Integration Guide

The workflow below will be useful for you, if you offer a web application or SaaS application and you wish to integrate Pabbly Subscriptions in your application.

Note: If you want to learn about the complete working of Pabbly Subscriptions you can check the “How It Works” guide below.
https://www.pabbly.com/subscriptions/how-it-works/

You can follow the workflow below to integrate Pabbly subscription in your SaaS/software application.

  1. Let’s say you are running your application on your website https://www.example.com
  2. You will be mentioning all the plans of your product on your website.
  3. Under each plan will be the checkout link of each plan. You will get the checkout link for plans after creating the product and plan inside Pabbly subscriptions product.
  4. If one of your customers tries to purchase any plan from your website.
  5. He will click the checkout link of any plan and he will be redirected to the checkout page.
  6. On the checkout page, he will fill his contact details including his name, email and address.
  7. After entering the credit card details, he will be redirected to the thanks page.
  8. You can also redirect customer to any custom thanks page on your application. The custom thanks page link is setup at the time of creating products inside Pabbly Subscriptions.
  9. When the customer is redirected to thanks page, the redirection link also includes a special query variable hostedpage.
    For example:
    https://www.inkthemes.com/?hostedpage=8ebdaa43b300805b078e66c014ed8625%3A9f42ed7e8275debf7df823bdd1a6cd070b8c2df97c23ae6bcf3f2d469967cee6ab8e614867af1f57df39449308469cb74051b16b559eb385a959a146257626fcaeea0269056b220133e4209caea561b954d50e14d5cca17993b82423b6fd58b5f09ef68191048f8b6d0a53dd13eee165451dae8b31312eec4decd435158a6a21b87597eed46c24f210398f8ad6842820
  10. You need to catch that query string and pass that value into the Verify Hosted page API to confirm the customer subscription. Check  https://www.pabbly.com/subscriptions/api/#section22
  11. The API response will give you the details of the customer along with the subscription status.

    {
        "status": "success",
        "message": "Invoice data",
        "data": [
            {
                "customer_id": "5a4b78053152df337d841348",
                "user_id": "5a4b5db47cfab6872a7feafa",
                "status": "paid",
                "amount": 99,
                "due_date": "2018-01-02T12:16:05.055Z",
                "plan_id": [
                    "5a4b5e7fcb9bc82fd2b4bff0"
                ],
                "subscription_id": "5a4b78053152df337d841349",
                "subscription": {
                    "customer_id": "5a4b78053152df337d841348",
                    "email_id": "neeraga@gmail.com",
                    "product_id": "5a4b5e6ecb9bc82fd2b4bfef",
                    "plan_id": "5a4b5e7fcb9bc82fd2b4bff0",
                    "user_id": "5a4b5db47cfab6872a7feafa",
                    "status": "live",
                    "quantity": "1",
                    "amount": 99,
                    "starts_at": "2018-01-02T12:16:05.055Z",
                    "activation_date": "2018-01-02T12:16:05.055Z",
                    "expiry_date": "",
                    "trial_days": 0,
                    "trial_expiry_date": "",
                    "next_billing_date": "",
                    "last_billing_date": "2018-01-02T12:16:05.508Z",
                    "plan": {
                        "product_id": "5a4b5e6ecb9bc82fd2b4bfef",
                        "user_id": "5a4b5db47cfab6872a7feafa",
                        "plan_name": "Life Time Plan",
                        "plan_code": "lifetime",
                        "price": "99",
                        "billing_period": "y",
                        "billing_period_num": "1",
                        "billing_cycle": "lifetime",
                        "billing_cycle_num": null,
                        "trial_period": null,
                        "setup_fee": null,
                        "plan_description": null,
                        "createdAt": "2018-01-02T10:27:11.365Z",
                        "updatedAt": "2018-01-02T10:27:11.365Z",
                        "id": "5a4b5e7fcb9bc82fd2b4bff0"
                    },
                    "setup_fee": null,
                    "payment_terms": "",
                    "pcustomer_id": "5a4b776f7cfab6872a7feb06",
                    "createdAt": "2018-01-02T12:16:05.503Z",
                    "updatedAt": "2018-01-02T12:16:05.535Z",
                    "payment_method": "5a4b78053152df337d841346",
                    "id": "5a4b78053152df337d841349"
                },
                "setup_fee": null,
                "pcustomer_id": "5a4b776f7cfab6872a7feb06",
                "createdAt": "2018-01-02T12:16:05.508Z",
                "updatedAt": "2018-01-02T12:16:05.541Z",
                "id": "5a4b78053152df337d84134a"
            }
        ]
    }
  12. From the API response, you should save the customer_id, subscription_id and plan_id in your database.
  13. You can map your applications user id with the Pabbly customer_id, So that you can check anything you like in future using different API’s of Pabbly subscription.
  14. If you want to check the status of any particular subscription you can use subscription_id of that customer to find the current status of subscription.
  15. Possible subscription status responses are as below. You can decide what you want to do with different subscription status in your application.

    • Trial – This represents that the subscription plan is now under a active and valid trial period.
    • Live – This represents that the subscription is active and paid up-to-date.
    • Dunning – This represents that the system tried renewing the subscription upon expiration and it failed and currently our system is attempting to collect payment from the customer by sending him dunning emails to update his credit card details.
    • Unpaid – This represents that the last invoice payment for this subscription was not received. The Dunning state leads to Unpaid status once all the attempts to collect the payment have failed.
    • Future – This represents that the subscription period starts in a future date and not on the current date.
    • Non Renewing – This appears when the subscription is cancelled using Cancel on Next Renewal date from the admin dashboard.
    • Canceled – This represents that the subscription has been cancelled. This may appear due to the manual cancellation of a subscription using Cancel Immediately or automatically subject to your Retry Settings preference.
    • Expired – This represents that the subscription period has expired.
    • Trial Expired – This represents that the trial period of the subscription plan has expired.