检索和更新订阅

检索订阅后,您可以使用成功响应中的信息更改订阅状态或更新订阅。本页将重点介绍检索和更新订阅的不同方法。

检索订阅

如需检索成功订购或转移的订阅,请使用以下 GETHTTP 请求。

GET https://reseller.googleapis.com/apps/reseller/v1/customers/CUSTOMER_ID/subscriptions/SUBSCRIPTION_ID

替换以下内容:

  • CUSTOMER_ID:客户的主域名或客户的唯一标识符。
  • SUBSCRIPTION_ID:每个客户都有唯一的订阅标识符。您可以使用“检索所有转销商订阅”方法检索此值。

此操作的请求正文中没有任何参数。

成功的响应会返回 HTTP 200 状态代码和订阅的设置。在以下示例响应中,isInTrial 属性为 false,但没有 trialEndTime 属性,这意味着此客户从未享受过此方案的 30 天免费试用。

{
  "kind": "reseller#subscription",
  "customerId": "C0123456",
  "subscriptionId": "123",
  "skuId": "1010020028",
  "billingMethod": "ONLINE",
  "creationTime": "1331647980142",
  "plan": {
    "planName": "ANNUAL",
    "isCommitmentPlan": true,
    "commitmentInterval": {
      "startTime": "1331647980142",
      "endTime": "1363183980142"
    }
  },
  "seats": {
    "kind": "subscriptions#seats",
    "numberOfSeats": 10,
    "licensedNumberOfSeats": 10
  },
  "trialSettings": {
    "isInTrial": false
  },
  "renewalSettings": {
    "kind": "subscriptions#renewalSettings",
    "renewalType": "RENEW_CURRENT_USERS_MONTHLY_PAY"
  },
  "purchaseOrderId": "example.com_annual_1",
  "status": "ACTIVE",
  "resourceUiUrl": "URL to customer's Subscriptions page in the Admin console",
  "skuName": "Google Workspace Business Standard"
}

检索客户的所有订阅

如需检索特定转销商客户已成功订购或转移的所有订阅,请使用以下 GET HTTP 请求并添加授权令牌:

GET https://reseller.googleapis.com/apps/reseller/v1/subscriptions?customerId=CUSTOMER_ID value&pageToken=START_DATE&maxResults=MAX_NUMBER

替换以下内容:

  • CUSTOMER_ID:客户的主域名或客户的唯一标识符。
  • START_DATE:开始日期,格式为 YYYY-MM-DD
  • MAX_NUMBER:响应页面上返回的结果数上限。

此操作的请求正文中没有任何参数。

成功的响应会返回 HTTP 200 状态代码以及客户的订阅和设置列表。订阅列表可能包含在此版本的 Reseller API 中不受管理的产品。

如果您不管理此客户,系统会返回 403 "Forbidden" 错误。

检索客户的所有可转移订阅

如需检索客户的所有订阅(这些订阅可能会转移到转销商的管理下),请使用以下 GET HTTP 请求,并添加授权令牌。customerId 是必需的,是检索转售客户的账号时返回的客户的唯一标识符。customerAuthToken 是客户提供的转移令牌,专门针对您的转销商 ID。客户生成该令牌后,其有效期为 30 天。如需详细了解客户如何生成令牌,请参阅将 Google Workspace 账号转移给转销商

GET https://reseller.googleapis.com/apps/reseller/v1/subscriptions?customerId=CUSTOMER_ID&customerAuthToken=AUTH_TOKEN&pageToken=START_DATE&maxResults=MAX_NUMBER

替换以下内容:

  • CUSTOMER_ID:客户的主域名或客户的唯一标识符。
  • AUTH_TOKEN:客户提供的转移令牌,该令牌专门针对您的转销商 ID。客户生成该令牌后,其有效期为 30 天。如需详细了解客户如何生成令牌,请参阅将 Google Workspace 账号转移给转销商。如果此值无效或已过期,API 响应会返回 403 "Forbidden" 错误。
  • START_DATE:开始日期,格式为 YYYY-MM-DD
  • MAX_NUMBER:响应页面上返回的结果数上限。

