Subscriptions
Subscriptions is a beta feature.
Subscriptions enable merchants to generate reliable recurring revenue. Merchants can easily create subscription plans and automatically charge customers on a periodic basis.
When working with subscriptions, there are a few building blocks to consider:
- Subscription Plan.
- Subscription.
- Subscription Charges.
Plan
The subscription plan defines the core attributes of future subscriptions. It could be used as a possible source for the list of subscription plans for customers to select from.
The plan has the following attributes:
- Periodicity (minimum 1 day, maximum 365 days)
- Token from the list of supported tokens.
- Amount.
- Description.
- Tags.
- Status.
Plan statuses have the following mechanics:
- Once created, a plan has a
Draft
status. The plan can be updated in this status only. - In order to create a subscription based on a plan, that plan should be switched to
Active
. - When a plan is no longer needed, it should be moved to a
Acrhive
status. Subscriptions cannot be created in this status anymore, but you can always move them back to active status if needed.
The main purpose of tags is to group and categorize plans. You an assign arbitrary tags to plans and use them in UI to filter or group plans according to your logic.
Subscription
A subscription is an entity that is linked to a subscription plan and contains charging rules. Charging rules are immutable and implemented as a smart contract on a blockchain network. Once deployed, this smart contract controls the number of tokens being transferred from the payer to the merchant.
The following status transitions are possible for a subscription.
Subscription Charges
A subscription charge represents a single token transfer from the payer to the merchant.
The following statuses could be assigned to a subscription charge:
Status | Description |
---|---|
Pending | The charge is waiting to be processed. |
Succeeded | The charge was successfully processed on the blockchain. |
Retrying | The previous charge attempt failed, and the system is making another attempt. |
Failed | The charge has failed for some reason, and no more attempts will be made automatically. |
Cancelled | The charge was canceled. |