Skip to main content

Update plan

Endpoint for updating a Plan.

info

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

PUT /api/v1/groups/{group_id}/revere_pay/{linked_account_id}/recurring/plans/{plan_id}

Request Parameters

NameDescriptionTypeRequired
amountThe amount of the plan.uint64Required
initial_amountThe 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_cycleBilling cycle of the plan. 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.string
descriptionDescription of the Plan. Will be seen by end-users, make sure it is recognizable.stringRequired
durationNumber of cycles the plan will run for. 6 means that the plan will run for 6 cycles. Use 0 for endless plans.stringRequired
nameName of the Plan. Will be seen by end-users, make sure it is recognizable.stringRequired
taxThe amount of tax included in the Plan.uint64
shipping_amountThe amount of shipping included in the Plan.uint64
trial_period_daysNumber of days of the trial period.uint64
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: 5uint64
update_subscriptionsUse it if you wish to update the values of your existing subscriptions with the given plan.booleanRequired
prorateIf true, the update will take effect immediately and charges the accurately prorated amount for the current partial billing cycle.booleanRequired

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: 'PUT',
headers: headers,
redirect: 'follow',
body: {
// request body data
}
};
const group_id = '';
const linked_account_id = '';
const plan_id = '';
const url = `https://api.reverepayments.dev/api/v1/groups/${group_id}/revere_pay/${linked_account_id}/recurring/plans/${plan_id}`;
fetch(url, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log('error', error));

Example Request

{
"name": "Monthly Plan",
"amount": 20000,
"initial_amount": 10000,
"billing_factor": 1,
"billing_cycle": "monthly",
"duration": 12,
"description": "Support our cause",
"trial_period_days": 0,
"update_subscriptions": true,
"tax": 1000,
"shipping_amount": 2000,
"prorate": true
}

Example Success Response

{
"id": "0204ea34-6c93-4990-9a9b-dfb372006ad6",
"name": "Monthly $2",
"duration": 12,
"amount": 20000,
"initial_amount": 10000,
"billing_cycle": "monthly",
"billing_factor": 1,
"linked_account_id": "<linked_account_id>",
"description": "Support our cause",
"tax": 1000,
"shipping_amount": 2000,
"custom_fields": null,
"created_at": "2024-04-11T15:11:16.975339Z",
"updated_at": "2024-04-11T15:11:16.975339Z",
"trial_period_days": 0,
"max_retry_count": 0
}