Switch a Plan of the Subscription
The method creates a new Order for switching a Plan of the Subscription to the available one. It returns an ID and body of the created Order.
POST /api/vendor/v1/subscriptions/:id/switch.json?api_token={api_token}&plan_id={plan_id}&plan_period_id={plan_period_id}&promo_code={promo_code}
Arguments
Name | Parameter Type | Data type | Required/ Optional | Description |
---|---|---|---|---|
id | path | integer | Required | An ID of the existing subscription. |
api_token | query | string | Required | API token of the manager who perform the operation (see API Token Authentication). |
plan_id | query | integer | Required | An ID of the new Plan of the Subscription. |
plan_period_id | query | integer | Required | A plan period ID of the new Plan. |
promo_code | query | string | Optional | A promo code, which is used to get the discount. |
Response model
Name | Data type | Description |
---|---|---|
id | integer | An order ID. |
document_id | string | Order number. |
status | string | One of the following statuses of the order:
|
account_id | integer | An account ID, which was used to pay for the order. |
type | string | One of the following types of order:
|
created_at | date | A date and time of the order's creation. |
updated_at | date | A date and time when the order was changed last time. |
expiration_date | date | A date, by which the order must be paid (the order status must be confirmed). The date is calculated using the grace period, which is set in the Plan Class (see Creating a service term in the ActivePlatform. Operator Control Panel). |
total | float | A total amount of the order. |
promo_code | string | A promo code, which was used to get the discount (see Managing promo codes in the ActivePlatform. Operator Control Panel). |
payment_id | integer | A payment ID, which is linked to the order. |
items | array | A list of items in the order:
|
charges | array | A list of charges, which were created by the order:
|
Request example
POST http://billing.activeplatform.com:80/api/vendor/v1/subscriptions/2005786/switch.json?api_token=654321&plan_id=2000303&plan_period_id=2000474
Response example
{
"id": 2010334,
"document_id": "CH000350",
"status": "waiting_for_payment",
"account_id": 2000532,
"type": "SwitchPlanOrder",
"created_at": "2016-09-30T13:09:20.137+03:00",
"updated_at": "2016-09-30T13:09:21.039+03:00",
"expiration_date": "2016-09-30",
"total": 0.12,
"promo_code": null,
"payment_id": 2006929,
"items": [
{
"id": 16589,
"target_id": 2005786,
"target_type": "Subscription",
"type": "ProvisioningItem::SwitchPlan",
"status": "waiting_for_payment",
"description": "MSExPlan"
}
],
"charges": [
{
"id": 754179,
"subscription_id": 2005786,
"subscription_resource_id": null,
"subscription_resource_name": null,
"plan_resource_id": null,
"resource_id": null,
"quantity": 1,
"operate_from": "2016-12-01",
"operate_to": "2016-12-30",
"duration": 0.935,
"description": "Switch Plan (recurring fee) #2005786 \"Microsoft Exchange 2013\" to MSExPlan",
"unit_price": 0.03,
"amount": 0.03,
"status": "new",
"type": "Charge::Recurring",
"order_id": 2010334,
"close_date": "2016-12-30",
"created_at": "2016-09-30T13:09:20.844748+0300",
"updated_at": "2016-09-30T13:09:20.844748+0300"
}
]
}