Subscription lifecycle
Overview
A subscription is a product of type subscription. The buyer pays from their Nostrad credit every period until it's cancelled. It's sold like any other product: POST /v1/purchases, the Nostrad purchase page, and your server acknowledges it within 3 days or it's refunded and ended. It keeps one purchase_token across renewals; each charge is an order. Later renewals need no acknowledgement.
Setting one up
| Field | What it is |
|---|---|
| Group | A buyer has one subscription per group, so plans of one service share a group. Letters, numbers, ., - and _, up to 64. It can't change. Up to 100 products in a group |
| Level | 1 to 100; 1 offers the most. Decides what a plan change does |
| Billing period | P1W, P1M, P3M, P6M or P1Y. It can't change |
| Grace days | 0 to 30, and no more than the period's length. Empty is 16, or 6 for weekly |
| Hold days | Grace and hold together are 30 to 60 days. Empty brings them to 60 |
Checking one
GET /v1/purchases/<token> answers:
{ "purchase_token": "pt_...", "type": "subscription", "state": "active", "product": "plus_monthly", "group": "plus", "period": "P1M",
"started_at": 1793000000000, "expires_at": 1795600000000, "auto_renew": true, "latest_order_id": "NOS.1234-5678-9012-34567",
"price": { "credits": 500, "usd": "$5.00" }, "linked_purchase_token": null, "acknowledgement": "acknowledged",
"acknowledge_by": null, "account_token": "user-1", "test": false }
Also, when they apply: canceled (by: customer, developer, system or replacement, and at), expiration_reason, price_change (new_price, state: outstanding, confirmed, applied or canceled, and charge_at), grace_ends_at, revoked_at and deferred_change (product, price, at). Two months after a subscription ends, its token answers 410 no_longer_available.
state | Access | What it means |
|---|---|---|
active | Yes | Paid up. A failed renewal stays here for its first day |
in_grace_period | Yes | A renewal failed; Nostrad tries again every day, and at once when credit is added |
on_hold | No | Grace ran out, or there was none; still retried. When it's paid, the renewal date moves to that day |
canceled | Yes, until expires_at | It won't renew. It can still be restarted, unless you stopped its payments |
expired | No | Over. Subscribing again is a new purchase, with a new token |
GET /v1/purchases and owned on GET /v1/products list a subscription only while it gives access, so one on hold is left out; your server still sees it by its token.
When a renewal fails
If the buyer's credit doesn't cover a renewal, they get one silent day, then the grace days, then the hold days, with an email at the start of grace and of hold. When hold runs out, the subscription ends with expiration_reason billing_error. Editing a product's grace or hold doesn't change the dates of anyone already in them.
Changing plan
Start a purchase of another product in the same group with the person's token. The purchase page says what will happen. The old subscription must be acknowledged first, or the answer is 409 pending_acknowledgement; asking for the plan they already have is 409 already_owned.
| Change | What happens |
|---|---|
| Upgrade: a lower level number | Starts now, charged in full (the buyer's credit must cover the whole price first), with the unused part of the old period back as credit |
| Same level, same period | Starts now, the same way |
| Downgrade: a higher level number | Starts at the next renewal. Nothing is charged today, and the old plan stays until then |
| Same level, another period | Starts at the next renewal, the same way |
| Any change while a renewal is unpaid (grace or hold) | Starts now, charged in full, with nothing back: no paid period is left |
Every change makes a new purchase token, whose linked_purchase_token is the old one, and ends the old token with canceled.by replacement. Follow the link, and stop giving access for the old token. Acknowledge the new token as usual, unless the change waits for the next renewal: then nothing has been charged, so it already answers acknowledged (latest_order_id stays the old plan's until it starts, shown in deferred_change).
Cancelling and refunds
- The buyer uses Cancel on their Credit page, or your link to
https://accounts.nostrad.ai/account#subscriptions. They keep it until the period ends, and Resubscribe carries on with the same token and no new order. Your server hearsSUBSCRIPTION_CANCELED, thenSUBSCRIPTION_RESTARTEDor, at the end,SUBSCRIPTION_EXPIRED. POST /v1/purchases/<token>/cancelwith{ "type": "stop_renewals" }does the same as the buyer's Cancel.{ "type": "stop_payments" }also means it can't be restarted. Both are safe to repeat and answer the subscription.POST /v1/purchases/<token>/revokewith{ "refund": "full" }or{ "refund": "prorated" }ends access now and refunds the latest charge, whole or for the unused part. You hearVOIDED_PURCHASEandSUBSCRIPTION_REVOKED.- Refunding an order (section 8) gives money back. With
revoke: trueon the latest order, it also ends the subscription. An older order can only be refunded, without revoke.
Changing the price
A product's new price is for new buyers. Under Manage, Move existing subscribers to the new price moves everyone already paying, however many there are (a very large app finishes in the background), and Subscribers shows how many pay what.
- A lower price applies from each one's next renewal, and they're told by email.
- A higher price needs each one's yes. For the first 7 days nobody is told, and Undo the price move cancels it. They're told by email at least 30 days before, and first pay at the first renewal at least 37 days after the move. They use Accept new price on their Credit page; anyone who hasn't by then loses the subscription on that renewal, with
expiration_reasonprice_increase_not_accepted. - Moving again replaces the earlier move. Each step sends
SUBSCRIPTION_PRICE_CHANGE_UPDATED.
Notifications
type | When |
|---|---|
SUBSCRIPTION_PURCHASED | Someone subscribed or changed plan (then with linked_purchase_token) |
SUBSCRIPTION_RENEWED | A renewal was paid |
SUBSCRIPTION_IN_GRACE_PERIOD | A renewal failed and grace began |
SUBSCRIPTION_ON_HOLD | Grace ended and access stopped |
SUBSCRIPTION_RECOVERED | A subscription on hold was paid |
SUBSCRIPTION_CANCELED | It won't renew |
SUBSCRIPTION_RESTARTED | The buyer used Resubscribe before it ended |
SUBSCRIPTION_EXPIRED | It ended |
SUBSCRIPTION_REVOKED | Access was taken back |
SUBSCRIPTION_PRICE_CHANGE_UPDATED | A price move was announced, accepted, applied or ended a subscription |
Testing one
Test subscriptions renew every few minutes: Testing purchases.