创建和管理子账号

在 Merchant API 中,账号可以与其他账号建立子账号关系。您可以使用 Merchant Accounts API 在高级账号下创建新的子账号。您必须拥有现有的高级账号才能进行此调用。您无法使用 Merchant API 将现有的独立商家账号迁移到您的账号下。

第三方提供商可以使用 Merchant Accounts API 开发一个接口,让商家能够创建和管理其账号详细信息。

创建子账号

如需在高级账号下创建新的子账号,请调用 accounts.createAndConfigure

  1. account 字段中提供子账号的详细信息。
  2. users 字段中指定任何新的获授权用户。用户访问权限也会从父级账号继承。
  3. service 字段中指定 accountAggregation

    以下示例说明了如何在账号 account/123(该账号是子账号的汇总账号)下创建子账号:

    POST https://merchantapi.googleapis.com/accounts/v1beta/accounts:createAndConfigure
    
    {
      "account": {
        "accountName": "merchantStore",
        "adultContent": false,
        "testAccount": false,
        "timeZone": {
          "id": "America/New_York",
        }
        "languageCode": "en-US",
      },
      "service": [
        {
          "accountAggregation": {},
          "provider": "providers/123"
        }
      ]
    }
    

以下示例演示了如何使用 CreateAndConfigureAccountRequest 软件包创建新的子账号。

Java

  public static void createSubAccount(Config config) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    AccountsServiceSettings accountsServiceSettings =
        AccountsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates parent/provider to identify the MCA account into which to insert the subaccount.
    String parent = getParent(config.getAccountId().toString());

    // Calls the API and catches and prints any network failures/errors.
    try (AccountsServiceClient accountsServiceClient =
        AccountsServiceClient.create(accountsServiceSettings)) {

      CreateAndConfigureAccountRequest request =
          CreateAndConfigureAccountRequest.newBuilder()
              .setAccount(
                  Account.newBuilder()
                      .setAccountName("Demo Business")
                      .setAdultContent(false)
                      .setTimeZone(TimeZone.newBuilder().setId("America/New_York").build())
                      .setLanguageCode("en-US")
                      .build())
              .addService(
                  AddAccountService.newBuilder()
                      .setProvider(parent)
                      .setAccountAggregation(AccountAggregation.getDefaultInstance())
                      .build())
              .build();

      System.out.println("Sending Create SubAccount request");
      Account response = accountsServiceClient.createAndConfigureAccount(request);
      System.out.println("Inserted Account Name below");
      // Format: `accounts/{account}
      System.out.println(response.getName());
    } catch (Exception e) {
      System.out.println(e);
    }
  }

接受服务条款

子账号会继承父级账号签署的 Merchant Center 服务条款 (TOS)

更新您的商家信息

您可以使用 Merchant Accounts API 修改商家信息