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/docs/how-it-works/
You can follow the workflow below to integrate Pabbly subscription in your SaaS/software application.
- Let’s say you are running your application on your website https://www.example.com
- You will be mentioning all the plans of your product on your website.
- 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.
- If one of your customers tries to purchase any plan from your website.
- He will click the checkout link of any plan and he will be redirected to the checkout page.
- On the checkout page, he will fill his contact details including his name, email and address.
- After entering the credit card details, he will be redirected to the thanks page.
- 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.
- 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 - 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/#section-31
- The API response will give you the details of the customer along with the subscription status.
{ "status": "success", "message": "Valid hosted page data", "data": { "plan": { "plan_active": "true", "bump_offer": {}, "createdAt": "2019-02-19T10:59:38.751Z", "updatedAt": "2019-02-19T10:59:38.751Z", "id": "5c6be19a44b44833b0c4e59c", "product_id": "5c6bde9944b44833b0c4e596", "user_id": "5c6bd93bebdd8a0e8b7ef6c9", "plan_name": "2 Novel Pack", "plan_code": "2-novel-pack", "price": 20, "billing_period": "m", "billing_period_num": "1", "billing_cycle": "lifetime", "billing_cycle_num": null, "trial_period": 0, "setup_fee": 0, "plan_description": "" }, "setup_fee": null, "payment_terms": "", "currency_symbol": "$", "payment_method": "5c6ce419b3eb0a4759bf851d", "taxable": true, "gateway_type": "stripe", "custom_fields": [], "cron_process": "done", "createdAt": "2019-02-20T05:22:33.683Z", "updatedAt": "2019-02-20T05:22:33.683Z", "id": "5c6ce419b3eb0a4759bf851a", "customer_id": "5c6ce419b3eb0a4759bf8519", "product_id": "5c6bde9944b44833b0c4e596", "plan_id": "5c6be19a44b44833b0c4e59c", "amount": 20, "email_id": "[email protected]", "status": "live", "quantity": 1, "starts_at": "2019-02-20T05:22:33.333Z", "activation_date": "2019-02-20T05:22:35.353Z", "expiry_date": "2119-02-20T05:22:33.333Z", "trial_days": 0, "trial_expiry_date": "", "next_billing_date": "2019-03-20T05:22:35.353Z", "last_billing_date": "2019-02-20T05:22:35.353Z", "canceled_date": null } }
- From the API response, you should save the customer_id, subscription_id and plan_id in your database.
- 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.
- 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.
- 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.