此操作的请求正文中没有任何参数。

成功的响应会返回 HTTP 200 状态代码以及客户可转让订阅的列表,其中包含转移令牌的到期日期和转移订单中所需的座位数下限。客户可能拥有无法转移的其他订阅。

{
  "kind": "reseller#subscriptions",
  "subscriptions": [
    {
      "kind": "subscriptions#subscription",
      "customerId": "custId-6543",
      "subscriptionId": "432",
      "skuId": "1010020028",
      "billingMethod": "ONLINE",
      "creationTime": "1331647980142",
      "plan": {
        "planName": "ANNUAL",
        "isCommitmentPlan": true,
        "commitmentInterval": {
          "startTime": "1331647980142",
          "endTime": "1363183980142"
        }
      },
      "seats": {
        "kind": "subscriptions#seats",
        "numberOfSeats": 10,
        "maximumNumberOfSeats": 500,
        "licensedNumberOfSeats": 10
      },
      "trialSettings": {
        "isInTrial": false
      },
      "renewalSettings": {
        "kind": "subscriptions#renewalSettings",
        "renewalType": "SWITCH_TO_PAY_AS_YOU_GO"
      },
      "transferInfo": {
        "transferabilityExpirationTime": "1333183980142",
        "minimumTransferableSeats": "20"
      },
      "purchaseOrderId": "PO_890",
      "status": "ACTIVE",
      "resourceUiUrl": "URL to customer's Subscriptions page in the Admin console",
      "skuName": "Google Workspace Business Standard"
    },
    {
      "kind": "subscriptions#subscription",
      "customerId": "custId-6543",
      "subscriptionId": "140",
      "skuId": "1010020028",
      "creationTime": "1329389322728",
      "plan": {
        "planName": "FLEXIBLE",
        "isCommitmentPlan": false
      },
      "seats": {
        "kind": "subscriptions#seats",
        "maximumNumberOfSeats": 50
        "licensedNumberOfSeats": 10
      },
      "trialSettings": {
        "isInTrial": false,
        "trialEndTime": "1331877480016"
      },
      "renewalSettings": {
        "kind": "subscriptions#renewalSettings",
        "renewalType": "SWITCH_TO_PAY_AS_YOU_GO"
      },
      "transferInfo": {
        "transferabilityExpirationTime": "1333183780159",
        "minimumTransferableSeats": "10"
      },
      "purchaseOrderId": "",
      "status": "ACTIVE",
      "resourceUiUrl": "URL to customer's Subscriptions page in the Admin console",
      "skuName": "Google Workspace Business Standard"
    },
  ],
  "nextPageToken": "token"
}

如果您打算使用批量操作转移这些订阅,请转移所有订阅。逐个转移每个订阅会导致错误。此外,批量操作仅转移状态为 ACTIVE 的订阅。如需了解详情,请参阅转移订阅

检索所有转销商订阅

如需检索转销商成功订购或转移的所有订阅,请使用以下 GET HTTP 请求,并添加授权令牌。

GET https://reseller.googleapis.com/apps/reseller/v1/subscriptions?customerNamePrefix=PREFIX &pageToken=TOKEN&maxResults=MAX_NUMBER

替换以下内容:

  • PREFIX:您要查找订阅的客户名称的开头。
  • TOKEN:标识服务器应返回的特定结果页面的令牌。
  • MAX_NUMBER:响应页面上返回的结果数上限。

此操作可以使用 OAuth 只读访问权限范围。customerNamePrefixpageTokenmaxResults 是可选查询字符串。

以下示例会检索某个转销商名下所有属于名称以“exam”开头的客户的订阅:

GET https://reseller.googleapis.com/apps/reseller/v1/subscriptions?customerNamePrefix=exam

