Skip to content

Instantly share code, notes, and snippets.

@afucher
Created July 15, 2021 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afucher/ae0c8f8500373c3e8e5f49b33075c096 to your computer and use it in GitHub Desktop.
Save afucher/ae0c8f8500373c3e8e5f49b33075c096 to your computer and use it in GitHub Desktop.

Extension

Create a new operation: allow-list.

That operation will change the number of rules that should be applied. When an account is allow-listed, authorizer should validate only two rules:

  1. The transaction amount should not be above limit
  2. No transaction should be approved when the card is blocked

The account is not allow-listed by default, and once it is allow-listed it can be disabled with a new allow-list operation.

The allow-list operation input is going to be:

{"allow-list": {"active": true}}

The output of that operation is going to be the current account state:

{"account": {"active-card": true, "available-limit": 100, "allow-listed": true}, "violations": []}

Examples:

For the following operations:

{ "account": { "active-card": true, "available-limit": 1000 } }
{ "allow-list": { "active": true } }
{ "transaction": { "merchant": "A", "amount": 20, "time": "2019-02-13T10:00:00.000Z" } }
{ "transaction": { "merchant": "B", "amount": 30, "time": "2019-02-13T10:00:01.000Z" } }
{ "transaction": { "merchant": "C", "amount": 40, "time": "2019-02-13T10:00:02.000Z" } }
{ "transaction": { "merchant": "D", "amount": 50, "time": "2019-02-13T10:00:03.000Z" } }
{ "transaction": { "merchant": "E", "amount": 2000, "time": "2019-02-13T10:00:04.000Z" } }
{ "allow-list": { "active": false } }
{ "transaction": { "merchant": "F", "amount": 50, "time": "2019-02-13T10:00:04.000Z" } }

The output should be:

{ "violations": [], "account": { "allow-listed": false, "available-limit": 1000, "active-card": true } }
{ "violations": [], "account": { "allow-listed": true, "available-limit": 1000, "active-card": true } }
{ "violations": [], "account": { "allow-listed": true, "available-limit": 980, "active-card": true } }
{ "violations": [], "account": { "allow-listed": true, "available-limit": 950, "active-card": true } }
{ "violations": [], "account": { "allow-listed": true, "available-limit": 910, "active-card": true } }
{ "violations": [], "account": { "allow-listed": true, "available-limit": 860, "active-card": true } }
{ "violations": ["insufficient-limit"], "account": { "allow-listed": true, "available-limit": 860, "active-card": true } }
{ "violations": [], "account": { "allow-listed": false, "available-limit": 860, "active-card": true } }
{ "violations": ["high-frequency-small-interval"], "account": { "allow-listed": false, "available-limit": 860, "active-card": true } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment