The Wallet System Service is an API that mocks a basic wallet system. The API provides information about various aspects of wallet systems such as User Authentication/Role-Based Authorization, Paystack API Gateway integration for wallet funding, Wallet Creation, Wallet Balance Retrieval, Wallet Funds Transfer and Transaction History Summary.
- User Authentication/Role-Based Authorization
- User Wallets Creation
- Wallet Account Crediting/Funding via Paystack Payment Gateway
- Wallet Funds Transfer & Approval
- Wallet Balance Retrival
- Wallet Transaction History
The following steps were followed in the implementation of a wallet system with minimalistic features leveraging on the Paystack API Gateway:
-
PayStack Account Setup: Visit the Paystack website (
https://paystack.com
) and sign up for an account. Then obtain the API keys from thedeveloper section
of the the aforementioned website. Paystack provides both test and production keys for development and testing purposes. However, in most cases, one'd be utilizing the test keys. -
Paystack API Integration.
-
Create Wallet Functionality: Within the application, the necessary logic and database structure were implemented to manage user wallets. This involved creating a wallet table, associating wallets with the user accounts, defining actions such as deposit, withdrawal amongst others.
-
User Authentication/Role-Based (Admin) Authorization: A user authentication system was implemented to secure wallet functionality. This includes features like user registration, user login, JWT token authentication, API endpoints protection.
-
Funds Deposit to Wallets: The Paystack API was used to create a payment request or payment authorization link for crediting funds into a user's wallet. This involved setting the necessary details to Paystack like including amount, customer details, and callback URL to handle payment response.
-
The requested amount must be sent in the subunit of that currency. For example, if a customer is supposed to make a payment of
NGN 100
, you would send10000 = 100 * 100
in your request. -
Payments Verification: After a payment is made, Paystack will send a
callback
to your specified URL i.e.http://example.com
either set on the paystack developer dashboard or the one specified in your implementation. Once the notification has been processed, verify the transaction status and update the user's wallet accordingly. -
Wallet Withdrawal Functionality: This was implemented from the scratch - point
3
. For everydeposit
ortransfer
request initiated, a request was logged to thewallet_transactions
to keep track of the wallet transactions. -
Balance Retrieval & Transaction History: Endpoints were implemented to retrieve user's wallets balances' & transaction history. This involves querying from the
wallet_transactions
andwallets
tables to spool the results data sets.
Overall, the project is designed to be scalable, maintainable and extensible. The use of a monolithic architecture that can easily spin off to a micro-service following modular architecture pattern that promotes code organization and separation of concerns.
PORT=4000
NODE_ENV=development
PAYSTACK_SECRET_KEY=XXXX
PAYSTACK_API_BASE_URL=https://api.paystack.co
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=XXXX
POSTGRES_PASSWORD=XXXX
POSTGRES_DB=postgres
DB_TYPE=postgres
MININUM_APPROVAL_AMOUNT=1000000
TEST_PAYSTACK_SECRET_KEY=XXXX
TEST_PAYSTACK_API_BASE_URL=https://api.paystack.co
TEST_POSTGRES_HOST=localhost
TEST_POSTGRES_PORT=5432
TEST_POSTGRES_USER=XXXX
TEST_POSTGRES_PASSWORD=XXXX
TEST_POSTGRES_DB=XXXX
$ git clone https://github.com/sheygs/wallet-system.git
$ cd wallet-system
$ yarn install
$ yarn run start:dev
- Install Docker
- Run
docker-compose up -d
. - Open browser and visit
http://localhost:4000
and rock it
- Run
yarn install
to install project dependencies - Run
yarn start:dev
to run the services and you are good - Open browser and visit
http://localhost:4000
and rock it
- RUN
yarn run start:prod
to start the production build
docker build -t ${IMAGETAG} -f Dockerfile .
$ yarn test:e2e
- Please see
/postman_docs
on the root directory OR - Navigate to
http://localhost:4000/docs
on your computer to view the openapi documentation.
- Implement a Notification process (email/mobile notification) when an automated deposit fails due to insufficient funds.
- Implement Phone Number verification using third-party SMS providers e.g. Twilio API