Merchant API を使用するには、Merchant Center アカウントが必要です。Merchant Center の管理画面を使用して作成できます。
複数のアカウントを管理する必要がある場合は、Merchant API を使用してサブアカウントを作成できます。
アカウントは、Merchant Center の管理画面で設定するか、後述の API を使用して設定できます。
Merchant Center 利用規約に同意する
すべての販売者は、Merchant Center 利用規約に同意する必要があります。販売アカウントの利用規約に同意する方法は次のとおりです。
accounts.termsOfServiceAgreementStates.retrieveForApplication
を呼び出して、アカウントに必要な利用規約を確認します。リクエストの例を次に示します。
GET https://merchantapi.googleapis.com/accounts/v1beta/accounts/{ACCOUNT_ID}/termsOfServiceAgreementStates:retrieveForApplication
呼び出しが成功した場合のレスポンスの例を次に示します。
{ "name": "accounts/{ACCOUNT_ID}/termsOfServiceAgreementStates/MERCHANT_CENTER-{COUNTRY}", "regionCode": {COUNTRY}, "termsOfServiceKind": "MERCHANT_CENTER", "accepted": { "termsOfService": "termsOfService/{VERSION}", "acceptedBy": "accounts/{ACCOUNT_ID}" } }
termsOfService.accept
を呼び出して、利用規約に同意します。リクエストの例を次に示します。
GET https://merchantapi.googleapis.com/accounts/v1beta/{name=termsOfService/{VERSION}}:accept
成功すると、レスポンスの本文は空になります。
販売者に利用規約を表示し、同意を求める UI を作成することをおすすめします。
ビジネスの
regionCode
を使用してtermsOfService.retrieveLatest
を実行し、販売者が同意する必要がある利用規約を確認します。リクエストの例を次に示します。
GET https://merchantapi.googleapis.com/accounts/v1beta/termsOfService:retrieveLatest
呼び出しが成功した場合のレスポンスの例を次に示します。
{ "name": "termsOfService/{VERSION}", "regionCode": "{COUNTRY}", "kind": "MERCHANT_CENTER", "fileUri": "{URI}" }
fileUri
の利用規約を販売者に表示します。販売者が UI で利用規約に同意したら、同意する利用規約の
name
を指定してtermsOfService.accept
を呼び出します。
特定のアカウントの利用規約に同意する際に使用できるサンプルを次に示します。
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()
販売者が利用規約に同意したら、Merchant API を使用して残りのアカウント情報を設定できます。Merchant Accounts API で管理できるアカウント情報の詳細については、Account
リソースをご覧ください。
ウェブサイトを申請する
Merchant Accounts API を使用して、ビジネスの Homepage
を追加して登録できます。
- ホームページをアカウントに追加するには、ホームページの URL を含む
Homepage
リソースを指定してaccounts.updateHomepage
を呼び出します。 - ホームページの所有権を主張するには、
Hompeage
リソースのname
を指定してaccounts.homepage.claim
を呼び出します。
Merchant API を使用してホームページを確認することはできません。詳しくは、ショップのウェブサイトの所有権の証明と申請を行うをご覧ください。
ビジネスの詳細を更新する
Merchant Accounts API を使用して、ビジネスの PostalAddress
、CusomerService
、BusinessIdentity
を編集できます。
ビジネスの身元:
- ビジネス アイデンティティを表示するには、
accounts.businessIdentity.getBusinessIdentity
を呼び出します。 - ビジネス アイデンティティを編集するには、
accounts.businessIdentity.updateBusinessIdentity
を呼び出します。
次のステップ
- サブアカウントを作成、管理する方法を学習する。
- 販売アカウント間の関係の仕組みについては、アカウント間の関係をご覧ください。