Introduction
This guide provides detailed instructions on how to integrate a custom payment gateway within Pabbly Subscriptions. Pabbly Subscriptions offers an open integrated payment API that allows you to seamlessly integrate any payment gateway of your choice.There are two methods for integrating your custom payment gateway:
1. Integration through Checkout Page
2. Integration through Pabbly Subscription API
We will walk you through each integration process step by step.
1. Integration through Checkout Page
Merchant (Sellers) Process:1. Add Custom Payment Gateway:
- Go to your payment gateway settings in Pabbly Subscriptions.
- Add the custom payment gateway option and provide the URL of your custom payment gateway integration file.
2. Host Integration File:
- Host the integration file on your server for handling payments through your custom payment gateway.
3. Redirect to Gateway URL:
- When a customer submits the checkout page, redirect the process to your gateway URL along with the checkout (hosted) page query string.
- Use the "Verify Hosted Page API" to get all checkout page data.
- Refer: Verify Hosted Page API
4. Fetch Customer Data:
- Use the fetched data and, if needed, call the "Get Single Customer" API to fetch additional customer data.
- Refer: Get Single Customer API
- Process the payment through your custom payment gateway integration using the details obtained in steps 2 and 3.
6. Update Payment Details in Pabbly Subscriptions:
- After successful payment processing, update customer details in Pabbly Subscriptions.
- Record payment data, add payment mode, transaction data, and payment note.
7. Redirect Customer:
- Redirect the customer to the Pabbly Subscriptions thank you page using data provided by the "Record Payment API."
- Optionally, redirect customers to your custom thank you page based on the details from the "Record Payment API."
8. Sample Code:
- Refer to the sample code on https://github.com/MagnetBrains/pab...eway/blob/master/checkout-with-hostedpage.php for implementation.
Customer Process:
1. Fill Checkout Form:
- Fill the checkout form with product and payment details.
2. Choose Custom Payment Gateway:
- Choose your custom payment gateway to proceed with the payment.
3. Payment Process:
- Be redirected to your payment gateway integration page and complete the payment successfully.
4. Return to Thank You Page:
- Be redirected back to the thank you page.
5. Recurring Billing:
- Receive a payable invoice during recurring billing and complete the payment.
2. Integration through API
Merchant (Sellers) Process:
1. Fetch Plan ID:
- Retrieve the plan ID for each created plan using your Pabbly Subscriptions account or relevant APIs.
- Refer:
- List All Products API
- List All Plans API
2. Create Customer with Subscription:
- Use the "Create Customer with Subscription" API to create a subscription for the customer with the initial status as "Pending."
- Refer: Create Customer with Subscription API
3. Capture API Response:
- Capture the API response and fetch data of the entire User, Customer, Product, Plan, and Invoice Object.
4. Process Payment:
- Use the details obtained in step 3 to process the payment through your custom payment gateway integration.
5. Update Payment Details in Pabbly Subscriptions:
- After successful payment processing, update customer details in Pabbly Subscriptions.
- Record payment data, add payment mode, transaction data, and payment note.
6. Redirect Customer:
- Redirect the customer to the Pabbly Subscriptions thank you page using data provided by the "Record Payment API."
- Optionally, redirect customers to your custom thank you page based on the details from the "Record Payment API."
7. Sample Code:
- Refer to the https://github.com/MagnetBrains/pabbly-subscription-custom-gateway/blob/master/checkout-with-api.php for implementation.