Create sales order

The Create sales order method is used to create a sales order for purchasing a new subscription at the plan prices for an account of the current reseller or any of its downstream resellers. The standard logic of the platform is used (see ordering subscriptions).

Ordering an SSL certificate or a domain subscription is available in the API v1 method Create an order only (see Create an Order).

Ordering a subscription at the individual prices or the individual markup is available in the Operator Control Panel only (see ordering subscriptions).

Ordering a subscription with additional attributes (like Microsoft or Google services) requires several steps to be completed sequentially:

  1. Get the list of additional attributes for services of a plan — see Get list of order attributes of plan. For some services, attributes can have only certain available values. In this case, with the list of additional attributes, the list of their available values will be provided.
  2. Specify the values of the additional attributes and send them to validation on the service side — see Validate order attributes of plan. For performing validation, an asynchronous task is created. Completing the task may take some time.
  3. Wait for the completion of the task and check the validation results — see Get async task.
  4. After successful validation of the additional attributes, create a sales order with the ID of the completed asynchronous task — see this article.

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 current reseller and downstream resellers accessible within a method.

POST {base_url}/api/v3/resellers/{reseller_id}/sales_order

Arguments

Name

Parameter Type

Data type

Required/Optional

Description

X-Api-TokenheaderstringRequiredAPI token of a manager that performs the operation (see Viewing and updating Manager's information)
Content-TypeheaderstringRequiredMedia type of the request. Specify the following: application/vnd.api+json
AcceptheaderstringRequired

Supported media types of the answer. Specify the following: application/vnd.api+json

base_urlpathstringRequiredActivePlatform URL
reseller_idpathintegerRequiredID of the current reseller or any of its downstream resellers (see Viewing and updating Reseller general information)
dataformobjectRequiredInformation about the attributes of the operation

attributesformobjectRequiredAttributes of the operation


account_idformintegerRequiredID of the account 


plan_idformintegerRequiredID of the plan


plan_period_idformintegerRequiredID of the period of the plan


payment_modelformstringRequired

Payment model for the subscription:

  • prepay 
  • postpay


subscription_credit_limit_use_systemformboolOptional

Shows whether the ordered subscription will use the default subscription credit limit value:

  • true — the subscription will use the subscription credit limit value that is set in the account class or redefined on the account level.
  • false — subscription will use the subscription credit limit value that is redefined on the subscription level (see subscription_credit_limit).

For postpaid subscriptions only (payment_model = postpay)



subscription_credit_limitformnumberOptional

The value of the subscription credit limit that is redefined on the subscription level (subscription_credit_limit_use_system = false).

For postpaid subscriptions only (payment_model = postpay)



provisioning_dateformstringOptionalThe provisioning date for a delayed order (YYYY-MM-DD). It is possible to specify any date between the current date and the current day + 15 days. See Delayed ordering a Subscription


resourcesformobjectOptionalList of resources in the order. Required if at least one resource has non-zero included or additional amount



dataformarrayOptionalInformation about resources in the order. Required for resources with non-zero included or additional amount




plan_resource_idformintegerOptionalID of the plan resource




additionalformintegerOptionalAdditional amount of the plan resource above included (see Plan Resources)


account_product_managersformobjectOptionalResponsible managers of the account (see Managing Responsible Managers)



dataformarrayOptionalInformation about responsible managers for the account within the product linked to the specified plan




manager_product_role_idformintegerOptionalManager role ID within the product




responsible_product_manager_idformintegerOptionalResponsible manager ID within the product


promo_codeformstringOptionalPromo-code for a discount

task_idformstringOptionalID of an asynchronous task within which validation of additional attributes was performed — required if ordering a subscription requires additional attributes (like Microsoft or Google services)

Response model

  • If no errors are encountered, the method returns data as the information about the created order (see the response model in Get order). Status: 201 Created.
  • For ordering a postpaid subscription when manual approval of a manager is required for an account (see Managing Account's permission to use the Postpay model), if no errors are encountered, the method returns information about the created manual operation.

    Name

    Data type

    Description

    postpay_verificationobjectInformation about account's permission to use the Postpay model


    manual_operation_id

    integer

    Manual operation ID

Errors

StatusError textComment
422Can not order subscription to plan with idThe plan should have the Active status (see Get list of plans)
The period id is not available for orderingThe plan period is not available in the plan
Account with id is not foundTo create an order, specify an existing account of the reseller (see Get list of accounts)
There are ordered invalid amount of resourcesIt is necessary to decrease or increase the ordered amount of the resource to fit the available range specified in the plan
The resource id is not available for ordering in planThe resource is not available in the plan
The order cannot be completed: the order total has exceeded the credit limit for this subscriptionTo create the order, it is necessary to increase the credit limit of the account (see Viewing and updating an Account's details) or individual credit limit of the subscription (see Viewing and updating Subscription's details)
The order cannot be completed: the monthly payment for the subscription has exceeded the credit limitTo create the order, it is necessary to increase the credit limit of the account or individual credit limit of the subscription
The resource id must be orderedIt is necessary to add the required resource in the order because, in the target plan, the resource has the minimal amount greater than 0
You cannot order service plan to this account because service plan is unavailable for such account typeTo create an order, specify an account with different account type (see available_account_types in Get plan)
You cannot order service plan to this account because service plan is trial and this account was blockedFor accounts in the Credit hold status, only paid subscriptions are available for ordering
You cannot order service plan to this account because account is in SFor accounts in this status, ordering new subscriptions is not available
You cannot order service plan to this account because service plan is singleton and this account already has subscription of this service plan in status SAn account can have only one subscription to a singleton plan
You cannot order additional resources for the trial periodTo create a sales order for a trial subscription, for all resources, specify the additional amount equal to 0
Trial period can not be ordered: minimum resource quantity greater included resource quantityOrdering a trial subscription with this configuration of resources is not available
Order for the selected account is not available due to restrictions imposed on the account or resellerThe validation service (see Managing the Validation Service) determined that restrictions are imposed on the reseller or account. Creating an order is not available for the product linked to the specified plan (see Get plan)
Order for the selected service is not available. service for checking the restrictions imposed on the account or reseller is not available. Please try to place order laterThe validation service (see Managing the Validation Service) failed to check the reseller and account. To create an order, try again later or contact the support team
The account or reseller does not have the INN attributeTo create an order, create and specify the INN attribute for the reseller or account (see Managing Attributes) and then try again
The provisioning date can be set as the date from {current date} to {current day + 15 days}The specified provisioning_date is out of the allowed interval
Such role is not configured in product

If it is necessary to attach a responsible manager to an account, specify the following data:

  1. ID of a manager role existing within the product linked to the specified plan (see Managing Roles of Responsible managers).
  2. ID of a user assigned as a responsible manager with the specified manager role to the product linked to the specified plan (see Managing Responsible Managers)
Manager with id is not responsible product manager

Request example

POST /api/v3/resellers/1/sales_order
Host: test.activeplatform.com
Content-Type: application/vnd.api+json
X-Api-Token: vY5fwetestK3gJXZH5uHCw
Accept: application/vnd.api+jsonon
{
    "data": {
        "attributes": {
            "account_id": "710",
            "plan_id": 1598,
            "plan_period_id": 2808,
            "payment_model": "prepay",
            "provisioning_date": "2022-03-01",
            "resources": {
                "data": [
                    {
                        "plan_resource_id": 4340,
                        "additional": 2
                    }
                ]
            },
            "promo_code": ""
        }
    }
}

Response example

{
    "data": {
        "id": "12187",
        "type": "sales_orders",
        "attributes": {
            "created_at": "2020-11-11T09:59:59.644+03:00",
            "updated_at": "2020-11-11T09:59:59.875+03:00",
            "document_id": "SO006650",
            "status": "waiting_for_payment",
            "account_id": 710,
            "type": "SalesOrder",
            "closed_at": null,
            "expiration_date": "2022-03-03",
            "provisioning_date": "2020-11-11",
            "total": "160.0",
            "promo_code": "",
            "payment_id": 9264,
            "manager_id": 225,
            "requester_ip": null,
            "custom_price": false,
            "created_by": "#225 Sales Manager",
            "subscription_id": 3007747,
            "items": [
                {
                    "id": 20865,
                    "target_id": "Subscription",
                    "target_type": "Subscription",
                    "type": "ProvisioningItem::New",
                    "status": "waiting_for_payment",
                    "description": "Clean CSPmonthly",
                    "quantity": 1
                },
                {
                    "id": 20866,
                    "target_id": "SubscriptionResource",
                    "target_type": "SubscriptionResource",
                    "type": "ProvisioningItem::Upgrade",
                    "status": "waiting_for_payment",
                    "description": "HDD",
                    "quantity": 2
                }
            ]
        },
        "relationships": {
            "charges": {
                "data": [
                    {
                        "id": "312660",
                        "type": "charges"
                    }
                ]
            }
        }
    }
}

Отзыв | Feedback