Tutorial: Purchase Plan for P-Series Appliance Edition Using API

This tutorial introduces the request parameters and provides a request example to show you how to subscribe to plan for P-Series Appliance Edition using API.

Before you begin: Understand the request parameters

Before subscribing to plan for P-Series Appliance Edition using API, we recommend that you read the table below to understand the request parameters and collect the corresponding values.

Item Parameter Description
Operation Type operationType The operation type.

In this scenario, the value is fixed at purchase_plan.

PBX Serial Number (SN) productNo Specify the device for which you want to subscribe to plan.

You will need to query the PBX SN as described in the following steps.

Product ID productId Specify the product to which you want to subscribe.

The Product ID for P-Series Appliance Edition is 11.

Billing Contact ID billingId Specify the contact who can receive the invoice after you subscribe to plan.

You will need to query the Billing Contact ID as described in the following steps.

Plan ID serviceId Specify the specific plan to which you want to subscribe.

The Plan IDs for P-Series Appliance Edition are shown below:

  • Standard Plan: 3048558946648207360
  • Enterprise Plan: 3048560232537899008
  • Ultimate Plan: 3048560606464323584
Plan Type serviceType The plan type.

The value is fixed at plan.

Purchase Type purchaseType The purchase type.

In this scenario, the value is fixed at purchase.

Billing Model billingModel The billing model of P-Series Plan for Appliance Edition.

The value is fixed at recurring.

Billing Cycle billingCycle The billing cycle of P-Series Plan for Appliance Edition.

The value can be monthly or annually.

Multi Cycle multiCycle The interval of recurring billing.
The valid value depends on the Billing Cycle:
  • If the Billing Cycle is monthly, the value of Multi Cycle can only be 0.
  • If the Billing Cycle is annually, the value of Multi Cycle can be 1, 2, 3, 4, 5.

Step 1. Get Serial Number (SN) from PBX web portal

  1. On PBX web portal, click Information at the top-right corner.
  2. Scroll down to Information section, then copy the Serial Number.

Step 2. Get Billing Contact ID using an API

  1. Make a request to the Query Billing Contact List API endpoint.
    GET {base_url}/user/openapi/user/v1/client/billing_contact_list
  2. Note down the returned value of billingContactId for the desired billing contact.

Step 3. Purchase Plan for P-Series Appliance Edition using an API

Make a request to the Create an Order API endpoint with the collected values.

POST {base_url}/order/openapi/order/v1/save

In this tutorial, the values we collect are shown below:

Item Parameter Value
Operation Type operationType purchase_plan
PBX Serial Number (SN) productNo 3631E0997265
Product ID productId 11
Billing Contact ID billingId 3197218168379846218
Plan ID serviceId 3048560232537899008 (ID for Enterprise Plan)
Plan Type serviceType plan
Purchase Type purchaseType purchase
Billing Model billingModel recurring
Billing Cycle billingCycle monthly
Multi Cycle multiCycle 0

The sample request to purchase 1-month Enterprise Plan for a P-Series Appliance Edition is shown below:

POST /order/openapi/order/v1/save HTTP/1.1
Host: openapi.partner.yeastar.com
Content-Type: application/json
User-Agent: OpenAPI
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsicmVzMSJdLCJYLU1TLVVTRVIiOiJ7XCJleHByXCI6XCIwXCIsXCJ0eXBlXCI6XCJwYXJ0bmVyXCIsXCJ1Y0lkXCI6XCIzMDc2OTE1NDU0NDY4NzY3NzQ0XCIsXCJ1c2VyQ29kZVwiOlwiUGFydG5lclwiLFwidXNlcklkXCI6XCIzMDc2OTE1NDU0NDg5NzM5MjY0XCIsXCJ1c2VybmFtZVwiOlwicGFydG5lcmV4YW1wbGVAb3V0bG9vay5jb21cIn0iLCJ1c2VyX25hbWUiOiJwYXJ0bmVyZXhhbXBsZUBvdXRsb29rLmNvbSIsInNjb3BlIjpbImFsbCJdLCJleHAiOjE3Mzk3MTc5MjYsInRva2VuX3R5cGUiOiJvcGVuYXBpIiwianRpIjoidmlzMkh0QkxaUStNQmxPbS9UdThWR1pyNFljPSIsImF1dGhvcml0aWVzIjpbIjc5Il0sImNsaWVudF9pZCI6IjE0NDI5NjM2ODBiMjM0YjA0YmRjZDVjMTZmODcyOWQ2In0.RPRoTJRkXCB4krDSwGRpUFyCfUVv2LHjIiBICA1pCiY

{
  "operationType": "purchase_plan",
  "productNo": "3631E0997265",
  "productId": 11,
  "billingId": 3197218168379846218,
  "serviceList": [
    {
      "serviceId": 3048560232537899008,
      "serviceType": "plan",
      "purchaseType": "purchase",
      "billingModel": "recurring",
      "billingCycle": "monthly",
      "multiCycle": 0
    }
  ]
}

Result

The sample response is shown below:

{
    "code": "success",
    "detailMessage": "",
    "requestId": "cdf55efc635a9363fda2f97972bed64b",
    "result": {
        "instanceId": "1259567",
        "orderNo": "EU3206205224534151168",
        "orderStatus": "succeed",
        "productNo": "3631E0997265",
        "transactionNo": "QZ3206205228384522241"
    },
    "status": 200
}