Merchant API를 사용하여 판매자 센터 계정을 만들 수 있으며, 이 계정은 accountAggregation, accountManagement 또는 comparisonShopping를 사용하여 고급 계정에 연결할 수 있습니다. accounts.createAndConfigure 메서드를 사용하면 계정을 만들고 선택적으로 사용자로 구성하고 서비스를 통해 다른 계정에 연결할 수 있습니다.
이 가이드에서는 Merchant API를 사용하여 accountManagement, comparisonShopping, accountAggregation와 같은 서비스를 사용하여 계정을 만드는 방법을 설명합니다. accounts.createAndConfigure를 사용하는 경우 service 필드에 accountAggregation, accountManagement 또는 comparisonShopping 중 하나 이상을 지정하여 새 계정을 제공업체에 연결해야 합니다.
동일한 요청에서 accountAggregation 및 comparisonShopping를 지정할 수 있지만 accountManagement는 accountAggregation 또는 comparisonShopping와 결합할 수 없습니다.
accountManagement을 지정하는 경우 user 또는 users 필드를 사용하여 새 계정에 사용자를 하나 이상 추가해야 합니다.
기본 요건
Merchant API를 사용하여 계정을 만들기 전에 사용하는 서비스에 따라 다음 요구사항을 충족하는지 확인하세요.
- 관리자 액세스:
accountManagement,comparisonShopping또는accountAggregation을 사용하여 새 계정을 연결할 때는 제공업체 계정에 대한 관리자 액세스 권한이 있어야 합니다. - 고급 계정:
accountAggregation를 사용하는 경우 제공업체 계정이 계정 집계용으로 구성된 고급 계정이어야 합니다. 서비스 제공업체이며 고급 계정을 설정해야 하는 경우 지원팀에 문의하여 구성에 대한 도움을 받으세요.
계정 만들기 (계정 관리 또는 비교 쇼핑 사용)
새 계정을 만들려면 accounts.createAndConfigure를 호출하세요.
이 방법은 판매자가 계정의 전체 관리 권한과 소유권을 유지하면서 파트너에게 특정 권한을 부여할 수 있으므로 판매자의 계정 관리를 지원하는 파트너에게 권장됩니다.
요청 본문에서 다음을 수행합니다.
account필드에 만들 계정의 세부정보를 입력합니다.accountManagement를 사용하는 경우 계정에 액세스할 수 있는 사용자를user필드에 하나 이상 지정합니다.service필드에서 이 계정에 제공할 서비스(예:accountManagement)를 지정하고provider을 계정의 리소스 이름(예:providers/{YOUR_ACCOUNT_ID})으로 설정합니다.productsManagement또는campaignsManagement과 같은 사용 가능한 서비스 목록은 계정 관계 관리를 참고하세요.
다음은 'merchantStore'라는 계정을 만들고 계정 및 제품 관리를 위해 계정 {YOUR_ACCOUNT_ID}에 연결하는 요청의 예입니다.
POST https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure
{
"account": {
"accountName": "merchantStore",
"adultContent": false,
"timeZone": {
"id": "America/New_York"
},
"languageCode": "en-US"
},
"user": [
{
"userId": "test@example.com",
"user": {
"accessRights": ["ADMIN"]
}
}
],
"service": [
{
"accountManagement": {},
"provider": "providers/{YOUR_ACCOUNT_ID}"
},
{
"productsManagement": {},
"provider": "providers/{YOUR_ACCOUNT_ID}"
}
]
}
호출이 성공하면 새 계정이 생성되고 지정된 서비스의 계정에 연결됩니다. 생성 중에 accountManagement, accountAggregation 또는 comparisonShopping 서비스를 지정하면 자동으로 승인되고 연결 상태는 ESTABLISHED가 됩니다. 생성된 계정에서 수락할 때까지 다른 서비스 링크가 PENDING 상태일 수 있습니다. 응답 본문에는 새로 생성된 Account 리소스가 포함됩니다.
이러한 계정을 만든 후에는 서비스 약관에 동의, 비즈니스 정보 설정, 웹사이트 인증과 같은 단계를 실행하여 온보딩해야 합니다.
계정 생성 중 이메일 인증 억제
accounts.createAndConfigure로 계정을 만들 때 user 필드를 사용하여 추가된 새 사용자의 인증 이메일을 선택적으로 억제할 수 있습니다. 이렇게 하려면 해당 사용자의 요청에서 verificationMailSettings.verificationMailMode을 SUPPRESS_VERIFICATION_MAIL로 설정하세요. 이는 users.verifySelf 메서드를 사용하여 생성 직후 판매자를 대신하여 사용자를 인증하려는 경우에 유용합니다. 기본적으로 verificationMailMode는 SEND_VERIFICATION_MAIL이며, 계정 생성 중에 추가된 신규 사용자에게 인증 이메일이 전송됩니다.
POST https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure
{
"account": {
"accountName": "merchantStore",
"adultContent": false,
"timeZone": {
"id": "America/New_York"
},
"languageCode": "en-US"
},
"user": [
{
"userId": "test@example.com",
"user": {
"accessRights": ["ADMIN"]
},
"verificationMailSettings": {
"verificationMailMode": "SUPPRESS_VERIFICATION_MAIL"
}
}
],
"service": [
{
"accountManagement": {},
"provider": "providers/{YOUR_ACCOUNT_ID}"
}
]
}
verificationMailMode을 SUPPRESS_VERIFICATION_MAIL로 설정하면 생성 중에 추가된 각 사용자에 대해 users.verifySelf를 호출하여 인증을 완료해야 합니다. 이 호출은 확인되는 사용자(userId에 지정된 사용자)로 인증되어야 합니다(예: 사용자의 OAuth 토큰 사용).
계정 생성 시 별칭 지정
setAlias 필드를 사용하여 CreateAndConfigureAccountRequest의 제공업체 컨텍스트에서 계정의 별칭을 지정할 수 있습니다. 별칭은 시스템에서 계정을 식별하는 데 사용할 수 있습니다. 서비스 제공업체인 경우 별칭을 사용하여 GET /accounts/v1/accounts/{provider}~{alias}로 계정을 검색할 수 있습니다. 별칭은 지정된 제공업체에 대해 고유해야 하며 요청의 service 필드에 동일한 제공업체의 서비스를 지정해야 합니다. 별칭 요구사항에 대한 자세한 내용은 계정 관계 관리를 참고하세요.
POST https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure
{
"account": {
"accountName": "merchantStore",
"adultContent": false,
"timeZone": {
"id": "America/New_York"
},
"languageCode": "en-US"
},
"service": [
{
"accountManagement": {},
"provider": "providers/{YOUR_ACCOUNT_ID}"
}
],
"setAlias": [
{
"provider": "providers/{YOUR_ACCOUNT_ID}",
"accountIdAlias": "my-merchant-alias"
}
]
}
권장 온보딩 흐름
판매자를 대신하여 계정을 만드는 파트너인 경우 다음 절차를 따르는 것이 좋습니다.
- 계정 만들기: 파트너 사용자 인증 정보로
accounts.createAndConfigure를 호출하여 새 계정을 만듭니다.service를 설정하여 제공업체 ID에 연결되는accountManagement를 포함합니다.user필드를 사용하여 판매자를 사용자로 추가하고verificationMailSettings.verificationMailMode을SUPPRESS_VERIFICATION_MAIL로 설정합니다.
- 사용자 확인: 판매자의 사용자 인증 정보 (예: OAuth 토큰 사용)를 사용하여
users.verifySelf를 호출하여 사용자 상태를PENDING에서VERIFIED로 변경합니다. - 비즈니스 국가 설정: 판매자 사용자 인증 정보를 사용하여
accounts.updateBusinessInfo를 사용하여address.regionCode를 업데이트하여 비즈니스 국가를 설정합니다. 서비스 약관에 동의하기 전에 필요합니다. - 서비스 약관에 동의: 판매자 사용자 인증 정보로 서비스 약관에 동의합니다.
이 흐름을 통해 판매자는 Google에서 초대 이메일을 받지 않고도 플랫폼 내에서 원활하게 온보딩할 수 있습니다.
고객 계정 만들기 (계정 집계 사용)
클라이언트 계정은 accountAggregation 서비스를 사용하여 고급 계정에 연결된 별도의 판매자 센터 계정으로, 별도의 설정, 웹사이트, 데이터 피드를 유지하면서 중앙 집중식 관리가 가능합니다.
판매자 계정 하위 API를 사용하여 새 고객 계정을 만들 수 있습니다.
고객 계정을 만들려면 먼저 고급 계정 설정이 있어야 합니다. 판매자 센터 계정을 고급 계정으로 전환하려면 계정 관리자여야 하며 계정에 해결되지 않은 문제가 없어야 합니다.
새 고객 계정을 만들려면 accounts.createAndConfigure를 호출합니다.
요청 본문에서 다음을 수행합니다.
account필드에 만들 계정의 세부정보를 입력합니다.- 원하는 경우
user필드에 새 승인된 사용자를 지정합니다. 계정의 사용자 액세스 권한도 상위 고급 계정에서 상속됩니다. service필드에서accountAggregation을 지정하고provider을 고급 계정의 리소스 이름 (예:providers/{ADVANCED_ACCOUNT_ID})으로 설정합니다. 이렇게 하면 고급 계정이 새 계정의 집계자로 설정됩니다.
다음은 고급 계정 {ADVANCED_ACCOUNT_ID}에 연결된 'merchantStore'라는 클라이언트 계정을 만드는 요청의 예입니다.
POST https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure
{
"account": {
"accountName": "merchantStore",
"adultContent": false,
"timeZone": {
"id": "America/New_York"
},
"languageCode": "en-US"
},
"service": [
{
"accountAggregation": {},
"provider": "providers/{ADVANCED_ACCOUNT_ID}"
}
]
}
호출이 성공하면 새 고객 계정이 생성되고 지정된 고급 계정에 연결됩니다. 응답 본문에는 새로 생성된 Account 리소스가 포함됩니다.
다음 샘플은 accounts.createAndConfigure를 사용하여 새 클라이언트 계정을 만드는 방법을 보여줍니다.
자바
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.Account;
import com.google.shopping.merchant.accounts.v1.AccountAggregation;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1.CreateAndConfigureAccountRequest;
import com.google.shopping.merchant.accounts.v1.CreateAndConfigureAccountRequest.AddAccountService;
import com.google.type.TimeZone;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to create a sub-account under an advanced account. */
public class CreateSubAccountSample {
private static String getParent(String accountId) {
return String.format("accounts/%s", accountId);
}
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 advanced 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);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
createSubAccount(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Account;
use Google\Shopping\Merchant\Accounts\V1\AccountAggregation;
use Google\Shopping\Merchant\Accounts\V1\Client\AccountsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\CreateAndConfigureAccountRequest;
use Google\Shopping\Merchant\Accounts\V1\CreateAndConfigureAccountRequest\AddAccountService;
use Google\Type\TimeZone;
/**
* This class demonstrates how to create a sub-account under an MCA account.
*/
class CreateSubAccount
{
private static function getParent(string $accountId): string
{
return sprintf("accounts/%s", $accountId);
}
public static function createSubAccount(array $config): void
{
// Gets the OAuth credentials to make the request.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates options config containing credentials for the client to use.
$options = ['credentials' => $credentials];
// Creates a client.
$accountsServiceClient = new AccountsServiceClient($options);
// Creates parent/provider to identify the MCA account into which to insert the subaccount.
$parent = self::getParent($config['accountId']);
// Calls the API and catches and prints any network failures/errors.
try {
$request = new CreateAndConfigureAccountRequest([
'account' => (new Account([
'account_name' => 'Demo Business',
'adult_content' => false,
'time_zone' => (new TimeZone(['id' => 'America/New_York'])),
'language_code' => 'en-US',
])),
'service' => [
(new AddAccountService([
'provider' => $parent,
'account_aggregation' => new AccountAggregation,
])),
],
]);
print "Sending Create SubAccount request\n";
$response = $accountsServiceClient->createAndConfigureAccount($request);
print "Inserted Account Name below\n";
// Format: `accounts/{account}
print $response->getName() . PHP_EOL;
} catch (ApiException $e) {
print $e->getMessage();
}
}
public function callSample(): void
{
$config = Config::generateConfig();
self::createSubAccount($config);
}
}
$sample = new CreateSubAccount();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import Account
from google.shopping.merchant_accounts_v1 import AccountAggregation
from google.shopping.merchant_accounts_v1 import AccountsServiceClient
from google.shopping.merchant_accounts_v1 import CreateAndConfigureAccountRequest
_ACCOUNT = configuration.Configuration().read_merchant_info()
def get_parent(account_id):
return f"accounts/{account_id}"
def create_sub_account():
"""Creates a sub-account under an advanced account."""
# Get OAuth credentials.
credentials = generate_user_credentials.main()
# Create a client.
client = AccountsServiceClient(credentials=credentials)
# Get the parent advanced account ID.
parent = get_parent(_ACCOUNT)
# Create the request.
request = CreateAndConfigureAccountRequest(
account=Account(
account_name="Demo Business",
adult_content=False,
time_zone={"id": "America/New_York"},
language_code="en-US",
),
service=[
CreateAndConfigureAccountRequest.AddAccountService(
provider=parent,
account_aggregation=AccountAggregation(),
)
],
)
# Make the request and print the response.
try:
print("Sending Create SubAccount request")
response = client.create_and_configure_account(request=request)
print("Inserted Account Name below")
print(response.name)
except RuntimeError as e:
print(e)
if __name__ == "__main__":
create_sub_account()
cURL
curl -X POST \
"https://merchantapi.googleapis.com/accounts/v1/accounts:createAndConfigure" \
-H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"account": {
"accountName": "Demo Business",
"adultContent": false,
"timeZone": {
"id": "America/New_York"
},
"languageCode": "en-US"
},
"service": [
{
"accountAggregation": {},
"provider": "providers/{ADVANCED_ACCOUNT_ID}"
}
]
}'
클라이언트 계정 가져오기
지정된 고급 계정의 모든 고객 계정을 나열하려면 accounts.listSubaccounts 메서드를 사용합니다. 요청 URL의 provider 필드에 고급 계정의 ID를 제공합니다.
다음은 샘플 요청입니다.
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ADVANCED_ACCOUNT_ID}:listSubaccounts
다음은 성공적인 호출의 샘플 응답입니다.
{
"accounts": [
{
"name": "accounts/<var class=\"readonly\">{SUB_ACCOUNT_ID_1}</var>",
"accountId": "<var class=\"readonly\">{SUB_ACCOUNT_ID_1}</var>",
"accountName": "<var class=\"readonly\">{SUB_ACCOUNT_NAME_1}</var>",
"timeZone": {
"id": "America/Los_Angeles"
},
"languageCode": "en-US"
},
{
"name": "accounts/<var class=\"readonly\">{SUB_ACCOUNT_ID_2}</var>",
"accountId": "<var class=\"readonly\">{SUB_ACCOUNT_ID_2}</var>",
"accountName": "<var class=\"readonly\">{SUB_ACCOUNT_NAME_2}</var>",
"timeZone": {
"id": "America/Los_Angeles"
},
"languageCode": "en-US"
}
]
}
다음 샘플은 고급 계정의 모든 클라이언트 계정을 나열하는 방법을 보여줍니다.
자바
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.Account;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient.ListSubAccountsPagedResponse;
import com.google.shopping.merchant.accounts.v1.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1.ListSubAccountsRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to list all the subaccounts of an advanced account. */
public class ListSubAccountsSample {
private static String getParent(String accountId) {
return String.format("accounts/%s", accountId);
}
public static void listSubAccounts(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 advanced account from which to list all sub-accounts.
String parent = getParent(config.getAccountId().toString());
// Calls the API and catches and prints any network failures/errors.
try (AccountsServiceClient accountsServiceClient =
AccountsServiceClient.create(accountsServiceSettings)) {
// The parent has the format: accounts/{account}
ListSubAccountsRequest request =
ListSubAccountsRequest.newBuilder().setProvider(parent).build();
System.out.println("Sending list subaccounts request:");
ListSubAccountsPagedResponse response = accountsServiceClient.listSubAccounts(request);
int count = 0;
// Iterates over all rows in all pages and prints the datasource in each row.
// Automatically uses the `nextPageToken` if returned to fetch all pages of data.
for (Account account : response.iterateAll()) {
System.out.println(account);
count++;
}
System.out.print("The following count of accounts were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
listSubAccounts(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\AccountsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\ListSubAccountsRequest;
/**
* This class demonstrates how to list all the subaccounts of an advanced account.
*/
class ListSubAccounts
{
private static function getParent(string $accountId): string
{
return sprintf("accounts/%s", $accountId);
}
public static function listSubAccounts(array $config): void
{
// Gets the OAuth credentials to make the request.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates options config containing credentials for the client to use.
$options = ['credentials' => $credentials];
// Creates a client.
$accountsServiceClient = new AccountsServiceClient($options);
// Creates parent/provider to identify the advanced account from which
//to list all accounts.
$parent = self::getParent($config['accountId']);
// Calls the API and catches and prints any network failures/errors.
try {
// The parent has the format: accounts/{account}
$request = new ListSubAccountsRequest(['provider' => $parent]);
print "Sending list subaccounts request:\n";
$response = $accountsServiceClient->listSubAccounts($request);
$count = 0;
// Iterates over all rows in all pages and prints the datasource in each row.
// Automatically uses the `nextPageToken` if returned to fetch all pages of data.
foreach ($response->iterateAllElements() as $account) {
print_r($account);
$count++;
}
print "The following count of accounts were returned: ";
print $count . PHP_EOL;
} catch (ApiException $e) {
print "An error has occured: \n";
print $e->getMessage();
}
}
public function callSample(): void
{
$config = Config::generateConfig();
self::listSubAccounts($config);
}
}
$sample = new ListSubAccounts();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import AccountsServiceClient
from google.shopping.merchant_accounts_v1 import ListSubAccountsRequest
_ACCOUNT = configuration.Configuration().read_merchant_info()
def get_parent(account_id):
return f"accounts/{account_id}"
def list_sub_accounts():
"""Lists all the subaccounts of an advanced account."""
# Get OAuth credentials.
credentials = generate_user_credentials.main()
# Create a client.
client = AccountsServiceClient(credentials=credentials)
# Get the parent advanced account ID.
parent = get_parent(_ACCOUNT)
# Create the request.
request = ListSubAccountsRequest(provider=parent)
# Make the request and print the response.
try:
print("Sending list subaccounts request:")
response = client.list_sub_accounts(request=request)
count = 0
for account in response:
print(account)
count += 1
print(f"The following count of accounts were returned: {count}")
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
list_sub_accounts()
cURL
curl -X GET \
"https://merchantapi.googleapis.com/accounts/v1/accounts/{ADVANCED_ACCOUNT_ID}:listSubaccounts" \
-H "Authorization: Bearer <YOUR_ACCESS_TOKEN>"
고객 계정 삭제
더 이상 고객 계정을 관리할 필요가 없는 경우 accounts.delete 메서드를 사용하여 삭제할 수 있습니다.
이 메서드를 실행하려면 삭제할 계정에 대한 관리자 액세스 권한이 필요합니다.
다음은 샘플 요청입니다.
DELETE https://merchantapi.googleapis.com/accounts/v1/accounts/{SUB_ACCOUNT_ID}
성공하면 응답 본문은 빈 JSON 객체로, 계정이 삭제되었음을 나타냅니다.
다음 샘플은 클라이언트 계정을 삭제하는 방법을 보여줍니다.
자바
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1.DeleteAccountRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to delete a given Merchant Center account. */
public class DeleteAccountSample {
// This method can delete a standalone, advanced account or sub-account. If you delete an advanced
// account,
// all sub-accounts will also be deleted.
// Admin user access is required to execute this method.
public static void deleteAccount(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();
// Gets the account ID from the config file.
String accountId = config.getAccountId().toString();
// Creates account name to identify the account.
String name =
AccountName.newBuilder()
.setAccount(accountId)
.build()
.toString();
// Calls the API and catches and prints any network failures/errors.
try (AccountsServiceClient accountsServiceClient =
AccountsServiceClient.create(accountsServiceSettings)) {
DeleteAccountRequest request =
DeleteAccountRequest.newBuilder()
.setName(name)
// Optional. If set to true, the account will be deleted even if it has offers or
// provides services to other accounts. Defaults to 'false'.
.setForce(true)
.build();
System.out.println("Sending Delete Account request");
accountsServiceClient.deleteAccount(request); // No response returned on success.
System.out.println("Delete successful.");
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
deleteAccount(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\AccountsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\DeleteAccountRequest;
/**
* This class demonstrates how to delete a given Merchant Center account.
*/
class DeleteAccount
{
private static function getParent(string $accountId): string
{
return sprintf("accounts/%s", $accountId);
}
// This method can delete a standalone, advanced account or sub-account.
// If you delete an advanced account, all sub-accounts will also be deleted.
// Admin user access is required to execute this method.
public static function deleteAccount(array $config): void
{
// Gets the OAuth credentials to make the request.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates options config containing credentials for the client to use.
$options = ['credentials' => $credentials];
// Creates a client.
$accountsServiceClient = new AccountsServiceClient($options);
// Gets the account ID from the config file.
$accountId = $config['accountId'];
// Creates account name to identify the account.
$name = self::getParent($accountId);
// Calls the API and catches and prints any network failures/errors.
try {
$request = new DeleteAccountRequest([
'name' => $name,
// Optional. If set to true, the account will be deleted even if it has offers or
// provides services to other accounts. Defaults to 'false'.
'force' => true,
]);
print "Sending Delete Account request\n";
$accountsServiceClient->deleteAccount($request); // No response returned on success.
print "Delete successful.\n";
} catch (ApiException $e) {
print $e->getMessage();
}
}
public function callSample(): void
{
$config = Config::generateConfig();
self::deleteAccount($config);
}
}
$sample = new DeleteAccount();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import AccountsServiceClient
from google.shopping.merchant_accounts_v1 import DeleteAccountRequest
_ACCOUNT = configuration.Configuration().read_merchant_info()
def get_parent(account_id):
return f"accounts/{account_id}"
def delete_account():
"""Deletes a given Merchant Center account."""
# Get OAuth credentials.
credentials = generate_user_credentials.main()
# Create a client.
client = AccountsServiceClient(credentials=credentials)
# Create the account name.
name = get_parent(_ACCOUNT)
# Create the request.
request = DeleteAccountRequest(name=name, force=True)
# Make the request and print the response.
try:
print("Sending Delete Account request")
client.delete_account(request=request)
print("Delete successful.")
except RuntimeError as e:
print(e)
if __name__ == "__main__":
delete_account()
cURL
curl -X DELETE \
"https://merchantapi.googleapis.com/accounts/v1/accounts/{SUB_ACCOUNT_ID}?force=true" \
-H "Authorization: Bearer <YOUR_ACCESS_TOKEN>"
서비스 약관 동의
클라이언트 계정은 상위 고급 계정이 서명한 판매자 센터 서비스 약관 (TOS)을 상속합니다.
비즈니스 정보 업데이트
판매자 계정 API를 사용하여 클라이언트 계정의 비즈니스 정보를 수정할 수 있습니다.
- 계정의 비즈니스 정보를 보려면
accounts.getBusinessInfo을 호출합니다.- 계정의 비즈니스 정보를 수정하려면
accounts.updateBusinessInfo을 호출합니다.
- 계정의 비즈니스 정보를 수정하려면