Nostraddeveloper documentationDocumentationDeveloper console

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

FieldWhat it is
GroupA 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
Level1 to 100; 1 offers the most. Decides what a plan change does
Billing periodP1W, P1M, P3M, P6M or P1Y. It can't change
Grace days0 to 30, and no more than the period's length. Empty is 16, or 6 for weekly
Hold daysGrace 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.

stateAccessWhat it means
activeYesPaid up. A failed renewal stays here for its first day
in_grace_periodYesA renewal failed; Nostrad tries again every day, and at once when credit is added
on_holdNoGrace ran out, or there was none; still retried. When it's paid, the renewal date moves to that day
canceledYes, until expires_atIt won't renew. It can still be restarted, unless you stopped its payments
expiredNoOver. 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.

ChangeWhat happens
Upgrade: a lower level numberStarts 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 periodStarts now, the same way
Downgrade: a higher level numberStarts at the next renewal. Nothing is charged today, and the old plan stays until then
Same level, another periodStarts 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

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.

Notifications

typeWhen
SUBSCRIPTION_PURCHASEDSomeone subscribed or changed plan (then with linked_purchase_token)
SUBSCRIPTION_RENEWEDA renewal was paid
SUBSCRIPTION_IN_GRACE_PERIODA renewal failed and grace began
SUBSCRIPTION_ON_HOLDGrace ended and access stopped
SUBSCRIPTION_RECOVEREDA subscription on hold was paid
SUBSCRIPTION_CANCELEDIt won't renew
SUBSCRIPTION_RESTARTEDThe buyer used Resubscribe before it ended
SUBSCRIPTION_EXPIREDIt ended
SUBSCRIPTION_REVOKEDAccess was taken back
SUBSCRIPTION_PRICE_CHANGE_UPDATEDA price move was announced, accepted, applied or ended a subscription

Testing one

Test subscriptions renew every few minutes: Testing purchases.