Part 2: Testing the Paystack Integration Using Postman
Tags: paymentgateway, paystack, java, springboot
Published: 2023-03-31 05:44:25

This is a follow-up article to Part 1, which guided Paystack payment gateway integration. It is going to be a very short and straightforward guide. We are going to be using Postman to test our endpoint.

This article will definitely not make sense if you haven't read Part 1, so please visit [here](https://dev.to/omoluabidotcom/integrate-paystack-payment-gateway-using-spring-boot-5fn2) to read and come back here.
We have three endpoints to make requests to accept payment.

**CreatePlan Endpoint**

Starting with the first endpoint, "CreatePlan endpoint," from PaystackController POJO, we see that the Createplan methods require us to pass in a request body three parameters, as in the image below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u8sos9pb1fixofav47mh.jpg)

The URL will be according to your configuration, and the request is a POST request. After hitting the endpoint, if everything goes well, the response will be as shown in the image below.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dn1bxbh2wzoeh33398e.jpg)

**InitializePayment Endpoint**
InitializePayment endpoint. From the name, it initiates the payment. This endpoint accepts a POST request, and its request body needs five JSON parameters as shown in the image below.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38jdv6sih5etetyuhnts.jpg)

The initializepayment endpoint URL should be similar to the createplan just the last part makes them different. The amount here in the JSON body should be the same as the amount used in createplan endpoint, and the value of the plan here in initializepayment endpoint is gotten from the response in the createplan endpoint, in particular the plan_code value.
Make a request to initializepayment endpoint if everything goes well, your response should be as in the image below.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jebhnz3sydxh99dh5nad.jpg)

The authorization_url in the response is where you redirect to. Since we are testing on the backend, copy the URL and paste it into a web browser, Paystack checkout page appears, and the user makes a payment, as shown in the pictures below.

**Checkout Page**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mfr83temaz4u7xq53mz0.jpg)

**Payment Succesful**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/der32llxv0diio5ahsvd.jpg)

**VerifyPayment Endpoint**

Paystack makes available means to verify if payment has been made. The verifypayment endpoint accepts GET requests.
Verifypayment endpoint needs three path variables to be passed in the URL to make a valid request as it relates to our implementation.
The three path variables to be added are reference, plan, and id respectively.
The reference is gotten from the initializepayment response body, the plan is the plan the user is paying for and the id is the user id.
If everything goes as expected, the response would be like the picture below.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ee122g1kmx25qh3ta99.jpg)

That is all for now, Thank you for your time. If you have questions, please drop them in the comment section. Have a great day.

**Credit**

[Paystack Documentation](https://paystack.com/docs/)