Subscriptions
Subscriptions is a beta feature, things can change slightly here and there.
Use the API described below to integrate subscriptions into your app or e-commerce system.
To learn more about subscriptions, visit this section.
To create a subscription via API one should follow these steps:
Get active subscription plans.
Create a new subscription in a
Draft
state, and get a future contract address.Broadcast a particular approve spending transaction into the blockchain, for the corresponding token and contract as a spender.
Activate subscription.
See also:
See a full example with signature creation.
See the list of supported tokens for the possible amount values.
Things to consider:
Subscription plans should be created upfront via Merchant Admin UI.
Plans should be activated to be used.
API Key and Secret should be created.
❗Gas Wallet for the corresponding network should be configured.
Returns active subscription plans
GET
<api>/integration/subscription-plans
Query Parameters
Name | Type | Description |
---|---|---|
limit | Integer | Result limit |
offset | Integer | Result offset |
Headers
Name | Type | Description |
---|---|---|
x-api-key* | String | API Key |
x-api-sig* | String | Signature created using API Secret |
x-api-ts* | String | Timestamp of the request |
Create a subscription
POST
<api>/integration/subscriptions
Creates a new subscription in a Draft state, you should activate it by giving allowance for the subscription contract.
Headers
Name | Type | Description |
---|---|---|
x-api-key* | String | API Key |
x-api-sig* | String | Signature created using API Secret |
x-api-ts* | String | Timestamp of the request |
Request Body
Name | Type | Description |
---|---|---|
planId* | String | ID of a subscription plan |
customerId* | String | Customer correlation ID |
payer* | String | Blockchain address of a payer |
startFrom* | String | Date/time when invoice expires (in ISO 8601 format) |
metadata* | String | Additional data to be passed with webhooks |
maxPeriods | Integer | A limit for the maximum allowed charges, default is 24 periods. |
Returns subscriptions by filter
GET
<api>/integration/subscriptions
Use this method to get a collection of subscriptions based on a filter.
Query Parameters
Name | Type | Description |
---|---|---|
customerId | String | External customer Id |
payer | String | Address of the payer |
statusIn | String | Comma-separated statuses |
limit | Integer | Result limit |
offset | Integer | Result offset |
Headers
Name | Type | Description |
---|---|---|
x-api-key* | String | API Key |
x-api-sig* | String | Signature created using API Secret |
x-api-ts* | String | Timestamp of the request |
Create access token for external widget
POST
<api>/integration/subscriptions/create-customer-token
Headers
Name | Type | Description |
---|---|---|
x-api-key* | String | API Key |
x-api-sig* | String | Signature created using API Secret |
x-api-ts* | String | Timestamp of the request |
Request Body
Name | Type | Description |
---|---|---|
customerId* | String | Customer correlation ID |
Last updated