Using Typescript to make a system example on how to create benefit cards for employees.
- Create a Card.
- Activate a Card.
- Block/Unblock a Card.
- Recharge a Card.
- Make a purchase.
- Get balance and transactions.
Here is where a company create a card for their employees, getting the mployee ID and the type of card that is going to be created, and giving the api key from company.
POST /card/create
Body | Type | Description |
---|---|---|
employeeId |
integer |
Required. User Id |
cardType |
string |
Required. Type of card benefit |
Valid types: [groceries, restaurant, transport, education, health]
Headers | Type | Description |
---|---|---|
x-api-key |
string |
Required. API key, from company |
Security code number.
This route works to activate your card, which means you can create a password, with an maximum length of 4 numbers.
PUT "/card/activate/:cardId"
Body | Type | Description |
---|---|---|
password |
string |
Required. Card password |
securityCode |
string |
Required. Card security code |
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. Card ID |
Password length: 4
Password pattern: only numbers
Security code max length: 3
Here is where you can block or unblock your card, this route is for the employees, and dependes on current status from the card. On the route you have to put the card ID.
PUT /card/block/:cardId
Body | Type | Description |
---|---|---|
password |
string |
Required. Card password |
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. Card ID |
Here is where you put credit on your card. This route is for the company to recharge the cards. The amount is how much you'll recharge.
POST /recharges/:cardId
Headers | Type | Description |
---|---|---|
x-api-key |
string |
Required. API key, from company |
Body | Type | Description |
---|---|---|
amount |
integer |
Required. Recharge amount |
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. Card ID |
Here is where a purchase is made, you have to inform the card ID and where you're buying, the card and the business must have the same type.
POST /payment
Body | Type | Description |
---|---|---|
cardId |
integer |
Required. Card ID |
password |
string |
Required. Card password |
businessId |
integer |
Required. Business ID |
amount |
integer |
Required. Payment amount |
GET /card/transaction/:cardId
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. Card ID |
{
"balance": 35000,
"transactions": [
{ "id": 1, "cardId": 1, "businessId": 1, "businessName": "Business", "timestamp": "date", "amount": 5000 }
],
"recharges": [
{ "id": 1, "cardId": 1, "timestamp": "date", "amount": 40000 }
]
}