{
  "kind": "reseller#subscriptions",
  "subscriptions": [
    {
      "kind": "subscriptions#subscription",
      "customerId": "C0123456",
      "subscriptionId": "123",
      "skuId": "1010020028",
      "creationTime": "1331647980142",
      "billingMethod": "ONLINE",
      "plan": {
        "planName": "ANNUAL",
        "isCommitmentPlan": true,
        "commitmentInterval": {
          "startTime": "1331647980142",
          "endTime": "1363183980142"
        }
      },
      "seats": {
        "kind": "subscriptions#seats",
        "numberOfSeats": 10,
        "licensedNumberOfSeats": 10
      },
      "trialSettings": {
        "isInTrial": false
      },
      "renewalSettings": {
        "kind": "subscriptions#renewalSettings",
        "renewalType": "SWITCH_TO_PAY_AS_YOU_GO"
      },
      "purchaseOrderId": "PO_135",
      "status": "ACTIVE",
      "resourceUiUrl": "URL to customer's Subscriptions page in the Admin console",
      "skuName": "Google Workspace Business Standard"
    },
    {
      "kind": "subscriptions#subscription",
      "customerId": "custId-5678",
      "subscriptionId": "1404686",
      "skuId": "1010020028",
      "billingMethod": "ONLINE",
      "creationTime": "1329389322728",
      "plan": {
        "planName": "FLEXIBLE",
        "isCommitmentPlan": false
      },
      "seats": {
        "kind": "subscriptions#seats",
        "maximumNumberOfSeats": 50,
        "licensedNumberOfSeats": 10
      },
      "trialSettings": {
        "isInTrial": false,
        "trialEndTime": "1331877480016"
      },
      "renewalSettings": {
        "kind": "subscriptions#renewalSettings",
        "renewalType": "AUTO_RENEW"
      },
      "purchaseOrderId": "",
      "status": "ACTIVE",
      "resourceUiUrl": "URL to customer's Subscriptions page in the Admin console",
      "skuName": "Google Workspace Business Standard"
    },
  ],
  "nextPageToken": "token"
}

更新订阅方案

更新 Google Workspace 方案的方式因方案而异。在更新方案之前,请考虑以下事项:

  • 当您创建订阅且客户符合条件时,订阅的方案可以是 30 天试用方案。弹性方案和包年方案均可免费试用 30 天。在试用期内,您可以根据需要随时将订阅的付款方案更改为弹性方案或包年方案。不过,在试用期结束且方案变为有效方案后,更新方案的规则与其他订阅的有效方案相同。如需立即将试用订阅转换为有效方案,请通过 30 天免费试用订阅开始付费服务。如需详细了解 30 天试用期和客户资格条件规则,请访问管理帮助中心

  • 您可以将弹性方案更新为包年承诺方案。

  • 您无法更新包年方案。

  • 并非所有方案都适用于所有产品。如需详细了解这些方案使用的商品,请参阅商品和 SKU

如需将 30 天试用方案或灵活方案订阅更新为包年方案,请使用以下 POST HTTP 请求:

POST https://reseller.googleapis.com/apps/reseller/v1/customers/CUSTOMER_ID/subscriptions/SUBSCRIPTION_ID/changePlan

替换以下内容:

  • CUSTOMER_ID:客户的主域名或客户的唯一标识符。
  • SUBSCRIPTION_ID:每个客户都有唯一的订阅标识符。您可以使用“检索所有转销商订阅”方法检索此值。

以下示例会使用值为 123 的 subscriptionId 更新订阅。customerId 为 C0123456。

POST https://reseller.googleapis.com/apps/reseller/v1/customers/C0123456/subscriptions/123/changePlan

请求正文如下:

{
  "kind": "reseller#changePlanRequest",
  "planName": "ANNUAL_MONTHLY_PAY",
  "seats": {
    "kind": "subscriptions#seats",
    "numberOfSeats": 10
  },
  "purchaseOrderId": "123_March2012"
}

成功的响应会返回 HTTP 201 状态代码,并返回更新后的订阅方案设置:

