Check out an order for a customer in a cart

Applies to: Partner Center | Partner Center operated by 21Vianet | Partner Center for Microsoft Cloud for US Government

How to check out an order for a customer in a cart.

This API is idempotent. Partners can call the CheckoutCart API multiple times for one cart id. In a scenario where an order fails due to error, the call can be made again to re-attempt checkout. If a cart was successfully checked out previously and an additional checkout call is made to that same cart, the API response will re-iterate the information returned after initial checkout.

Please note, carts expire 7 days from initial creation.

Prerequisites

  • Credentials as described in Partner Center authentication. This scenario supports authentication with both standalone App and App+User credentials.

  • A customer ID (customer-tenant-id). If you don't know the customer's ID, you can look it up in Partner Center by selecting the Customers workspace, then the customer from the customer list, then Account. On the customer’s Account page, look for the Microsoft ID in the Customer Account Info section. The Microsoft ID is the same as the customer ID (customer-tenant-id).

  • A Cart ID for an existing cart.

C#

To check out an order for a customer, get a reference to the cart using the cart and customer identifier. Finally, call the Create or CreateAsync functions to complete the order.

// IAggregatePartner partnerOperations;
// string customerId;
// string cartId;

var cart = partnerOperations.Customers.ById(customerId).Cart.ById(cartId).Checkout();

Java

The Partner Center Java SDK can be used to manage Partner Center resources. It's an open-source project maintained by the partner community and not officially supported by Microsoft. You can get help from the community or open an issue on GitHub if you experience a problem.

To check out an order for a customer, get a reference to the cart using the cart and customer identifier. Finally, call the create function to complete the order.

// IAggregatePartner partnerOperations;
// String customerId;
// String cartId;

Cart cart = partnerOperations.getCustomers().byId(customerId).getCart().byId(cartId).checkout();

PowerShell

The Partner Center PowerShell module can be used to manage Partner Center resources. It's an open-source project maintained by the partner community and not officially supported by Microsoft. You can get help from the community or open an issue on GitHub if you experience a problem.

To check out an order for a customer, execute the Submit-PartnerCustomerCart to complete the order.

# $customerId
# $cartId

Submit-PartnerCustomerCart -CartId $cartId -CustomerId $customerId

REST request

Request syntax

Method Request URI
POST {baseURL}/v1/customers/{customer-id}/carts/{cart-id}/checkout HTTP/1.1

URI parameters

Use the following path parameters to identify the customer and specify the cart to be checked out.

Name Type Required Description
customer-id string Yes A GUID formatted customer-id that identifies the customer.
cart-id string Yes A GUID formatted cart-id that identifies the cart.

Request headers

For more information, see Partner Center REST headers.

Request body

None.

Request example

POST /v1/customers/d6bf25b7-e0a8-4f2d-a31b-97b55cfc774d/carts/b4c8fdea-cbe4-4d17-9576-13fcacbf9605/checkout HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 4fa6dad6-a89f-4875-8247-8294a10ae1cf
MS-CorrelationId: 0e93c70c-977a-4a88-9580-7cf084c73286
X-Locale: en-US
MS-PartnerCenter-Client: Partner Center .NET SDK
Content-Type: application/json
Host: api.partnercenter.microsoft.com
Content-Length: 0
Expect: 100-continue

No-Content-Body

REST response

If successful, the response body contains the populated CartCheckoutResult resource.

If the cart contains one or more subscriptions, respective subscription ID values will only appear in the REST response if the corresponding subscriptions have been provisioned at the time of the API call. Provisioning subscriptions occurs asynchronously, and therefore, subscription ID values may not always be visible in the REST response of the Cart Checkout call. However, once the respective subscriptions have been provisioned, their subscription ID values can be accessed through Get Orders and Get Order by ID API calls.

Response success and error codes

Each response comes with an HTTP status code that indicates success or failure and more debugging information. Use a network trace tool to read this code, error type, and other parameters. For the full list, see Error Codes.

Response example for software, multiple reservations, Azure plan and third-party product SKU

