Share via


使用合作夥伴中心 API 取消商業市集或新的商務訂用帳戶

適用于:合作夥伴中心

本文說明如何使用合作夥伴中心 API 來取消符合客戶和訂用帳戶識別碼的商業市集或新的商務 用帳戶資源。

注意

授權型服務的新商務體驗包含許多新功能,可供所有雲端解決方案提供者 (CSP) 使用。 如需詳細資訊,請參閱 新的商務體驗概觀

新的商務訂閱可以在 7 天內取消,除非法律要求購買或續約。 此視窗通過之後,就無法再取消訂用帳戶,而且 API 會擲回錯誤。

必要條件

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

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

  • 訂用帳戶識別碼。

合作夥伴中心方法

若要在合作夥伴中心取消商業市集訂用帳戶:

  1. 選取客戶

  2. 選取您想要取消的訂用帳戶。

  3. 選擇 [ 取消訂用帳戶] 選項,然後選取 [ 提交]。

C#

若要取消客戶的訂用帳戶:

  1. 依識別碼取得訂用帳戶。

  2. 變更訂閱的 Status 屬性。 如需 [狀態] 代碼的資訊,請參閱 SubscriptionStatus 列舉

  3. 進行變更之後,請使用您的 IAggregatePartner.Customers 集合並呼叫 ById () 方法。

  4. 呼叫 Subscriptions 屬性,後面接著 ById () 方法。

  5. 呼叫 Patch() 方法。

// IAggregatePartner partnerOperations;
// var selectedCustomerId as string;
// Subscription selectedSubscription;

selectedSubscription.Status = SubscriptionStatus.Deleted;
var updatedSubscription = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ById(selectedSubscription.Id).Patch(selectedSubscription);

範例主控台測試應用程式

範例主控台測試應用程式專案:PartnerSDK.FeatureSample 類別:UpdateSubscription.cs

REST 要求

要求的語法

方法 要求 URI
PATCH {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{subscription-id} HTTP/1.1

URI 參數

下表列出要暫停訂閱的必要查詢參數。

名稱 類型 必要 描述
customer-tenant-id guid Y 對應至客戶的 GUID。
subscription-id guid Y 對應至訂用帳戶的 GUID。

要求標頭

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

要求本文

要求本文中必須有完整的 Subscription 資源。 若要取消您的訂用帳戶,請確定 Status 屬性已更新為 的值 deleted

欄位 類型 必要 描述
status string Y 訂用帳戶的狀態。 選項可以是 - activesuspendeddeleted

要求範例

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/subscriptions/<subscription-id> HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831
MS-CorrelationId: ec8f62e5-1d92-47e9-8d5d-1924af105f2c
If-Match: <etag>
Content-Type: application/json
Content-Length: 1029
Expect: 100-continue
Connection: Keep-Alive

{
    "id": "6e7aa601-629e-461b-8933-0898c3cc3c7c",
    "offerId": "DZH318Z0BXWC:0001:DZH318Z0BMJX",
    "offerName": "offer Name",
    "friendlyName": "friendly Name",
    "quantity": 1,
    "unitType": "License(s)",
    "hasPurchasableAddons": false,
    "creationDate": "2019-01-04T01:00:12.6647304Z",
    "effectiveStartDate": "2019-01-09T00:21:45.9263727+00:00",
    "commitmentEndDate": "2019-02-08T00:21:45.9263727+00:00",
    "status": "deleted",
    "autoRenewEnabled": false,
    "isTrial": false,
    "billingType": "license",
    "billingCycle": "monthly",
    "termDuration": "P1M",
    "refundOptions": [{
        "type": "Full",
        "expiresAt": "2019-01-10T00:21:45.9263727+00:00"
    }],
    "isMicrosoftProduct": false,
    "partnerId": "",
    "contractType": "subscription",
    "publisherName": "publisher Name",
    "orderId": "ImxjLNL4_fOc-2KoyOxGTZcrlIquzls11",
    "attributes": {"objectType": "Subscription"},
}

REST 回應

如果要求成功,這個方法會在回應本文中傳回已刪除的 用帳戶資源屬性。

回應成功和錯誤碼

每個回應都隨附 HTTP 狀態碼,會指出成功與否以及其他的偵錯資訊。 請使用網路追蹤工具來讀取此錯誤碼、錯誤類型和其他參數。 如需完整清單,請參閱錯誤碼

回應範例

HTTP/1.1 200 OK
Content-Length: 1322
Content-Type: application/json; charset=utf-8
MS-RequestId: ca7c39f7-1a80-43bc-90d8-ee7d1cad3831
MS-CorrelationId: ec8f62e5-1d92-47e9-8d5d-1924af105f2c
X-Locale: en-US

{
    "id": "6e7aa601-629e-461b-8933-0898c3cc3c7c",
    "offerId": "DZH318Z0BXWC:0001:DZH318Z0BMJX",
    "offerName": "offer Name",
    "friendlyName": "friendly Name",
    "quantity": 1,
    "unitType": "License(s)",
    "hasPurchasableAddons": false,
    "creationDate": "2019-01-04T01:00:12.6647304Z",
    "effectiveStartDate": "2019-01-09T00:21:45.9263727+00:00",
    "commitmentEndDate": "2019-02-08T00:21:45.9263727+00:00",
    "status": "deleted",
    "autoRenewEnabled": false,
    "isTrial": false,
    "billingType": "license",
    "billingCycle": "monthly",
    "termDuration": "P1M",
    "refundOptions": [
        {
            "type": "Full",
            "expiresAt": "2019-01-10T00:21:45.9263727+00:00"
        }
    ],
    "isMicrosoftProduct": false,
    "partnerId": "",
    "contractType": "subscription",
    "links": {
        "product": {
            "uri": "/products/DZH318Z0BXWC?country=US",
            "method": "GET",
            "headers": []
        },
        "sku": {
            "uri": "/products/DZH318Z0BXWC/skus/0001?country=US",
            "method": "GET",
            "headers": []
        },
        "availability": {
            "uri": "/products/DZH318Z0BXWC/skus/0001/availabilities/DZH318Z0BMJX?country=US",
            "method": "GET",
            "headers": []
        },
        "self": {
            "uri": "/customers/5921f00a-32c0-4457-aaa1-e8018c650895/subscriptions/6e7aa601-629e-461b-8933-0898c3cc3c7c",
            "method": "GET",
            "headers": []
        }
    },
    "publisherName": "publisher Name",
    "orderId": "ImxjLNL4_fOc-2KoyOxGTZcrlIquzls11",
    "attributes": {
        "etag": "",
        "objectType": "Subscription"
    }
}