run yarn install
Before you begin, make sure you have the following installed on your machine:
git clone <repository-url>
cd <repository-directory>
Replace with the URL of the public repository you want to clone.
Use Yarn to install the project dependencies:
yarn install
This command will read the package.json file and install all the necessary packages.
Copy the .env.example file to a new file named .env:
cp .env.example .env
Start the Express.js application with the following command:
yarn run dev
Visit http://localhost:4000 in your web browser to see the running application.
-
Access Swagger UI:
- Open your web browser and navigate to the Swagger UI documentation at
/docs
. For example, if your application is running locally, the URL would behttp://localhost:3000/docs
.
- Open your web browser and navigate to the Swagger UI documentation at
-
Explore Endpoints:
- In the Swagger UI interface, you'll see a list of available endpoints. Locate the
POST /api/user/signup
endpoint for user registration and thePOST /api/auth/login
endpoint for user login.
- In the Swagger UI interface, you'll see a list of available endpoints. Locate the
-
Sign Up (if not already registered):
- If you don't have an account, start by signing up:
- Click on the
POST /api/user/signup
endpoint. - Click on the "Try it out" button.
- Provide the required information such as
username
,email
, andpassword
. - Click on the "Execute" button to create a new user.
- Click on the
- If you don't have an account, start by signing up:
-
Log In:
- After signing up, navigate to the
POST /api/auth/login
endpoint:- Click on the
POST /api/auth/login
endpoint. - Click on the "Try it out" button.
- Enter the
username
andpassword
that you used during signup. - Click on the "Execute" button.
- Click on the
- After signing up, navigate to the
-
Retrieve Access Token:
- If the login is successful, you'll see a
200 OK
response in the Swagger UI. - Look for the
200
response under the "Responses" section. - In the response body, you should see an
accessToken
. This token is your access token.
- If the login is successful, you'll see a
-
Copy Access Token:
- Copy the value of the
accessToken
. This token will be used to authenticate and authorize your subsequent requests to protected endpoints.
- Copy the value of the
Now you have successfully logged in using Swagger UI, obtained the access token, and are ready to make authenticated requests to your API. Ensure to include the access token in the Authorization
header for protected endpoints.
- POST /api/transactions/initiate
-
Access Swagger UI:
- Open your web browser and navigate to the Swagger UI documentation at
/docs
.
- Open your web browser and navigate to the Swagger UI documentation at
-
Find Initialize Transaction Endpoint:
- In Swagger UI, locate the
POST /api/transactions/initiate
endpoint.
- In Swagger UI, locate the
-
Try It Out:
- Click on the
POST /api/transactions/initiate
endpoint. - Click on the "Try it out" button.
- Click on the
-
Provide Required Data:
- Input the necessary information required to initialize the transaction, as specified in the Swagger documentation.
- Click on the "Execute" button.
-
Capture Response:
- Review the response, which should include a payment gateway URL and other relevant data.
- Note down the payment gateway URL.
-
Redirect to Payment Gateway:
- Open a new browser window or tab and navigate to the payment gateway URL obtained in Step 1.
-
Complete Payment:
- Follow the payment gateway's instructions to complete the transaction.
- POST /api/webhooks/confirm
-
Wait for Payment Gateway Callback:
- After completing the payment on the payment gateway, wait for the payment gateway to call the webhook.
-
Webhook Confirmation:
- Once the webhook is triggered, it will send a POST request to
/api/webhooks/confirm
.
- Once the webhook is triggered, it will send a POST request to
-
Update Transaction Status:
- The server will update the status of the transaction in the database based on the webhook data.
- GET /api/transactions
-
Access Swagger UI:
- Open your web browser and navigate to the Swagger UI documentation at
/docs
.
- Open your web browser and navigate to the Swagger UI documentation at
-
Find List User's Transactions Endpoint:
- In Swagger UI, locate the
GET /api/transactions
endpoint.
- In Swagger UI, locate the
-
Try It Out:
- Click on the
GET /api/transactions
endpoint. - Click on the "Try it out" button.
- Click on the
-
Retrieve User's Transactions:
- Input any required parameters, such as user ID or other filters, as specified in the Swagger documentation.
- Click on the "Execute" button to retrieve a list of the user's transactions.
Now you have successfully completed the transaction flow, from initializing the transaction to confirming the payment through the webhook, and finally, viewing the user's transactions.
- POST /api/transactions/initiate
-
Access Swagger UI:
- Open your web browser and navigate to the Swagger UI documentation at
/docs
.
- Open your web browser and navigate to the Swagger UI documentation at
-
Authenticate:
- Click on the "Authorize" button on the top right.
- Enter your JWT access token in the "Value" field, prefixed with "Bearer ".
- Click on the "Authorize" button.
-
Find Initialize Transaction Endpoint:
- In Swagger UI, locate the
POST /api/transactions/initiate
endpoint.
- In Swagger UI, locate the
-
Try It Out:
- Click on the
POST /api/transactions/initiate
endpoint. - Click on the "Try it out" button.
- Click on the
-
Provide Required Data:
- Input the necessary information required to initialize the transaction, as specified in the Swagger documentation.
- Click on the "Execute" button.
-
Capture Response:
- Review the response, which should include a payment gateway URL and other relevant data.
- Note down the payment gateway URL.
-
Redirect to Payment Gateway:
- Open a new browser window or tab and navigate to the payment gateway URL obtained in Step 1.
-
Complete Payment:
- Follow the payment gateway's instructions to complete the transaction.
- POST /api/webhooks/confirm
-
Wait for Payment Gateway Callback:
- After completing the payment on the payment gateway, wait for the payment gateway to call the webhook.
-
Webhook Confirmation:
- Once the webhook is triggered, it will send a POST request to
/api/webhooks/confirm
.
- Once the webhook is triggered, it will send a POST request to
-
Update Transaction Status:
- The server will update the status of the transaction in the database based on the webhook data.
- GET /api/transactions
-
Access Swagger UI:
- Open your web browser and navigate to the Swagger UI documentation at
/docs
.
- Open your web browser and navigate to the Swagger UI documentation at
-
Authenticate:
- Click on the "Authorize" button on the top right.
- Enter your JWT access token in the "Value" field, prefixed with "Bearer ".
- Click on the "Authorize" button.
-
Find List User's Transactions Endpoint:
- In Swagger UI, locate the
GET /api/transactions
endpoint.
- In Swagger UI, locate the
-
Try It Out:
- Click on the
GET /api/transactions
endpoint. - Click on the "Try it out" button.
- Click on the
-
Retrieve User's Transactions:
- Input any required parameters, such as user ID or other filters, as specified in the Swagger documentation.
- Click on the "Execute" button to retrieve a list of the user's transactions.
Now you have successfully completed the transaction flow, with authentication, from initializing the transaction to confirming the payment through the webhook, and finally, viewing the user's transactions.