Menu

Custom payment gateway integration guide

This guide explains How you can integrate payment within Pabbly Subscriptions.

With Pabbly Subscriptions, we are offering an open integrated payment API through which you can integrate any payment gateway of your choice.

There are 2 methods in which you can integrate your own custom payment gateway to Pabbly Subscriptions.

  1. Integration through Checkout Page.
  2. Integration through Pabbly Subscription API.

I will explain the integration process of adding your own custom payment gateway one by one.

1. Integration through checkout page.

The first way to integrate a custom payment gateway is through the checkout page.

Whenever you create a product and plan within Pabbly Subscription, a checkout form for that product is automatically generated.  Your customers can then fill the checkout form and choose their ideal payment gateway and do the payment.


Pabbly Subscriptions custom payment gateway


To add your own custom payment gateway integration and do perform the payment through your custom gateway via checkout page, here is how the payment workflow takes place.

From Merchant (Sellers) end.

  1. You will add the custom payment gateway from your payment gateway settings.


    Pabbly Subscriptions Custom Payment Gateway


  2. You will add a link/URL of your own custom payment gateway integration file.


    Pabbly Subscriptions Custom payment gateways


      

  3. This file will be hosted on your server for handling the payments through your own custom payment gateway.
  4. When your customer submits the checkout page, the process will be redirected to your gateway URL along with the checkout(hosted) page query string.
  5. You can then run the “Verify Hosted Page API” by passing the value of the query string from the previous step to get all the check-out page data on your custom payment gateway integration page.
    Refer: https://www.pabbly.com/subscriptions/api/#section26
  6. The pre-payment data includes all the essential fields to do your own processing through your gateway. It includes fields details below.
    1. Customers Name
    2. Customer Email
    3. Customer ID
    4. Product Name
    5. Product Price
    6. Invoice ID
  7. If you need any further customer data apart from what is provided through the “Hosted Page API”, you can also get further customer data by calling the “Get Single Customer” API. This API will fetch you data for billing address, country state, etc.
    Refer: https://www.pabbly.com/subscriptions/api/#section3
  8. You can then use the details fetched in the steps 6 and 7 above and process the payment through your custom payment gateway integration.
  9. After completion of your payment through your payment gateway, you will be notified about the payment success through your gateway.
  10. Once the payment processing is successful, you need to update the details of the customers and record the payment for that customer in Pabbly Subscriptions.
  11. Details that need to be updated are below.
    1. Invoice: Record the payment data for the subscription to update the invoice.
    2. Payment Mode: You can add your own payment mode name. For example – Authorize.net or PayPro
    3. Transaction Data: You can store any transaction data returned from your payment gateway within Pabbly Subscriptions.
    4. Payment Note: Add your own custom payment note for the payment.
  12. Once the payment is updated, you can redirect the customer to the Pabbly Subscriptions thank you page by using the data provided by the “Record Payment API”.
  13. If required you can also redirect the customers to your own custom thank you page based on the details provided by the “Record Payment API”.
  14. Sample code for your reference is included below.
    https://github.com/MagnetBrains/pabbly-subscription-custom-gateway/blob/master/checkout-with-hostedpage.php
  15. We have also integrated a custom payment gateway “RazorPay” by following the steps explained above. You can checkout the integration through the link below. https://github.com/MagnetBrains/pabbly-subscription-razorpay-php

From Customers end. Here is how the payment workflow happens.

  1. Customer will fill the checkout form.
  2. Customer will choose your custom payment gateway to do the payment.
  3. They will be redirected to your payment gateway integration page.
  4. They will do the payment successfully.
  5. They will be redirected back to the thank you page.

2. Integration through API.

The second way to integrate a custom payment gateway is through the Pabbly Subscriptions API. The integration with API is fairly straightforward.

To add your own custom payment gateway integration and do perform the payment through your custom gateway via API, here is how the payment workflow takes place.

From Merchant (Sellers) end.

  1. Whenever you create a product and plan within Pabbly Subscription. You get the plan ID for each created plan.
  2. Plan ID can be fetched through your Pabbly Subscriptions account or it can also be fetched by running the “List All Products” and “List All Plans” or “List All Plans by Product Id” API.
    Refer:
    List All Products: https://www.pabbly.com/subscriptions/api/#section12
    List All Plans: https://www.pabbly.com/subscriptions/api/#section15
  3. Once the details are fetched, you can then run the “Create Customer with Subscription” API to create the subscription for the customer. This API requires all the customer details including the plan id for which you want to subscribe to the customer. The initial subscription is created with “Pending” status.
    Refer: https://www.pabbly.com/subscriptions/api/#section2
  4. You can then capture the API response from the “Create Customer with Subscription” API and fetch data of the entire User, Customer, Product, Plan, Invoice Object.
  5. You can then use the details fetched in the step above and process the payment through your custom payment gateway integration.
  6. After completion of your payment through your payment gateway, you will be notified about the payment success through your gateway.
  7. Once the payment processing is successful, you need to update the details of the customers and record the payment for that customer in Pabbly Subscriptions.
  8. Details that need to be updated are below.
    1. Invoice: Record the payment data for the subscription to update the invoice.
    2. Payment Mode: You can add your own payment mode name. For example Authorize.net or PayPro
    3. Transaction Data: You can store any transaction data returned from your payment gateway within Pabbly Subscriptions.
    4. Payment Note: Add your own custom payment note for the payment.
  9. Once the payment is updated, you can redirect the customer to the Pabbly Subscriptions thank you page by using the data provided by the “Record Payment API”.
  10. If required you can also redirect the customers to your own custom thank you page based on the details provided by the “Record Payment API”.
  11. Sample code for your reference is included below.
    https://github.com/MagnetBrains/pabbly-subscription-custom-gateway/blob/master/checkout-with-api.php