Close charges
The Close charges method initiates closing subscription charges with the Blocked and Opened statuses and returns the request status.
If at the moment of the charge closing via API, there is an order in the Waiting for payment status related to the subscription, then, depending on the order type, the following occurs:
- An order for the subscription resources upgrade stays in the Waiting for payment status. After the order is completed, the charges are processed as in case of manual closing of charges via the Operator Control Panel (see Manual closing of the subscription charges).
- An order for the subscription resources upgrade and downgrade stays in the Waiting for payment status. After the order is completed, the charges for the resources upgrading with the New status are processed as in case of manual closing of charges via the Operator Control Panel. The charges with the Waiting for refund status receive the Refunded status.
- An order for the subscription plan switching stays in the Waiting for payment status. After the order is completed, the following occurs:
- Charges in the New status receive the Refunded status.
- Charges for the unused period are not refunded, because they are already closed.
- When the customer creates an order for the subscription resources upgrade and downgrade after that, all charges, which are related to the switch order and to the resources upgrade and downgrade order, are processed as in case of manual closing of charges via the Operator Control Panel.
An API token of a manager is required for authorization. To get an API token via the Operator Control Panel, see Viewing and updating manager's information.
The manager's API token specified in an API request determines:
- The role and access level of the manager, which determine the availability of a method.
- The current reseller and downstream resellers accessible within a method.
PATCH {base_url}/api/v3/reseller/subscriptions/{subscription_id}/close_charges
Arguments
Name | Parameter type | Data type | Required/ | Description |
---|---|---|---|---|
X-Api-Token | header | string | Required | API token of a manager that performs the operation (see Viewing and updating manager's information) |
Content-Type | header | string | Required | Media type of the request. Specify the following: application/vnd.api+json |
Accept | header | string | Required | Supported media types of the answer. Specify the following: application/vnd.api+json |
base_url | path | string | Required | ActivePlatform URL |
subscription_id | path | integer | Required | ID of a subscription, charges for which should be closed |
Response model
Name | Tupe | Description | |||
---|---|---|---|---|---|
data | object | Response data | |||
id | string | Subscription ID | |||
type | string | Response model type | |||
attributes | object | Subscription information | |||
created_at | string | Date and time of the subscription creation | |||
updated_at | string | Date and time when the subscription was updated | |||
auto_renewal | boolean | Subscription auto-renew status:
| |||
billing_from | string | Subscription paid period start date | |||
expiration_date | string | Subscription expiration date | |||
name | string | Subscription name | |||
renew_point_days | number | Period in days before the subscription expiration, when the manual subscription renewal becomes available via the Customer Control Panel | |||
start_date | string | Subscription activation date | |||
status | string | Subscription status (see Viewing the list of subscriptions for the list of statuses) | |||
payment_model | string | Subscription payment model:
| |||
payment_model_parameters | string | Payment model parameters | |||
credit_limit | number | The value of the subscription debt, above which the postpaid subscription will be stopped. For postpaid subscriptions only (payment_model = postpay ) | |||
current_debt | number | The subscription debt that is calculated as the total amount of all blocked charges for the subscription for the current billing period. For postpaid subscriptions only ( |
Status codes:
- 200 — the request is processed successfully. Subscription charges are closed.
- 401 — unauthorized.
- 404 — the requested subscription was not found.
- 422 — unprocessable entity. Subscription charges are not closed. In case of the 422 error, the log contains detailed information.
Request example
PATCH /api/v3/reseller/subscriptions/3006017/close_charges
Host: test.activeplatform.com
Content-Type: application/vnd.api+json
X-Api-Token: vY5fwetest3gJXZH5uHCw
Accept: application/vnd.api+json
Response example
{
"data": {
"id": "3006017",
"type": "subscriptions",
"attributes": {
"created_at": "2020-07-27T05:01:39.591935+0300",
"updated_at": "2020-07-27T06:11:27.466827+0300",
"auto_renewal": false,
"billing_from": "2020-07-27",
"expiration_date": "2020-08-27",
"name": "auto provisioning with only one period",
"renew_point_days": 0,
"start_date": "2020-07-27",
"status": "active",
"payment_model": "postpay",
"payment_model_parameters": {
"credit_limit": 11000.0,
"current_debt": 0.0
}
}
}
}