Prerequisite
The amount and the billing interval of the subscription derive from a plan previously configured on the account. The plan is identified, in the request, by theproductId and offerSlug fields. The interval may be weekly, monthly, bimonthly, quarterly, semiannual or annual.
Starting the subscription
Starting a subscription comprises two operations. The first converts the card data into a token, throughPOST /card-token, as described in Credit card. The second, POST /subscriptions, makes the first charge and creates the subscription.
First charge declined
The subscription is created only when the first charge is authorized. If it is declined, the response keeps status200, contains the transaction in the refused status, with the reason in refuseReason, and does not contain the subscription block. It is for the integrator to obtain another card and submit a new request.
A 400 response indicates that the plan was not found or is not configured as recurring. The temporary block of the payer described in Credit card applies to this operation.
Statuses
Renewal
At each cycle, the platform makes the charge on the card linked to the subscription. Each renewal charge is a transaction of its own and generates the ordinary transaction notifications, includingtransaction_paid, described in Webhooks.
Renewal failure
A declined renewal charge moves the subscription to theoverdue status, and the platform makes further charge attempts. Authorization of a further attempt restores the active status. Upon the fifth attempt without authorization, the subscription is cancelled by the platform.
Cancellation
ThePOST /subscriptions/{subscriptionId}/cancel operation cancels the subscription. From cancellation onwards, no further charge is made.
400 when the subscription is already cancelled or completed.
Retrieval
TheGET /subscriptions/{subscriptionId} operation returns the subscription, with its status, the date of the next charge, the plan contracted and the identification of the payer. The GET /subscriptions operation lists the subscriptions of the account, filtered by plan (productId, offerId), status (status), period and search text, and paginated by the page and limit parameters.
The listing also contains consolidated indicators in the stats block.