In Merchant API, accounts can have a sub-account relationship to another account. You can use the Merchant Accounts API to create new sub-accounts under your advanced account. You must have an existing advanced account to make this call. You can't use the Merchant API to move existing standalone merchant accounts under your account.
Third-party providers can use the Merchant Accounts API to develop an interface that lets merchants create and manage their account details.
Create a sub-account
To create a new sub-account under your advanced account, call
accounts.createAndConfigure
:
- Provide the details of the sub-account in the
account
field. - Specify any new authorized users in the
users
field. User access is also inherited from the parent account. Specify
accountAggregation
in theservice
field.Here's an example to create a sub-account under account
account/123
, which is an aggregator for the sub-account: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" } ] }
The following sample demonstrates how you can use the
CreateAndConfigureAccountRequest
package to
create a new sub-account.
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);
}
}
Accept the Terms of Service
Sub-accounts inherit the Merchant Center Terms of Service (TOS) that the parent account signed.
Update your business information
You can use the Merchant Accounts API to edit your business information.
- To view your business information, call
accounts.getBusinessInfo
. - To edit your business information, call
accounts.updateBusinessInfo
.