HTTP/1.1 201 Created
Content-Length: 764
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 0e93c70c-977a-4a88-9580-7cf084c73286
MS-RequestId: 4fa6dad6-a89f-4875-8247-8294a10ae1cf
X-Locale: en-US,en-US
MS-CV: sF/wRa2ih0CzbABc.0
MS-ServerId: 000001
Date: Thu, 15 Mar 2018 17:15:01 GMT
?{
  "orders": [
    {
      "id": "3c6f2530-1e31-4088-8230-dd1c31a18bce",
      "alternateId": "3c6f2530-1e31-4088-8230-dd1c31a18bce",
      "referenceCustomerId": "28045616-f6b9-462f-9701-0d89b5e65c44",
      "billingCycle": "monthly",
      "currencyCode": "USD",
      "lineItems": [
        {
          "lineItemNumber": 0,
          "offerId": "MS-AZR-0145P",
          "subscriptionId": "EF2E1307-86E6-40E3-A794-872403FBD31C",
          "termDuration": "P1Y",
          "transactionType": "New",
          "friendlyName": "Microsoft Azure",
          "quantity": 1,
          "links": {...}
        }
      ],
      "creationDate": "2019-01-16T00:48:44.76+00:00",
      "status": "completed",
      "transactionType": "UserPurchase",
      "links": {...},
      ...
    },
    {
      "id": "311qiN8iFwkv-XARWMvXRYAwYKMACVqv1",
      "alternateId": "0a3624c6e47d",
      "referenceCustomerId": "28045616-f6b9-462f-9701-0d89b5e65c44",
      "billingCycle": "one_time",
      "currencyCode": "USD",
      "currencySymbol": "$",
      "lineItems": [
        {
          "lineItemNumber": 0,
          "offerId": "DZH318Z0BQ36:004G:DZH318Z08C0S",
          "termDuration": "P1Y",
          "transactionType": "New",
          "friendlyName": "Reserved VM Instance, Standard_NV12, US East 2, 1 Year",
          "quantity": 1,
          "links": {...}
        },
        {
          "lineItemNumber": 1,
          "offerId": "DZH318Z0BQ36:004J:DZH318Z08B8X",
          "termDuration": "P3Y",
          "transactionType": "New",
          "friendlyName": "Reserved VM Instance, Standard_NV12, US East 2, 3 Years",
          "quantity": 1,
          "links": {...}
        },
        {
          "lineItemNumber": 2,
          "offerId": "DG7GMGF0DWM3:0002:DG7GMGF0DT1M",
          "transactionType": "New",
          "friendlyName": "BizTalk Server 2016 Branch",
          "quantity": 1,
          "links": {...}
        }
      ],
      "creationDate": "2019-01-16T00:48:51.6578126Z",
      "status": "pending",
      "transactionType": "UserPurchase",
      "links": {...},
      ...
    },
    {
      "id": "HVu_cO8Ea7fNRQP4ia1QTpZap-kg_7P71",
      "alternateId": "55a4e6854d54",
      "referenceCustomerId": "28045616-f6b9-462f-9701-0d89b5e65c44",
      "billingCycle": "monthly",
      "currencyCode": "USD",
      "currencySymbol": "$",
      "lineItems": [
        {
          "lineItemNumber": 0,
          "offerId": "DZH318Z0BXWC:0002:DZH318Z0BMRV",
          "termDuration": "P1M",
          "transactionType": "New",
          "friendlyName": "Barracuda WaaS - Medium Plan",
          "quantity": 1,
          "links": {...}
        }
      ],
      "creationDate": "2019-01-16T00:48:44.4514129Z",
      "status": "pending",
      "transactionType": "UserPurchase",
      "links": {...},
      ...
    }
  ],
  ...
}

Response example for a new commerce license-based subscription with an add-on

{
    "orders": [
        {
            "id": "75985eaa8bc1",
            "alternateId": "75985eaa8bc1",
            "referenceCustomerId": "3a15e1df-b095-41d4-9029-27a5974c2458",
            "billingCycle": "monthly",
            "currencyCode": "USD",
            "currencySymbol": "$",
            "lineItems": [
                {
                    "lineItemNumber": 0,
                    "offerId": "CFQ7TTC0LFLX:0001:CFQ7TTC0LB30", - Base
                    "subscriptionId": "f44c64ac-2ad8-45d3-de21-04be992a8866",
                    "termDuration": "P1M",
                    "promotionId": "39NFJQT1PHSN:0008:39NFJQT1Q5J0",
                    "transactionType": "New",
                    "friendlyName": "Microsoft 365 E3",
                    "quantity": 20,
                    "links": {
                        "product": {
                            "uri": "/products/CFQ7TTC0LFLX?country=US",
                            "method": "GET",
                            "headers": []
                        },
                        "sku": {
                            "uri": "/products/CFQ7TTC0LFLX/skus/0001?country=US",
                            "method": "GET",
                            "headers": []
                        },
                        "availability": {
                            "uri": "/products/CFQ7TTC0LFLX/skus/0001/availabilities/CFQ7TTC0LB30?country=US",
                            "method": "GET",
                            "headers": []
                        }
                    }
                },
                {
                    "lineItemNumber": 1,
                    "offerId": "CFQ7TTC0HDJX:0001:CFQ7TTC0K806",
                    "subscriptionId": "9c410602-8f28-4fda-c815-e3347e0e7252", - Add on
                    "termDuration": "P1M",
                    "transactionType": "New",
                    "friendlyName": "Extra Graph Connector Capacity",
                    "quantity": 20,
                    "links": {
                        "product": {
                            "uri": "/products/CFQ7TTC0HDJX?country=US",
                            "method": "GET",
                            "headers": []
                        },
                        "sku": {
                            "uri": "/products/CFQ7TTC0HDJX/skus/0001?country=US",
                            "method": "GET",
                            "headers": []
                        },
                        "availability": {
                            "uri": "/products/CFQ7TTC0HDJX/skus/0001/availabilities/CFQ7TTC0K806?country=US",
                            "method": "GET",
                            "headers": []
                        }
                    }
                }
            ],
            "creationDate": "2022-02-10T16:05:58.3466833Z",
            "status": "pending",
            "transactionType": "UserPurchase",
            "links": {
                "self": {
                    "uri": "/customers/3a15e1df-b095-41d4-9029-27a5974c2458/orders/75985eaa8bc1",
                    "method": "GET",
                    "headers": []
                },
                "provisioningStatus": {
                    "uri": "/customers/3a15e1df-b095-41d4-9029-27a5974c2458/orders/75985eaa8bc1/provisioningstatus",
                    "method": "GET",
                    "headers": []
                },
                "patchOperation": {
                    "uri": "/customers/3a15e1df-b095-41d4-9029-27a5974c2458/orders/75985eaa8bc1",
                    "method": "PATCH",
                    "headers": []
                }
            },
            "client": {},
            "attributes": {
                "objectType": "Order"
            }
        }
    ],
    "additionalInformation": [],
    "attributes": {
        "objectType": "CartCheckoutResult"
    }
}