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 reattempt checkout. If a cart was successfully checked out previously and a subsequent checkout call is made to that same cart, the API response will reiterate the information returned after initial checkout.
Note
Carts expire 7 days from the 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: aaaa0000-bb11-2222-33cc-444444dddddd
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
Important
As of June 2023, the latest Partner Center .NET SDK release 3.4.0 is now archived. You can download the SDK release from GitHub, along with a readme file that contains useful information.
Partners are encouraged to continue to use the Partner Center REST APIs.
REST response
If successful, the response body contains the populated CartCheckoutResult resource.
If the cart contains one or more subscriptions, respective subscription ID values only appear in the REST response if the corresponding subscriptions are provisioned at the time of the API call. Provisioning subscriptions occurs asynchronously, and therefore, subscription ID values might not always be visible in the REST response of the Cart Checkout call. However, once the respective subscriptions are 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: aaaa0000-bb11-2222-33cc-444444dddddd
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": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
"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
{
"id": "a68736758d9c",
"alternateId": "a68736758d9c",
"referenceCustomerId": "94cd6638-11b6-4323-8c9f-6ae3088adc59",
"billingCycle": "monthly",
"currencyCode": "USD"
"currencySymbol": "US$",
"lineItems": [
{
"lineItemNumber": 0,
"offerId": "CFQ7TTC0LF8S:0001:CFQ7TTC0N81H",
"subscriptionId": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"termDuration": "P1M",
"transactionType": "New",
"friendlyName": "Office 365 E5 without Audio Conferencing",
"quantity": 1,
"pricing": {
"listPrice": 36.48,
"discountedPrice": 36.48,
"proratedPrice": 36.48,
"price": 36.48,
"extendedPrice": 36.48
},
"links": {
"product": {
"uri": "/products/CFQ7TTC0LF8S?country=US",
"method": "GET",
"headers": []
},
"sku": {
"uri": "/products/CFQ7TTC0LF8S/skus/0001?country=US",
"method": "GET",
"headers": []
},
"availability": {
"uri": "/products/CFQ7TTC0LF8S/skus/0001/availabilities/CFQ7TTC0N81H?country=US",
"method": "GET",
"headers": []
}
}
}
],
"creationDate": "2023-04-18T22:03:45.4505136Z",
"status": "pending",
"transactionType": "UserPurchase",
"links": {
"self": {
"uri": "/customers/94cd6638-11b6-4323-8c9f-6ae3088adc59/orders/a68736758d9c",
"method": "GET",
"headers": []
},
"provisioningStatus": {
"uri": "/customers/94cd6638-11b6-4323-8c9f-6ae3088adc59/orders/a68736758d9c/provisioningstatus",
"method": "GET",
"headers": []
},
"patchOperation": {
"uri": "/customers/94cd6638-11b6-4323-8c9f-6ae3088adc59/orders/a68736758d9c",
"method": "PATCH",
"headers": []
}
},
"totalPrice": 36.48,
"client": {},
"attributes": {
"objectType": "Order"
}
}