Create Plan
Endpoint for creating a Plan.
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/plans
Request Parameters
Name | Description | Type | Required |
---|---|---|---|
amount | The amount of the plan. | uint64 | Required |
initial_amount | The initial amount of the plan. This amount is only used for the first transaction of the plan, and then the amount will be used. | uint64 | |
billing_cycle | Billing cycle of the plan. 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 | |
description | Description of the Plan. Will be seen by end-users, make sure it is recognizable. | string | |
duration | Number of cycles the plan will run for. 6 means that the plan will run for 6 cycles. Use 0 for endless plans. | string | Required |
name | Name of the Plan. Will be seen by end-users, make sure it is recognizable. | string | Required |
tax | The amount of tax included in the Plan. | uint64 | |
shipping_amount | The amount of shipping included in the Plan. | uint64 | |
trial_period_days | Number of days of the trial period. | uint64 | |
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 | 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/plans`;
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/plans"
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/plans"
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
{
"name": "Monthly Plan",
"amount": 10000,
"initial_amount": 5000,
"billing_factor": 1,
"billing_cycle": "monthly",
"duration": 12,
"description": "Cover support for a year",
"tax": 1000,
"shipping_amount": 2000,
"trial_period_days": 0
}
Example Success Response
{
"id": "0204ea34-6c93-4990-9a9b-dfb372006ad6",
"name": "Monthly Plan",
"duration": 12,
"amount": 10000,
"initial_amount": 5000,
"billing_cycle": "monthly",
"billing_factor": 1,
"linked_account_id": "<linked_account_id>",
"description": "Cover support for a year",
"tax": 1000,
"shipping_amount": 2000,
"custom_fields": null,
"created_at": "2024-04-11T15:11:16.975339432Z",
"updated_at": "2024-04-11T15:11:16.975339432Z",
"trial_period_days": 0,
"max_retry_count": 0
}