{
  "kind": "reseller#subscription",
  "customerId": "C0123456",
  "subscriptionId": "123",
  "skuId": "1010020028",
  "creationTime": "1331647980142",
  "plan": {
    "planName": "ANNUAL",
    "isCommitmentPlan": true,
    "commitmentInterval": {
      "startTime": "1331647980142",
      "endTime": "1363183980142"
    }
  },
  "seats": {
    "kind": "subscriptions#seats",
    "numberOfSeats": 10,
    "licensedNumberOfSeats": 10
  },
  "trialSettings": {
    "isInTrial": false
  },
  "renewalSettings": {
    "kind": "subscriptions#renewalSettings",
    "renewalType": "SWITCH_TO_PAY_AS_YOU_GO"
  },
  "purchaseOrderId": "123_March2012",
  "status": "ACTIVE",
  "skuName": "Google Workspace Business Standard"
}

更新订阅的座位数

更新包年套餐订阅所用的订阅属性与更新 Google Workspace 弹性方案订阅所用的订阅属性不同。

更新包年套餐订阅的座位数

如需更新包年方案订阅的用户许可设置,请使用以下 POST HTTP 请求:

POST https://reseller.googleapis.com/apps/reseller/v1/customers/CUSTOMER_ID/subscriptions/SUBSCRIPTION_ID/changeSeats

替换以下内容:

  • CUSTOMER_ID:客户的主域名或客户的唯一标识符。
  • SUBSCRIPTION_ID:每个客户都有唯一的订阅标识符。您可以使用“检索所有转销商订阅”方法检索此值。

以下示例使用 123 subscriptionId 更新订阅。customerId 为 C0123456。请求正文因方案类型而异:

POST https://reseller.googleapis.com/apps/reseller/v1/customers/C0123456/subscriptions/123/changeSeats

Google Workspace 包年方案的订阅会使用此请求正文来更新用户许可数量。numberOfSeats 值为总和。例如,如果您之前有 10 个用户许可,并且有客户订购了 5 个新许可,则请求正文中 numberOfSeats 的总数为 15,如以下示例所示:

{
    "kind": "subscriptions#seats",
    "numberOfSeats": 15
}

更新弹性方案订阅的座位数

Google Workspace 弹性方案的订阅使用请求正文来更新用户许可。maximumNumberOfSeats 值是现有许可和新许可的总和。这是该账号可以预配的用户许可数量上限。

{
  "kind": "subscriptions#seats",
  "maximumNumberOfSeats": 15
}

成功的响应会返回 HTTP 201 状态代码和更新后的订阅许可设置:

{
  "kind": "reseller#subscription",
  "customerId": "C0123456",
  "subscriptionId": "123",
  "skuId": "1010020028",
  "creationTime": "1331647980142",
  "plan": {
    "planName": "FLEXIBLE",
    "isCommitmentPlan": false
  },
  "seats": {
    "kind": "subscriptions#seats",
    "maximumNumberOfSeats": 15,
    "licensedNumberOfSeats": 10
  },
  "trialSettings": {
    "isInTrial": false
  },
  "skuName": "Google Workspace Business Standard"
}

更新订阅的续订设置

如需更新包年合约订阅的续订设置,请使用以下 POST HTTP 请求:

POST https://reseller.googleapis.com/apps/reseller/v1/customers/CUSTOMER_ID/subscriptions/SUBSCRIPTION_ID/changeRenewalSettings

替换以下内容:

  • CUSTOMER_ID:客户的主域名或客户的唯一标识符。
  • SUBSCRIPTION_ID:每个客户都有唯一的订阅标识符。您可以使用“检索所有转销商订阅”方法检索此值。

以下是请求正文示例:

{
  "kind": "subscriptions#renewalSettings",
  "renewalType": "SWITCH_TO_PAY_AS_YOU_GO"
}

