共用方式為


查看購物車中的客戶訂單

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

如何在購物車中為客戶結帳訂單。

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

注意

購物車將在首次建立後7天到期。

先決條件

  • 認證資訊如 合作夥伴中心驗證所述。 此案例支援使用獨立應用程式和 App+使用者認證進行驗證。

  • 客戶標識碼 (customer-tenant-id)。 如果您不知道客戶的ID,可以在 合作夥伴中心 中,選擇 客戶 工作區,然後從客戶清單中選擇客戶,最後進入 帳戶。 在客戶的帳戶頁面上,在 [客戶帳戶資訊] 區段中尋找 Microsoft ID。 Microsoft識別碼與客戶標識碼 (customer-tenant-id) 相同。

  • 現有購物車的購物車標識碼。

C#

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

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

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

爪哇島

合作夥伴中心 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 參數

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

名字 類型 必填 描述
客戶標識碼 字串 是的 識別客戶的 GUID 格式客戶識別碼。
購物車編號 字串 是的 用於識別購物車的 GUID 格式化購物車 ID。

請求標頭

如需詳細資訊,請參閱 合作夥伴中心 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: 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

重要

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

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

REST 回應

如果成功,回應內容將包含填滿的 CartCheckoutResult 資源。

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

回應成功和錯誤碼

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

軟體、多筆預約、Azure 計劃及第三方產品 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": {...},
      ...
    }
  ],
  ...
}

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

  {
    "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"
    }
}