- Get the card balance and transactions
- Create cards
- Activate / Block / Unlock a card
- Recharge a card
- Make card payments with online payment option
TL;DR
POST /cards/create
Header:
{
"x-api-key": string
}
Body:
{
"employeeId": integer,
"cardType": string
}
Response:
{
"cardId": 1,
"number": "1111 1111 1111 1111",
"cardholderName": "NAME N NAME",
"creditCardCVC": "111",
"expirationDate": "01/27",
}
PATCH /cards/activate
Body:{
"employeeId": integer,
"secutiryCode": string,
"password": string
}
POST /cards/recharge
Header:
{
"x-api-key": string
}
Body:
{
"cardId": integer,
"value": integer,
}
PATCH /cards/block
Body:
{
"cardId": integer,
"password": string
}
PATCH /cards/unlock
Body:
{
"cardId": integer,
"password": string
}
GET /cards/statement/:cardId
Params:
{
"cardId": integer
}
POST /purchases/pos/:cardId
Body:
{
"cardId": integer,
"businessId": integer,
"cardPassword": string,
"value": integer
// value: use 4000 instead of 40.00
}
POST /cards/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 |
{
"cardId": 1,
"number": "1111 1111 1111 1111",
"cardholderName": "NAME N NAME",
"creditCardCVC": "111",
"expirationDate": "01/27",
}
PATCH /cards/activate
Body | Type | Description |
---|---|---|
employeeId |
integer |
Required. employeeId |
securityCode |
string |
Required. card cvv |
password |
string |
Required. card password |
Password length: 4
Password pattern: only numbers
CVV max length: 3
CVV pattern: only numbers
POST /cards/recharge
Headers | Type | Description |
---|---|---|
x-api-key |
string |
Required. api key |
Body | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
value |
integer |
Required. recharge amount |
PATCH /cards/block
Body | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
password |
string |
Required. card password |
Password length: 4
Password pattern: only numbers
PATCH /cards/unlock
Body | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
password |
string |
Required. card password |
Password length: 4
Password pattern: only numbers
GET /cards/statement/:cardId
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
{
"balance": 35000,
"transactions": [
{ "id": 1, "cardId": 1, "businessId": 1, "businessName": "DrivenEats", "timestamp": "22/01/2022", "amount": 5000 },{...},{...}
],
"recharges": [
{ "id": 1, "cardId": 1, "timestamp": "21/01/2022", "amount": 40000 },{...},{...}
]
}
POST /purchases/pos/
Body | Type | Description |
---|---|---|
cardId |
integer |
Required. cardId |
businessId |
integer |
Required. card expiration date |
cardPassword |
string |
Required. card password |
value |
integer |
Required. payment value |
Value: must be without period, like '4000' instead of '40.00'
To run this project, you will need to add the following environment variables to your .env file
DATABASE_URL = postgres://YOUR-USER-NAME:YOUR-PASSWORD@Hostname:5432/DatabaseName
PORT = number
CRYPTR_SECRET = any string
Clone the project
git clone https://github.com/DarlonGomes/projeto18-valex
Go to the project directory
cd projeto18-valex/
Install dependencies
npm install
Create database
cd valex-setup/
bash ./create-database
cd ../../..
Start the server
npm run start
- API Architecture
- TypeScript interfaces
- TypeScript types
- Classes
- Constructor
- Object Literals
- Darlon Gomes is a student at Driven Education and is putting effort into switch careers. Nowadays he works with Fine Woodworking looking forward to become a Fullstack Dev.