Calculate Subscription Price
Calculate the final price before subscribing to a specific plan or service.
Request URL
POST {base_url}/pricing/openapi/purchase/v1/pricing/calculate
Request parameters
- Headers
-
Parameter Required Description Content-Type Yes Specify the type of data that is sent in the body of the POST request. Valid value:
application/json.User-Agent Yes Provide information about the user agent, such as the type of web browser, operating system, software version, etc., so as to help Yeastar Partner Portal to identify the user or the application that is making the request. Example:
User-Agent: OpenAPI.Authorization Yes Pass the access token in the header, so as to authenticate the API request. Format: Bearer {access_token}.
- Body parameters
-
Parameter Required Type Description productId Yes Integer The unique ID of the product. Note: You can query product ID using the Query Available Subscription Products interface.productNo No String The Serial Number (SN) of the product for which you want to query subscription price. Note: You can query this information using the Query Product List interface or obtain it from PBX web portal.operationType Yes String Operation type. Valid value:
trial_plantrial_servicepurchase_planpurchase_serviceswitch_planswitchTrial_planrenew_planrenew_service
serviceList Yes Array<Service_Info> The detailed information about the desired plan or service. partnerView No String The Yeastar ID of your subordinate customer for whom you want to calculate subscription price. - Service_Info
-
Parameter Required Type Description serviceType Yes String Service type. Valid value:
planservice
pricingId Yes Integer The unique pricing ID of the plan or service. Note: To obtain the pricing ID, you need to first obtain product ID using the Query Available Subscription Products interface, then query pricing ID using the Query Available Subscription / Trial Plans and Services for a Product interface.billingCycle No String Billing cycle. Valid value:once: One-off plan/service.annuallyormonthly: Recurring plan/service.
billingModel No String Billing model. Valid value:oncerecurring
purchaseType Yes String Purchase type. Valid value:
trialpurchaseswitchswitchTrialrenew
quantity No Integer The quantity of the item to which you want to subscribe. multiCycle No Integer Interval of recurring billing. Valid value:0: One-off plan/service.1,2,3,4,5: Recurring plan/service.
connectionPlanId No Integer The unique ID of the plan on which a specific service is dependent. Note:- To obtain the connection plan ID, you need to first obtain the product ID using the Query Available Subscription Products interface, then query the connection plan ID using the Query Available Subscription / Trial Plans and Services for a Product interface.
- For service that is dependent on plan, this parameter is required.
Response parameters
| Parameter | Type | Description |
|---|---|---|
| code | String | The response message of the API request. |
| detailMessage | String | The detailed error information. When the request is successful, this parameter returns empty. |
| requestId | String | The unique ID of the request, which can be used to quickly locate the request. |
| result | Object<Price_Info> | Detailed information about the subscription price. |
| status | Integer | The HTTP status code of the API request. |
Price_Info
| Parameter | Type | Description |
|---|---|---|
| totalPrice | Number | The amount to be paid. |
| originalPriceList | Array<Original_Price> | Detailed information about the original price. |
| upgradeServicePriceList | Array<Upgrade_Price> | Detailed information about upgrading the plan or service. |
| currency | String | Currency for payment.
|
- Original_Price
-
Parameter Type Description serviceType String Service type. planservice
serviceName String The name of the plan or service. servicePurchaseQuantity Integer The quantity of the item that you want to calculate price. servicePrice String Price for the plan or service. connectionPlanName String The plan that is associated with the service.
- Upgrade_Price
-
Parameter Type Description price Number The total price for the upgrade. pricingId Integer The unique pricing ID of the plan or service. serviceType String Service type. planservice
expireTime String Expiration date of the plan or service. servicePeriod Integer Validity period of the plan or service. Note: This parameter is returned only for P-Series Software Edition.quantity Integer The quantity of the item in the service to which you want to subscribe.
Example
Query the price for purchasing P-Series Software Edition with Enterprise Plan.
Request example
POST /pricing/openapi/purchase/v1/pricing/calculate HTTP/1.1
Host: openapi.partner.yeastar.com
Content-Type: application/json
User-Agent: OpenAPI
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsicmVzMSJdLCJYLU1TLVVTRVIiOiJ7XCJleHByXCI6XCIwXCIsXCJ0eXBlXCI6XCJwYXJ0bmVyXCIsXCJ1Y0lkXCI6XCIzMDc2OTEzNjQ0ODkwODMyODk2XCIsXCJ1c2VyQ29kZVwiOlwiRGlzdHJpYnV0b3JcIixcInVzZXJJZFwiOlwiMzA3NjkxMzY0NDkxNTk5ODcyMFwiLFwidXNlcm5hbWVcIjpcImRpc3RyaWJ1dG9yZXhhbXBsZUBvdXRsb29rLmNvbVwifSIsInVzZXJfbmFtZSI6ImRpc3RyaWJ1dG9yZXhhbXBsZUBvdXRsb29rLmNvbSIsInNjb3BlIjpbImFsbCJdLCJleHAiOjE3MzkyNTgwMTUsInRva2VuX3R5cGUiOiJvcGVuYXBpIiwiYXV0aG9yaXRpZXMiOlsiNzciXSwianRpIjoibDkzTXhVMWlWYm1MeEhuOWkrdzRVaitqZ0JZPSIsImNsaWVudF9pZCI6ImFjMGYyZTViZWU3NmI2ZDdmNDU0NTY5NmMyNGZjMWYzIn0.4jMWQBsRMZp2Q0Lxo_NTOsM2V89r4FphvKlDe667oCA
{
"productId": 12,
"productNo": "3651E3999037",
"operationType": "purchase_plan",
"serviceList": [
{
"serviceType": "plan",
"pricingId": 15438,
"billingCycle": "annually",
"billingModel": "recurring",
"purchaseType": "purchase",
"quantity": 10,
"multiCycle": 0,
"connectionPlanId": 0
}
]
}
Response example
{
"code": "success",
"detailMessage": "",
"requestId": "1f7b350c7ef2e9cf7ffc4adc18c6ba56",
"result": {
"currency": "USD",
"originalPriceList": [
{
"connectionPlanName": "",
"serviceName": "Enterprise Plan",
"servicePrice": "$40.00/year",
"servicePurchaseQuantity": 10,
"serviceType": "plan"
}
],
"totalPrice": 40.00,
"upgradeServicePriceList": [
{
"expireTime": 1763110509109,
"price": 40.00,
"pricingId": 15438,
"quantity": 10,
"servicePeriod": 30,
"serviceType": "plan"
}
]
},
"status": 200
}