建立及管理子帳戶

在 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 編輯商家資訊