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
Name | Description | Type | Required |
---|---|---|---|
plan_id | Plan ID used for the transaction. | string | Required |
amounts.requested_amount | The amount of the subscription. | uint64 | Required |
amounts.included_tax_amount | The 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_amount | The 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_amount | The 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 | |
currency | Currency of the subscription. Currently supported currencies: USD | string | Required |
billing_address.city | City of the Billing Address. | string | Required |
billing_address.company | Company Name of the Billing Address. | string | |
billing_address.country | Country of the Billing Address. | string | Required |
billing_address.email | Email address of the Billing Address. | string | Required |
billing_address.first_name | First Name of the Billing Address used for the Customer charged. | string | Required |
billing_address.last_name | Last Name of the Billing Address used for the Customer charged. | string | Required |
billing_address.line_1 | First Address line of the Billing Address. | string | Required |
billing_address.line_2 | Second Address line of the Billing Address. | string | |
billing_address.postal_code | Postal Code of the Billing Address. | string | Required |
billing_address.subdivision | Subdivision of the Billing Address. | string | Required |
billing_cycle | Billing cycle of the subscription. It can be annual , monthly or daily . | string | Required |
billing_factor | Billing 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 | |
duration | Number of cycles the plan will run for. 6 means that the plan will run for 6 cycles. Use 0 for endless duration. | string | Required |
max_retry_count | Number of times the subscription should be tried to run. After the maximum retries, the subscription status will change to failed. Maximum value: 5 | string | Required |
description | Description of the Subscription. Will be seen by end-users, make sure it is recognizable. | string | |
payment_details.token | Token generated for the transaction. | string | Required |
payment_details.card_details.dynamic_descriptor | An optional override of the default card statement descriptor for the transaction. | string | |
processor_id | Processor ID used for the transaction. | string | Required |
trial_period_days | Number of days while the plan is active but the first payment is not initiated yet. | uint64 |
Response
Code | Description |
---|---|
200 | Success |
400 | Bad Request / Validation error |
500 | Internal Error |
Example Usage
- JavaScript
- Python
- Go
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));
plans.py
import requests
group_id = ""
linked_account_id = ""
url = "https://api.reverepayments.dev/api/v1/groups/" + group_id + "/revere_pay/" + linked_account_id + "/recurring/subscription"
headers = {
'Authorization': 'API_KEY'
}
response = requests.request("POST", url, headers=headers, json={
// request body data
})
print(response.text)
plans.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
const group_id = ""
const linked_account_id = ""
url := "https://api.reverepayments.dev/api/v1/groups/" + group_id + "/revere_pay/" + linked_account_id + "/recurring/subscription"
client := &http.Client{}
body := bytes.NewBuffer(nil)
_ = json.NewEncoder(body).Encode(map[string]any{
// body data
})
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Authorization", "API_KEY")
res, _ := client.Do(req)
defer res.Body.Close()
bytes, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(string(bytes))
}
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>"
}