This is a simple implementation of an E-Wallet platform that supports the following features.
To setup this application first clone the repo
➜ git clone https://github.com/NathBabs/e-wallet.git
➜ cd e-wallet
next install dependencies
➜ npm install
create a .env
file for environment variables
create the following variables in the .env
file
DATABASE_URL=
PORT=
JWT_SECRET=
next run the following to start the server
➜ npm run dev
I have uploaded the .env.test
for easier setup without hassle.
Just run.
➜ npm test
** Ensure you have docker running already.
These are the routes you can call.
** For all protected routes, pass in the token to the Authorization header as Bearer [token] gotten from logging in or registering
method : POST
🌎 ➜ /wallet/register
payload
{
"email": "[email protected]",
"password": "nathaniel",
"balance": 5000
}
response
{
"success": true,
"message": "Your account has been created successfully. Here is your A/C No 6",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYiLCJpYXQiOjE2NDM0MTczMDAsImV4cCI6MTY0MzQyMDkwMH0.THSeL4ps2eYZLGSbkgauXoOU2D92KhhwrmNiyH-LuDs",
"user": {
"id": 6,
"email": "[email protected]",
"account": {
"accNumber": 6,
"balance": 5000
}
}
}
}
method : POST
🌎 ➜ /wallet/login
payload
{
"email": "[email protected]",
"password": "nathaniel"
}
response
{
"success": true,
"message": "Successfully logged in",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYiLCJpYXQiOjE2NDM1ODU1MjMsImV4cCI6MTY0MzU4OTEyM30.KImhEALfYMFrujbDiOm9Ubyd3nJqbz22pIe-zOoOZQ4"
}
}
method : POST
🌎 ➜ /wallet/logout
response
{
"success": true,
"message": "You have successfully logged out"
}
method : POST
🌎 ➜ /wallet/deposit?amount=3000
response
{
"success": true,
"message": "Your account has been credited with 3000, this is your new balance 4000",
"data": {
"balance": 7000
}
}
method : POST
🌎 ➜ /wallet/withdraw?amount=3000
response
{
"success": true,
"message": "Withdrawal successfull. Your new balance is now at 49000",
"data": {
"balance": 7000,
"amount": 1000,
}
}
method : POST
🌎 ➜ /wallet/transfer
to is the account you are transfering to
amount is how much you want to transafer
payload
{
"to": 6,
"amount": 900.00
}
response
{
"success": true,
"data": {
"transactionReference": "gm1SzBI0qnYy",
"balance": 7000
}
}
method : POST
🌎 ➜ /wallet/refund
txRef is the transaction reference you want to refund
payload
{
"txRef": "gm1SzBI0qnYy"
}
response
{
"success": true,
"message": "Refund has been completed here is the Transaction Refrence: refundgm1SzBI0qnYy"
}
method : GET
🌎 ➜ /wallet/history
response
{
"success": true,
"data": {
"transactions": [
{
"id": 10,
"txRef": "refundgm1SzBI0qnYy",
"amount": 900,
"refundRef": "gm1SzBI0qnYy",
"senderId": 6,
"receiverId": 4,
"created_at": "2022-01-30T23:40:59.380Z",
"updated_at": "2022-01-30T23:40:59.381Z"
},
{
"id": 8,
"txRef": "gm1SzBI0qnYy",
"amount": 900,
"refundRef": null,
"senderId": 4,
"receiverId": 6,
"created_at": "2022-01-30T23:37:30.521Z",
"updated_at": "2022-01-30T23:37:30.522Z"
}
]
}
}
method : GET
🌎 ➜ /wallet/balance
response
{
"success": true,
"balance": 49000
}