查看購物車中的客戶訂單

適用於:合作夥伴中心 |由 21Vianet 營運的合作夥伴中心 |美國政府適用的 Microsoft Cloud 合作夥伴中心

如何在購物車中查看客戶的訂單。

此 API 是等冪的。 合作夥伴可以針對一個購物車標識碼多次呼叫 CheckoutCart API。 在訂單因錯誤而失敗的案例中,可以再次呼叫來重新嘗試簽出。 如果先前已成功取出購物車,且隨後對同一購物車進行結賬呼叫,API 回應將會重申初始結帳後傳回的資訊。

注意

購物車從初始建立起 7 天到期。

必要條件

C#

若要取出客戶的訂單,請使用購物車和客戶標識碼取得購物車的參考。 最後,呼叫 Create 或 CreateAsync 函式來完成順序。

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

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

Java

合作夥伴中心 Java SDK 可用來管理合作夥伴中心資源。 它是由合作夥伴社群維護的開放原始碼專案,且 Microsoft 未正式支援。 如果您遇到問題,可以從社群取得協助在 GitHub 上提出問題

若要取出客戶的訂單,請使用購物車和客戶標識碼取得購物車的參考。 最後,呼叫 create 函式以完成順序。

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

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

PowerShell

合作夥伴中心 PowerShell 模組可用來管理合作夥伴中心資源。 它是由合作夥伴社群維護的開放原始碼專案,且 Microsoft 未正式支援。 如果您遇到問題,可以從社群取得協助在 GitHub 上提出問題

若要取出客戶的訂單,請執行 Submit-PartnerCustomerCart 來完成訂單。

# $customerId
# $cartId

Submit-PartnerCustomerCart -CartId $cartId -CustomerId $customerId

REST 要求

要求語法

方法 要求 URI
POST {baseURL}/v1/customers/{customer-id}/carts/{cart-id}/checkout HTTP/1.1

URI 參數

使用下列路徑參數來識別客戶,並指定要取出的購物車。

名稱 類型​​ 必要 描述
customer-id string Yes 識別客戶的 GUID 格式客戶識別碼。
cart-id string Yes 識別購物車的 GUID 格式化購物車標識碼。

要求標頭

如需詳細資訊,請參閱合作夥伴中心 REST 標頭

要求本文

無。

要求範例

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

重要

自 2023 年 6 月起,最新的合作夥伴中心 .NET SDK 3.4.0 版現已封存。 您可以從 GitHub 下載 SDK 版本,以及 包含實用資訊的自述檔

鼓勵合作夥伴繼續使用 合作夥伴中心 REST API

REST 回應

如果成功,回應本文會包含填入的 CartCheckoutResult 資源。

如果購物車包含一或多個訂用帳戶,則只有在 API 呼叫時布建對應的訂用帳戶時,個別的訂用帳戶標識碼才會出現在 REST 回應中。 布建訂閱會以異步方式發生,因此,在購物車結帳呼叫的 REST 回應中,可能不會一律顯示訂用帳戶標識符值。 不過,布建個別訂用帳戶之後,就可以透過取得訂單和依標識碼 API 呼叫取得訂單來存取其訂用帳戶標識碼值。

回應成功和錯誤碼

每個回應都有一個 HTTP 狀態代碼,指出成功或失敗,以及更多偵錯資訊。 使用網路追蹤工具來讀取此程式代碼、錯誤類型和其他參數。 如需完整清單,請參閱錯誤碼

軟體、多個保留、Azure 方案和第三方產品 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": {...},
      ...
    }
  ],
  ...
}

新商務授權型訂用帳戶的回應範例

  {
    "id": "a68736758d9c",
    "alternateId": "a68736758d9c",
    "referenceCustomerId": "94cd6638-11b6-4323-8c9f-6ae3088adc59",
    "billingCycle": "monthly",
    "currencyCode": "USD"
    "currencySymbol": "US$",
    "lineItems": [
        {
            "lineItemNumber": 0,
            "offerId": "CFQ7TTC0LF8S:0001:CFQ7TTC0N81H",
            "subscriptionId": "0c353b8e-da9d-4007-d0d4-bca8bd5b5ce1",
            "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"
    }
}