Subscriptions

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:

  1. Subscription Plan.
  2. Subscription.
  3. 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:

  1. Periodicity (minimum 1 day, maximum 365 days)
  2. Token from the list of supported tokens.
  3. Amount.
  4. Description.
  5. Tags.
  6. 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.

Subscriptions flow

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:

StatusDescription
PendingThe charge is waiting to be processed.
SucceededThe charge was successfully processed on the blockchain.
RetryingThe previous charge attempt failed, and the system is making another attempt.
FailedThe charge has failed for some reason, and no more attempts will be made automatically.
CancelledThe charge was canceled.