Skip to main content

Create subscription

Endpoint for creating a Subscription.

info

Please be aware that this endpoint requires a Manage Transactions API Key.

POST /api/v1/groups/{group_id}/revere_pay/{linked_account_id}/recurring/subscription

info

Available countries: US, CA, UK.

info

Dynamic descriptor: This feature requires pre-configuration by our Support Team. Reach out to us to enable this feature for your account.

Request Parameters

NameDescriptionTypeRequired
plan_idPlan ID used for the transaction.stringRequired
amounts.requested_amountThe amount of the subscription.uint64Required
amounts.included_tax_amountThe tax amount included in the requested amount of the subscription. If it's null, then the tax amount of the plan will be used.uint64
amounts.included_shipping_amountThe shipping amount included in the requested amount of the subscription. If it's null, then the shipping amount of the plan will be used.uint64
amounts.initial_amountThe initial amount of the plan. This amount is only used for the first transaction of the subscription, and then the amount will be used. If it's null, then the initial amount of the plan will be used.uint64
currencyCurrency of the subscription. Currently supported currencies: USDstringRequired
billing_address.cityCity of the Billing Address.stringRequired
billing_address.companyCompany Name of the Billing Address.string
billing_address.countryCountry of the Billing Address.stringRequired
billing_address.emailEmail address of the Billing Address.stringRequired
billing_address.first_nameFirst Name of the Billing Address used for the Customer charged.stringRequired
billing_address.last_nameLast Name of the Billing Address used for the Customer charged.stringRequired
billing_address.line_1First Address line of the Billing Address.stringRequired
billing_address.line_2Second Address line of the Billing Address.string
billing_address.postal_codePostal Code of the Billing Address.stringRequired
billing_address.subdivisionSubdivision of the Billing Address.stringRequired
billing_cycleBilling cycle of the subscription. It can be annual, monthly or daily.stringRequired
billing_factorBilling factor of the Billing Cycle. It represents how often a given cycle is initiated. For example, 365 for a daily Billing Cycle means that it will run every 365th day.uint64
durationNumber of cycles the plan will run for. 6 means that the plan will run for 6 cycles. Use 0 for endless duration.stringRequired
max_retry_countNumber of times the subscription should be tried to run. After the maximum retries, the subscription status will change to failed. Maximum value: 5stringRequired
descriptionDescription of the Subscription. Will be seen by end-users, make sure it is recognizable.string
payment_details.tokenToken generated for the transaction.stringRequired
payment_details.card_details.dynamic_descriptorAn optional override of the default card statement descriptor for the transaction.string
processor_idProcessor ID used for the transaction.stringRequired
trial_period_daysNumber of days while the plan is active but the first payment is not initiated yet.uint64

Response

CodeDescription
200Success
400Bad Request / Validation error
500Internal Error

Example Usage

plans.js
var headers = new Headers();
headers.append('Authorization', 'API_KEY');

var requestOptions = {
method: 'POST',
headers: headers,
redirect: 'follow',
body: {
// request body data
}
};
const group_id = '';
const linked_account_id = '';
const url = `https://api.reverepayments.dev/api/v1/groups/${group_id}/revere_pay/${linked_account_id}/recurring/subscription`;
fetch(url, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log('error', error));

Example Request

{
"amounts": {
"requested_amount": 30000,
"included_tax_amount": 1000,
"included_shipping_amount": 0,
"initial_amount": 20000
},
"billing_factor": 7,
"billing_cycle": "daily",
"duration": 0,
"processor_id": "<processor_id>",
"currency": "USD",
"plan_id": "6f8df983-62a1-4d36-85fd-2e37114fa694",
"max_retry_count": 3,
"description": "Endless subscription",
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"city": "New York",
"country": "US",
"subdivision": "NY",
"line_2": "1217",
"line_1": "1st Ave.",
"postal_code": "10065",
"email": "johndoe@example.com"
},
"trial_period_days": 0,
"payment_details": {
"token": "<token_id>",
"card_details": {
"dynamic_descriptor": "Lorem ipsum"
}
}
}

Example Success Response

{
"id": "eef1b240-6e4d-42f7-93ea-873d165aa696",
"plan_id": "6f8df983-62a1-4d36-85fd-2e37114fa694",
"duration": 0,
"amounts": {
"amount": 30000,
"tax_amount": 1000,
"initial_amount": 20000
},
"billing_cycle": "daily",
"billing_factor": 7,
"next_bill_date": "2024-04-18T00:00:00Z",
"description": "Endless subscription",
"currency": "USD",
"processor_id": "<processor_id>",
"retry_count": 3,
"metadata": {
"max_retry_count": 3,
"form_layout_id": null,
"form_layout_external_id": null,
"form_entry_id": null,
"charge_count": 1
},
"trial_period_days": 0,
"payment_method": "card",
"payment_details": {
"card": {
"brand": "Visa",
"first_six": "411111",
"last_four": "1111",
"dynamic_descriptor": "Lorem ipsum"
}
},
"billing_address": {
"address": {
"first_name": "John",
"last_name": "Doe",
"city": "New York",
"line_1": "1st Ave.",
"line_2": "1217",
"subdivision": "NY",
"postal_code": "10065",
"country": "US",
"email": "johndoe@example.com"
}
},
"status": "active",
"gateway_customer_id": "<customer_id>"
}