Calculate plan cycles
- Only applicable for activate_type = immediate and process_credit = true
Calculate plan cycles
PUT /svc/payment/api/v1/openapi/recurring_payments/plan/:id/cycles/calculate
- Only applicable for activate_type = immediate and process_credit = true
- The next_billing_amount of the first recurring_cycles is the total amount of the order to be generated, with discount and proration deduction alrerady included.
Request
Path Parameters
id stringrequired
- application/json
Body
activate_type stringrequired
Immediate: The cycle to be added will start immediately and all previously-active recurring_cycles.state from the recurring plan will be updated to cancelled.
Next Billing Date: The cycle to be added will start on the next billing date of the current recurring cycle. The recurring_cycles.state will be updated to completed, and all the succession recurring_cycles.state of it will be updated to cancelled.
As Last Cycle: The cycle to be added will start once the current last recurring_cycles.state of recurring plan is changed to completed. If that recurring_cycles.billing_count and hence recurring_cycles.estimated_end_date are empty, the new cycle would not be added. If activate_type is not provided, the cycle would automatically be added as this value.
Possible values: [immediate, next_billing_date, as_last_cycle]
process_credit boolean
Only applicable for activate_type = immediate. By default, we will process the current recurring billing's remaining credit and add to/ subtract from recurring_plan.credit
cycles object[]required
Array [
billing_count numberrequired
This is to count how long will the recurring cycle run for. If data is null, then consider this recurring_cycles record will run forerver.
recurring_billing_config stringrequired
\
- This is for the system to know the billing date of a cycle, once the cycle has started\
- If the user changes the recurring plan of a customer (upgrade/downgrade etc.), then the
recurring_items object[]required
Array [
quantity numberrequired
recurring_item_id stringrequired
]
discount_amount number
\ - if trial_period is TRUE, it means the total amount of billing amount for this recurring_cycles record will be 0.00
discount_type string
description string
\ - Any description to remark about this record
]
Responses
- 200
Response Headers
-
application/json
-
Schema
-
Example (auto)
Schema
code integerrequired
message stringrequired
data objectrequired
plan objectrequired
id stringrequired
name string
reference_number string
default_payment_token string
default_collection_method string
payment_retry_count number
payment_retry_day_period number
grace_period numbernullable
credit number
redirect_url string
note string
timeout object
timer integerrequired
url string
description stringnullable
created_at stringrequired
updated_at stringrequired
deleted_at stringnullable
recurring_cycles object[]required
Array [
id string
state stringrequired
recurring_plan_id stringrequired
billing_count integer
billing_count_created integerrequired
recurring_billing_config objectrequired
id stringrequired
billing_interval stringrequired
billing_type string
billing_month integer
billing_day_of_month integer
billing_proration_enabled booleanrequired
description string
created_at string
updated_at string
deleted_at stringnullable
recurring_items object[]required
Array [
id stringrequired
label string
price numberrequired
quantity integerrequired
currency stringrequired
reference_id string
description string
created_at stringrequired
updated_at string
deleted_at stringnullable
]
billing_amount number
discount_amount number
discount_type string
previous_cycle stringnullable
next_cycle stringnullable
estimated_start_date string
start_date stringnullable
estimated_end_date stringnullable
end_date stringnullable
next_execute_time stringnullable
description stringnullable
created_at stringrequired
updated_at stringrequired
deleted_at stringnullable
]
customer object
name string
email string
phone string
reference_number stringrequired
default_payment_method string
uuid stringrequired
current_order object
amount number
paid_total number
currency string
order_number string
reference_number string
state string
correspondence_state string
auth_code string
default_payment_token string
default_collection_method string
note string
redirect_url string
timeout object
timer string
url string
current_payment_link string
{
"code": 0,
"message": "string",
"data": {
"plan": {
"id": "string",
"name": "string",
"reference_number": "string",
"default_payment_token": "string",
"default_collection_method": "string",
"payment_retry_count": 0,
"payment_retry_day_period": 0,
"grace_period": 0,
"credit": 0,
"redirect_url": "string",
"note": "string",
"timeout": {
"timer": 0,
"url": "string"
},
"description": "string",
"created_at": "string",
"updated_at": "string",
"deleted_at": "string",
"recurring_cycles": [\
{\
"id": "string",\
"state": "string",\
"recurring_plan_id": "string",\
"billing_count": 0,\
"billing_count_created": 0,\
"recurring_billing_config": {\
"id": "string",\
"billing_interval": "string",\
"billing_type": "string",\
"billing_month": 0,\
"billing_day_of_month": 0,\
"billing_proration_enabled": true,\
"description": "string",\
"created_at": "string",\
"updated_at": "string",\
"deleted_at": "string"\
},\
"recurring_items": [\
{\
"id": "string",\
"label": "string",\
"price": 0,\
"quantity": 0,\
"currency": "string",\
"reference_id": "string",\
"description": "string",\
"created_at": "string",\
"updated_at": "string",\
"deleted_at": "string"\
}\
],\
"billing_amount": 0,\
"discount_amount": 0,\
"discount_type": "string",\
"previous_cycle": "string",\
"next_cycle": "string",\
"estimated_start_date": "string",\
"start_date": "string",\
"estimated_end_date": "string",\
"end_date": "string",\
"next_execute_time": "string",\
"description": "string",\
"created_at": "string",\
"updated_at": "string",\
"deleted_at ": "string"\
}\
],
"customer": {
"name": "string",
"email": "string",
"phone": "string",
"reference_number": "string",
"default_payment_method": "string",
"uuid": "string"
},
"current_order": {
"amount": 0,
"paid_total": 0,
"currency": "string",
"order_number": "string",
"reference_number": "string",
"state": "string",
"correspondence_state": "string",
"auth_code": "string",
"default_payment_token": "string",
"default_collection_method": "string",
"note": "string",
"redirect_url": "string",
"timeout": {
"timer": "string",
"url": "string"
}
},
"current_payment_link": "string"
}
}
}-
csharp
-
curl
-
dart
-
go
-
http
-
java
-
javascript
-
kotlin
-
c
-
nodejs
-
objective-c
-
ocaml
-
php
-
powershell
-
python
-
r
-
ruby
-
rust
-
shell
-
swift
-
HTTPCLIENT
-
RESTSHARP
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://developer.wonder.today/svc/payment/api/v1/openapi/recurring_payments/plan/:id/cycles/calculate");
request.Headers.Add("Accept", "application/json");
var content = new StringContent("{\n \"activate_type\": \"immediate\",\n \"process_credit\": true,\n \"cycles\": [\n {\n \"billing_count\": 0,\n \"recurring_billing_config\": \"string\",\n \"recurring_items\": [\n {\n \"quantity\": 0,\n \"recurring_item_id\": \"string\"\n }\n ],\n \"discount_amount\": 0,\n \"discount_type\": \"string\",\n \"description\": \"string\"\n }\n ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());Request Collapse all
Parameters
id — pathrequired
Body
{
"activate_type": "immediate",
"process_credit": true,
"cycles": [\
{\
"billing_count": 0,\
"recurring_billing_config": "string",\
"recurring_items": [\
{\
"quantity": 0,\
"recurring_item_id": "string"\
}\
],\
"discount_amount": 0,\
"discount_type": "string",\
"description": "string"\
}\
]
}