Merchant Center とその機能を使用するには、ビジネスの所在地について Merchant Center 利用規約(ToS)に同意する必要があります。これらの契約には、Merchant Center サービスの利用に関する法的条件が記載されています。
このガイドでは、Merchant API を使用して、自社のアカウントまたはサードパーティ プロバイダ(3P)として管理しているアカウントの契約を管理する方法について説明します。
次のことを実現できます。
- アカウントの現在の利用規約への同意状況を確認します。
- 必要な利用規約に同意するよう販売者を案内します。
- クライアント アカウントまたはスタンドアロン アカウントのサードパーティ プロバイダとして利用規約を管理します。
前提条件
Merchant API を使用するには、Merchant Center アカウントが必要です。Merchant Center のユーザー インターフェース(UI)を使用してアカウントを作成したら、UI または API を使用してアカウントに変更を加えることができます(ビジネス情報の更新、ユーザーの管理など)。
複数のアカウントを管理する必要がある場合は、Merchant API を使用してクライアント アカウントを作成できます。サブアカウントの作成と管理をご覧ください。
アカウントの利用規約への同意状況を確認する
販売者が Merchant Center を十分に活用できるようにする前に、または現在の契約ステータスを確認する必要がある場合は、利用規約の契約ステータスを取得できます。
termsOfServiceAgreementStates.retrieveForApplication
メソッドを使用して、コア Merchant Center アプリケーションの利用規約の同意ステータスを取得します。このメソッドは、現在の利用規約(存在する場合)を返します。また、前回同意したときから利用規約が更新されている場合は、同意する必要がある最新バージョンを返します。
リクエストの例を次に示します。
GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}/termsOfServiceAgreementStates:retrieveForApplication
呼び出しが成功すると、TermsOfServiceAgreementState
リソースが返されます。このリソースには次のものが含まれます。
name
: この契約状態の識別子。regionCode
: この契約状態が適用される国。通常はアカウントのビジネス国です。termsOfServiceKind
:MERCHANT_CENTER
になります。accepted
: アカウントがすでに同意している利用規約のバージョンに関する詳細。termsOfService
リソース名(termsOfService/132
など)や、誰がacceptedBy
したかなど。新しい利用規約のバージョンがrequired
の場合は、validUntil
の日付も含まれることがあります。required
: アカウントが同意する必要がある利用規約のバージョンに関する詳細。これには、termsOfService
リソース名と、人が読める形式の利用規約ドキュメントを指すtosFileUri
が含まれます。
レスポンスの例:
{
"name": "accounts/{ACCOUNT_ID}/termsOfServiceAgreementStates/MERCHANT_CENTER-{REGION_CODE}",
"regionCode": "{REGION_CODE}",
"termsOfServiceKind": "MERCHANT_CENTER",
"accepted": {
"termsOfService": "termsOfService/132",
"acceptedBy": "accounts/{ACCOUNT_ID}"
},
"required": {
"termsOfService": "termsOfService/132",
"tosFileUri": "https://www.google.com/intl/{REGION_CODE}/policies/merchants/terms/"
}
}
新しい利用規約が required
の場合は、販売者に同意するよう案内する必要があります。
特定のユーザー アカウントと国について利用規約の同意状況を取得するために使用できるサンプルを次に示します。
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.GetTermsOfServiceAgreementStateRequest;
import com.google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementState;
import com.google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementStateName;
import com.google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementStateServiceClient;
import com.google.shopping.merchant.accounts.v1beta.TermsOfServiceAgreementStateServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to get a TermsOfServiceAgreementState for a specific
* TermsOfServiceKind and country.
*/
public class GetTermsOfServiceAgreementStateSample {
public static void getTermsOfServiceAgreementState(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.
TermsOfServiceAgreementStateServiceSettings termsOfServiceAgreementStateServiceSettings =
TermsOfServiceAgreementStateServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates TermsOfServiceAgreementState name to identify TermsOfServiceAgreementState.
String name =
TermsOfServiceAgreementStateName.newBuilder()
.setAccount(config.getAccountId().toString())
// The Identifier is: "{TermsOfServiceKind}-{country}"
.setIdentifier("MERCHANT_CENTER-US")
.build()
.toString();
System.out.println(name);
// Calls the API and catches and prints any network failures/errors.
try (TermsOfServiceAgreementStateServiceClient termsOfServiceAgreementStateServiceClient =
TermsOfServiceAgreementStateServiceClient.create(
termsOfServiceAgreementStateServiceSettings)) {
// The name has the format:
// accounts/{account}/termsOfServiceAgreementStates/{TermsOfServiceKind}-{country}
GetTermsOfServiceAgreementStateRequest request =
GetTermsOfServiceAgreementStateRequest.newBuilder().setName(name).build();
System.out.println("Sending Get TermsOfServiceAgreementState request:");
TermsOfServiceAgreementState response =
termsOfServiceAgreementStateServiceClient.getTermsOfServiceAgreementState(request);
System.out.println("Retrieved TermsOfServiceAgreementState below");
// If the terms of service needs to be accepted, the "required" field will include the
// specific version of the terms of service which needs to be accepted, alongside a link to
// the terms of service itself.
System.out.println(response);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
getTermsOfServiceAgreementState(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1beta\Client\TermsOfServiceAgreementStateServiceClient;
use Google\Shopping\Merchant\Accounts\V1beta\GetTermsOfServiceAgreementStateRequest;
/**
* Demonstrates how to get a TermsOfServiceAgreementState.
*/
class GetTermsOfServiceAgreementState
{
/**
* Gets a TermsOfServiceAgreementState.
*
* @param array $config The configuration data.
* @return void
*/
public static function getTermsOfServiceAgreementState($config): void
{
// Get OAuth credentials.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Create client options.
$options = ['credentials' => $credentials];
// Create a TermsOfServiceAgreementStateServiceClient.
$termsOfServiceAgreementStateServiceClient = new TermsOfServiceAgreementStateServiceClient($options);
// Service agreeement identifier
$identifier = "MERCHANT_CENTER-US";
// Create TermsOfServiceAgreementState name.
$name = "accounts/" . $config['accountId'] . "/termsOfServiceAgreementStates/" . $identifier;
print $name . PHP_EOL;
try {
// Prepare the request.
$request = new GetTermsOfServiceAgreementStateRequest([
'name' => $name,
]);
print "Sending Get TermsOfServiceAgreementState request:" . PHP_EOL;
$response = $termsOfServiceAgreementStateServiceClient->getTermsOfServiceAgreementState($request);
print "Retrieved TermsOfServiceAgreementState below\n";
print $response->serializeToJsonString() . PHP_EOL;
} catch (ApiException $e) {
print $e->getMessage();
}
}
/**
* Helper to execute the sample.
*
* @return void
*/
public function callSample(): void
{
$config = Config::generateConfig();
self::getTermsOfServiceAgreementState($config);
}
}
// Run the script
$sample = new GetTermsOfServiceAgreementState();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1beta import GetTermsOfServiceAgreementStateRequest
from google.shopping.merchant_accounts_v1beta import TermsOfServiceAgreementStateServiceClient
# Replace with your actual value.
_ACCOUNT_ID = configuration.Configuration().read_merchant_info()
_IDENTIFIER = "MERCHANT_CENTER-US" # Replace with your identifier
def get_terms_of_service_agreement_state():
"""Gets a TermsOfServiceAgreementState for a specific TermsOfServiceKind and country."""
credentials = generate_user_credentials.main()
client = TermsOfServiceAgreementStateServiceClient(credentials=credentials)
name = (
"accounts/"
+ _ACCOUNT_ID
+ "/termsOfServiceAgreementStates/"
+ _IDENTIFIER
)
print(name)
request = GetTermsOfServiceAgreementStateRequest(name=name)
try:
print("Sending Get TermsOfServiceAgreementState request:")
response = client.get_terms_of_service_agreement_state(request=request)
print("Retrieved TermsOfServiceAgreementState below")
print(response)
except RuntimeError as e:
print(e)
if __name__ == "__main__":
get_terms_of_service_agreement_state()
利用規約に同意する
販売者は、Merchant Center の機能へのアクセスを維持するために、最新の利用規約に同意する必要があります。
自分のアカウントの利用規約に同意する
Merchant Center アカウントを自分で管理している場合は、次の操作を行います。
termsOfServiceAgreementStates.retrieveForApplication
を呼び出して、利用規約がrequired
かどうかを特定します。- 利用規約が必要な場合は、
required
フィールドのtermsOfService
名(termsOfService/132
など)をメモします。 termsOfService.accept
を呼び出して利用規約に同意します。retrieveForApplication から返された ToS 名、ACCOUNT_ID
、regionCode
が必要になります。リクエストの例を次に示します。
POST https://merchantapi.googleapis.com/accounts/v1beta/{name={termsOfService/VERSION}}:accept { "account": "accounts/{ACCOUNT_ID}", "regionCode": "{REGION_CODE}" }
呼び出しが成功すると、空のレスポンス本文が返され、アカウントの利用規約同意ステータスが更新されます。
販売者に利用規約への同意を促す(サードパーティ プロバイダ向け)
他のビジネスのスタンドアロンの Merchant Center アカウントを管理しているサードパーティ プロバイダ(3P)は、他のビジネスの代理として利用規約に同意することはできません。代わりに、次のことを行う必要があります。
最新の利用規約を取得する: 販売者の
regionCode
とMERCHANT_CENTER
の種類に対してtermsOfService.retrieveLatest
を呼び出し、販売者が同意する必要がある最新の利用規約のバージョンの詳細を取得します。リクエストの例:
GET https://merchantapi.googleapis.com/accounts/v1beta/termsOfService:retrieveLatest?regionCode={REGION_CODE}&kind=MERCHANT_CENTER
レスポンスの例:
{ "name": "{termsOfService/VERSION}", "regionCode": "{REGION_CODE}", "kind": "MERCHANT_CENTER", "fileUri": "https://www.google.com/intl/{REGION_CODE}/policies/merchants/terms/" }
利用規約を表示する: レスポンスの
fileUri
を使用して、アプリケーションの UI 内で販売者に利用規約の全文を表示します。販売者の同意を得る: 販売者は UI 内で明示的に規約に同意する必要があります。
API を使用して同意を記録する: 販売者が同意したら、ステップ 1 で取得した利用規約の
name
、販売者のACCOUNT_ID
、販売者のregionCode
を使用してtermsOfService.accept
を呼び出します。リクエストの例:
POST https://merchantapi.googleapis.com/accounts/v1beta/{name={termsOfService/VERSION}}:accept { "account": "accounts/{MERCHANT_ACCOUNT_ID}", "regionCode": "{REGION_CODE}" }
マーチャントが同意した後、特定のアカウントの利用規約に同意するために使用できるサンプルを次に示します。
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1beta.AcceptTermsOfServiceRequest;
import com.google.shopping.merchant.accounts.v1beta.TermsOfServiceServiceClient;
import com.google.shopping.merchant.accounts.v1beta.TermsOfServiceServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to accept the TermsOfService agreement in a given account. */
public class AcceptTermsOfServiceSample {
public static void acceptTermsOfService(String accountId, String tosVersion, String regionCode)
throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
TermsOfServiceServiceSettings tosServiceSettings =
TermsOfServiceServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (TermsOfServiceServiceClient tosServiceClient =
TermsOfServiceServiceClient.create(tosServiceSettings)) {
// The parent has the format: accounts/{account}
AcceptTermsOfServiceRequest request =
AcceptTermsOfServiceRequest.newBuilder()
.setName(String.format("termsOfService/%s", tosVersion))
.setAccount(String.format("accounts/%s", accountId))
.setRegionCode(regionCode)
.build();
System.out.println("Sending request to accept terms of service...");
tosServiceClient.acceptTermsOfService(request);
System.out.println("Successfully accepted terms of service.");
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// See GetTermsOfServiceAgreementStateSample to understand how to check which version of the
// terms of service needs to be accepted, if any.
// Likewise, if you know that the terms of service needs to be accepted, you can also simply
// call RetrieveLatestTermsOfService to get the latest version of the terms of service.
// Region code is either a country when the ToS applies specifically to that country or 001 when
// it applies globally.
acceptTermsOfService(config.getAccountId().toString(), "VERSION_HERE", "REGION_CODE_HERE");
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1beta\AcceptTermsOfServiceRequest;
use Google\Shopping\Merchant\Accounts\V1beta\Client\TermsOfServiceServiceClient;
/**
* Demonstrates how to accept the TermsOfService agreement in a given account.
*/
class AcceptTermsOfService
{
/**
* Accepts the Terms of Service agreement.
*
* @param string $accountId The account ID.
* @param string $tosVersion The Terms of Service version.
* @param string $regionCode The region code.
* @return void
*/
public static function acceptTermsOfService($accountId, $tosVersion, $regionCode): void
{
// Get OAuth credentials.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Create client options.
$options = ['credentials' => $credentials];
// Create a TermsOfServiceServiceClient.
$tosServiceClient = new TermsOfServiceServiceClient($options);
try {
// Prepare the request.
$request = new AcceptTermsOfServiceRequest([
'name' => sprintf("termsOfService/%s", $tosVersion),
'account' => sprintf("accounts/%s", $accountId),
'region_code' => $regionCode,
]);
print "Sending request to accept terms of service...\n";
$tosServiceClient->acceptTermsOfService($request);
print "Successfully accepted terms of service.\n";
} catch (ApiException $e) {
print $e->getMessage();
}
}
/**
* Helper to execute the sample.
*
* @return void
*/
public function callSample(): void
{
$config = Config::generateConfig();
// Replace with actual values.
$tosVersion = "132";
$regionCode = "US";
self::acceptTermsOfService($config['accountId'], $tosVersion, $regionCode);
}
}
// Run the script
$sample = new AcceptTermsOfService();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1beta import AcceptTermsOfServiceRequest
from google.shopping.merchant_accounts_v1beta import TermsOfServiceServiceClient
# Replace with your actual values.
_ACCOUNT_ID = configuration.Configuration().read_merchant_info()
_TOS_VERSION = ( # Replace with the Terms of Service version to accept
"VERSION_HERE"
)
_REGION_CODE = "US" # Replace with the region code
def accept_terms_of_service():
"""Accepts the Terms of Service agreement for a given account."""
credentials = generate_user_credentials.main()
client = TermsOfServiceServiceClient(credentials=credentials)
# Construct the request
request = AcceptTermsOfServiceRequest(
name=f"termsOfService/{_TOS_VERSION}",
account=f"accounts/{_ACCOUNT_ID}",
region_code=_REGION_CODE,
)
try:
print("Sending request to accept terms of service...")
client.accept_terms_of_service(request=request)
print("Successfully accepted terms of service.")
except RuntimeError as e:
print(e)
if __name__ == "__main__":
accept_terms_of_service()
サードパーティ プロバイダに関する特別な考慮事項
サードパーティ プロバイダは、クライアント アカウントまたはスタンドアロン アカウントの利用規約を管理できます。
クライアント アカウントの利用規約を管理する
アドバンス アカウント を運営しており、さまざまなビジネスのクライアント アカウントを作成している場合:
- 高度なアカウントの承認: 高度なアカウントがクライアント アカウントにアカウント集約サービスを提供する場合、高度なアカウントが承認した利用規約は、そのサービスを利用するすべてのクライアント アカウントにも適用されます。
- 表示と同意: 上級アカウントの同意がクライアント アカウントを対象としている場合でも、各クライアント アカウントの実際のビジネスオーナーに関連する Google Merchant Center の利用規約を表示することが推奨されます(法的要件である場合もあります)。同意の API 呼び出しが高度なアカウント レベルで行われる場合でも、これらの規約を理解し、同意していることを明示的に確認する必要があります。
- クライアント アカウントのステータスを確認する: 特定のクライアント アカウントで
termsOfServiceAgreementStates.retrieveForApplication
を使用して、利用規約のステータスを確認し、高度なアカウントの契約の対象となっているかどうか、または直接的な対応が必要かどうかを確認します。
スタンドアロン アカウントの利用規約を管理する
販売者に利用規約への同意を促すで説明しているように、ビジネスがスタンドアロンの Merchant Center アカウントを作成または管理するのをサポートする場合は、そのビジネス(アカウントの所有者)が利用規約に同意する必要があります。この処理を容易にするため、利用規約を取得して表示し、ユーザーがインターフェースを通じて明示的な同意を与えた後に、ユーザーに代わって termsOfService.accept
メソッドを呼び出します。