管理 Merchant Center 服務條款協議

如要使用 Merchant Center 和相關功能,你必須為商家地點接受 Merchant Center 服務條款。這些協議列出使用 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:這項協議狀態的 ID。
  • regionCode:這項協議狀態適用的國家/地區,通常是帳戶的商家國家/地區。
  • termsOfServiceKind:這會是 MERCHANT_CENTER
  • accepted:帳戶已接受的服務條款版本詳細資料,包括 termsOfService 資源名稱 (例如 termsOfService/132) 和acceptedBy。如果《服務條款》有新版本,也可能包含 validUntil 日期 required
  • 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 帳戶,請按照下列步驟操作:

  1. 呼叫 termsOfServiceAgreementStates.retrieveForApplication,判斷是否有任何服務條款為 required
  2. 如果需要服務條款,請記下 required 欄位中的 termsOfService 名稱 (例如 termsOfService/132)。
  3. 呼叫 termsOfService.accept 即可接受服務條款。您需要服務條款名稱、ACCOUNT_ID,以及 retrieveForApplication 傳回的 regionCode

    以下是範例要求:

    POST https://merchantapi.googleapis.com/accounts/v1beta/{name={termsOfService/VERSION}}:accept
    {
      "account": "accounts/{ACCOUNT_ID}",
      "regionCode": "{REGION_CODE}"
    }
    

    如果呼叫成功,系統會傳回空白的回應主體,並更新帳戶的服務條款同意狀態。

引導商家接受服務條款 (適用於第三方供應商)

如果您是第三方供應商,為其他商家管理獨立的 Merchant Center 帳戶,請勿代表他們接受服務條款。建議改用下列方法:

  1. 擷取最新服務條款:呼叫商家 regionCodeMERCHANT_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/"
    }
    
  2. 顯示服務條款:使用回應中的 fileUri,在應用程式的使用者介面中向商家顯示服務條款全文。

  3. 取得商家接受聲明:商家必須在 UI 中明確同意條款。

  4. 使用 API 記錄接受情形:商家接受後,請使用步驟 1 中取得的服務條款 name、商家的 ACCOUNT_IDregionCode,呼叫 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 方法,才能完成這項程序。