renewalType 属性的值可以是以下任一值:

  • AUTO_RENEW_YEARLY_PAY:在包年承诺方案的间隔期结束时,使用相同的 numberOfSeats 将订阅的方案自动续订为 ANNUAL_YEARLY_PAY
  • AUTO_RENEW_MONTHLY_PAY:在包年方案的间隔期结束时,使用相同的 numberOfSeats 将订阅的方案自动续订为 ANNUAL_MONTHLY_PAY
  • RENEW_CURRENT_USERS_YEARLY_PAY:在包年合约方案的间隔期结束时,将订阅的方案续订为 ANNUAL_YEARLY_PAY,但使用当前活跃用户许可的总数。这是有效包年方案(按年付费)的默认设置。
  • RENEW_CURRENT_USERS_MONTHLY_PAY:在包年合约方案的间隔期结束时,将订阅的方案续订为 ANNUAL_MONTHLY_PAY,但使用当前活跃用户许可的总数。这是有效包年方案(按月付款)的默认设置。
  • RENEW_ON_PROPOSED_OFFER:在当前承诺方案的间隔期结束时,根据最新的续订方案进行续订,其中 numberOfSeats 为当前有效用户许可数量或拟议的优惠承诺数量(以较高者为准)。
  • SWITCH_TO_PAY_AS_YOU_GO:在包年方案的间隔期结束时,将包年方案更改为弹性方案。
  • CANCEL:包年方案间隔期结束后,订阅会被暂停。如需了解如何解除账号中止状态,请参阅管理帮助中心

成功的响应会返回 HTTP 201 状态代码和更新后的订阅续订设置:

{
  "kind": "reseller#subscription",
  "customerId": "C0123456",
  "subscriptionId": "123",
  "skuId": "1010020028",
  "creationTime": "1331647980142",
  "plan": {
    "planName": "ANNUAL",
    "isCommitmentPlan": true,
    "commitmentInterval": {
      "startTime": "1331647980142",
      "endTime": "1363183980142"
    }
  },
  "seats": {
    "kind": "subscriptions#seats",
    "numberOfSeats": 15,
    "licensedNumberOfSeats": 15
  },
  "trialSettings": {
    "isInTrial": false
  },
  "renewalSettings": {
    "kind": "subscriptions#renewalSettings",
    "renewalType": "SWITCH_TO_PAY_AS_YOU_GO"
  },
  "skuName": "Google Workspace Business Standard"
}

从免费试用订阅开始使用付费服务

如果已为 30 天免费试用订阅设置付款方案,如需立即将其转换为付费服务订阅,请使用以下 POST HTTP 请求。

POST https://reseller.googleapis.com/apps/reseller/v1/customers/CUSTOMER_ID/subscriptions/SUBSCRIPTION_ID/startPaidService

替换以下内容:

  • CUSTOMER_ID:客户的主域名或客户的唯一标识符。
  • SUBSCRIPTION_ID:每个客户都有唯一的订阅标识符。您可以使用“检索所有转销商订阅”方法检索此值。

以下示例的 customerId 为 C0123456,subscriptionId 值为 123:

POST https://reseller.googleapis.com/apps/reseller/v1/customers/C0123456/subscriptions/123/startPaidService

此操作的请求正文中没有任何参数。

成功的响应会返回 HTTP 201 状态代码和更新后的订阅设置:

{
  "kind": "reseller#subscription",
  "customerId": "C0123456",
  "subscriptionId": "123",
  "skuId": "1010020028",
  "creationTime": "1331647980142",
  "plan": {
    "planName": "ANNUAL",
    "isCommitmentPlan": true,
    "commitmentInterval": {
      "startTime": "1331647980142",
      "endTime": "1363183980142"
    }
  },
  "seats": {
    "kind": "subscriptions#seats",
    "numberOfSeats": 15,
    "licensedNumberOfSeats": 15
  },
  "trialSettings": {
    "isInTrial": false
  },
  "renewalSettings": {
    "kind": "subscriptions#renewalSettings",
    "renewalType": "SWITCH_TO_PAY_AS_YOU_GO"
  },
  "skuName": "Google Workspace Business Standard"
}

升级或降级订阅

您无法在包年方案的有效期内降级,也无法使用续订设置安排降级。我们建议您将续订设置设为切换到 FLEXIBLE,然后在续订时间过后降级。

如需升级或降级订阅,请使用您要升级或降级到的 skuId 创建新订阅。

POST https://reseller.googleapis.com/apps/reseller/v1/customers/CUSTOMER_ID/subscriptions

替换以下内容:

  • CUSTOMER_ID:客户的主域名或客户的唯一标识符。

此调用会终止之前的订阅并创建新的订阅。

如需详细了解升级和降级,请参阅“商品和 SKU”页面。