This guide contains a walkthrough with visual examples, and a list of all Core API Subscription Management objects.
Summary
- Feature
- Advanced Billing API
- You Need
- 1. Developers
2. Existing frontend UI for subscription management
3. Backend that recognizes a logged in user - Code
- Yes
- Difficulty
- ◉◉◉◎◎
Core Subscription Management API Resources
The core API resources for managing subscriptions.
Resource |
Description |
Read Customer’s Subscriptions |
|
Read Customer Payment Profiles |
|
Update Customer |
|
Read Subscription |
|
Read Subscription Invoices |
|
List Subscription’s Components (All) |
|
List Subscription’s Components (Only ones subscribed to) |
GET /components.json > if allocated_quantity > 0, show. if kind is metered_component and price_point_id is not null, show. |
Next billing amount and next renewal date |
GET /subscriptions/:id.json > parse current_billing_amount_in_cents and next_assessment_at |
Resource |
Description |
Read Products from Catalog |
|
Preview Prorated Product U/D |
|
Execute Prorated Product U/D |
|
Schedule Upgrade/Downgrade for Next Renewal |
|
Read Subscription’s Components |
|
Preview Component U/D |
|
Execute Component U/D |
|
Read Offers from Catalog |
|
Preview Offer U/D |
|
Execute Offer U/D |
|
Enforce upgrades only |
In your UI, only allow changes if the total cost of the change is greater than the current cost. Additionally, if you do not want to display lower cost options at all, filter out what you display to the user, based on price. |
Resource |
Description |
View Invoices |
|
Cancel Subscription (immediate) |
|
Reactivate Subscription |
|
Create Pending Cancellation (delayed) |
|
Remove Pending Cancellation |
|
Pause Subscription |
|
Resume Paused Subscription |
Resource |
Description |
Collect Payment Information |
Docs: Chargify.js |
Read Customer’s Payment Profiles |
|
Create Payment Profile for Customer |
|
Set Default Payment Method on Subscription |
Resource |
Description |
Cancel a Group (immediate) |
|
Cancel a Group (delayed) |
|
Read Consolidated Invoices for Group |
|
Read Child Invoices |
|
Remove Canceled Subscription from Group |
Create a Subscription Management Dashboard
In this first section, you’ll create a subscription dashboard for your users, so they can view their subscription data, view their invoices, add/update payment methods, and perform actions on their subscription. These are visual examples, no code is available for these examples.
-
Read the subscription
You’ll need the subscription id, and then perform GET /subscriptions/:id.json.
- Parse the data you want to display
For example, the subscription id would be similar toresponse.subscription.id
. Maybe you want the customer organization, which would beresponse.subscription.customer.organization
-
Pass the data to your frontend, and display it
Here is a sample image that shows what an end result might look like:
-
Read the subscription’s invoices
You’ll need the subscription id, and then perform GET /invoices.json?subscription_id=:id
- Parse the data you want to display
For example, the invoice uid would be similar toresponse.invoice.uid
, or the invoice numberresponse.invoice.number
, or the invoice urlresponse.invoice.public_url
. -
Pass the data to your frontend, and display it
Here is a sample image that shows what an end result might look like in a basic table/list layout:
-
Display the components to change
Read the subscription’s components by performing GET /components.json.
- Parse the data you want to display
For example, the component name would be similar toresponse[0].component.name
. -
Pass the data to your frontend, and display it
Here is a sample image that shows what an end result might look:
- Add a preview changes section
Make a POST to /allocations/preview.json, parse the result, and display. This will show the user what the cost will be. -
Submit the form with a “Change Add Ons” button
Make the api call with POST /allocations.json
- Test your subscription dashboard
Your subscription dashboard should now reflect the changes of the subscription.
-
Add a cancel action
It might look like this:
- Add a page in your UI, with a preview, confirmation, and submit button
It might look like this. This is a great place to clearly establish the terms of cancellation and informing the user of what will happen. -
Upon submit, cancel the subscription
Choose which method you prefer:
Cancel Subscription (Immediate)
The user can cancel their subscription, and the cancellation takes effect immediately.
Cancel Subscription (Delayed)
The user can schedule their subscription to cancel at the end of the current billing period.
- Test your subscription dashboard
On your subscription dashboard, if you show the subscription state, it should now reflect the changes of the subscription. If there are certain actions that need to be shown/removed for a canceled subscription, or a subscription that is scheduled to cancel, do those in your UI.
-
Add a reactivation action, and only show it when a subscription is canceled
It might look like this:
- Add a page in your UI, with a preview, confirmation, and submit button
It might look like this. This is a great place to clearly establish the terms of reactivation and informing the user of what will happen, such as how much they will be charged (if any), and anything else you need to communicate. -
Upon submit, reactivate the subscription
Do this by performing a /subscriptions/:id/reactivate.json
- Test your subscription dashboard
On your subscription dashboard, if you show the subscription state, it should now reflect the changes of the subscription. If there are certain actions that need to be shown/removed for an active subscription, do those in your UI.
-
Add a pause action
It might look like this:
- Add a page in your UI, with a preview, confirmation, and submit button
It might look like this: This is a great place to clearly establish the terms of pausing and informing the user of what will happen. -
Upon submit, cancel the subscription
Do this with POST /subscription/:id/hold.json
- Test your subscription dashboard
On your subscription dashboard, if you show the subscription state, it should now reflect the changes of the subscription. If there are certain actions that need to be shown/removed for a paused subscription, do those in your UI.
-
Add a resume action, and only show it when a subscription is paused
It might look like this:
- Add a page in your UI, with a preview, confirmation, and submit button
It might look like this. This is a great place to clearly establish the terms of resuming and informing the user of what will happen. -
Upon submit, resume the subscription
Do this by performing /subscriptions/:id/resume.json
- Test your subscription dashboard
On your subscription dashboard, if you show the subscription state, it should now reflect the changes of the subscription. If there are certain actions that need to be shown/removed for a active subscription, do those in your UI.