Quản lý thoả thuận Điều khoản dịch vụ của Merchant Center

Để sử dụng Merchant Center và các tính năng của nền tảng này, bạn phải chấp nhận Điều khoản dịch vụ của Merchant Center (ToS) cho địa điểm của doanh nghiệp mình. Các thoả thuận này nêu ra các điều khoản pháp lý để sử dụng dịch vụ Merchant Center.

Hướng dẫn này giải thích cách bạn có thể sử dụng Merchant API để quản lý các thoả thuận này, cho dù là cho tài khoản của riêng bạn hay cho các tài khoản mà bạn quản lý với tư cách là nhà cung cấp bên thứ ba (3P).

Bạn có thể đạt được những điều sau:

  • Kiểm tra trạng thái thoả thuận ToS hiện tại của một tài khoản.
  • Hướng dẫn người bán chấp nhận ToS cần thiết.
  • Quản lý ToS với tư cách là nhà cung cấp dịch vụ cho tài khoản khách hàng.

Điều kiện tiên quyết

Để sử dụng Merchant API, bạn cần có tài khoản Merchant Center. Sau khi tạo tài khoản này bằng giao diện người dùng (UI) của Merchant Center, bạn có thể thay đổi tài khoản (chẳng hạn như cập nhật thông tin doanh nghiệp, quản lý người dùng, v.v.) bằng giao diện người dùng hoặc API.

Nếu cần quản lý nhiều tài khoản, bạn có thể tạo tài khoản khách hàng bằng Merchant API. Xem bài viết Tạo tài khoản.

Kiểm tra trạng thái thoả thuận ToS của một tài khoản

Trước khi người bán có thể sử dụng đầy đủ Merchant Center hoặc nếu bạn cần xác minh trạng thái thoả thuận hiện tại của họ, bạn có thể truy xuất trạng thái thoả thuận Điều khoản dịch vụ của họ.

Use the termsOfServiceAgreementStates.retrieveForApplication phương thức để xem trạng thái thoả thuận ToS cho ứng dụng Merchant Center cốt lõi. Phương thức này trả về ToS hiện tại của bạn (nếu có) và nếu ToS đã được cập nhật kể từ lần bạn chấp nhận gần đây nhất, thì phương thức này sẽ trả về phiên bản mới nhất mà bạn cần chấp nhận.

Sau đây là yêu cầu mẫu:

GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/termsOfServiceAgreementStates:retrieveForApplication

Lệnh gọi thành công sẽ trả về tài nguyên TermsOfServiceAgreementState. Tài nguyên này chứa:

  • name: Giá trị nhận dạng cho trạng thái thoả thuận này.
  • regionCode: Quốc gia mà trạng thái thoả thuận này áp dụng, thường là quốc gia kinh doanh của tài khoản.
  • termsOfServiceKind: Giá trị này sẽ là MERCHANT_CENTER.
  • accepted: Thông tin chi tiết về phiên bản ToS mà tài khoản đã chấp nhận, bao gồm tên tài nguyên termsOfService (chẳng hạn như termsOfService/132) và người acceptedBy. Giá trị này cũng có thể bao gồm ngày validUntil nếu phiên bản ToS mới hơn là required.
  • required: Thông tin chi tiết về phiên bản ToS mà tài khoản phải chấp nhận. Thông tin này bao gồm tên tài nguyên termsOfServicetosFileUri trỏ đến tài liệu ToS mà con người có thể đọc được.

Phản hồi mẫu:

{
  "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/"
  }
}

Nếu ToS mới là required, bạn nên hướng dẫn người bán chấp nhận ToS đó.

Sau đây là mẫu mà bạn có thể dùng để truy xuất trạng thái thoả thuận Điều khoản dịch vụ cho một tài khoản và quốc gia cụ thể:

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.GetTermsOfServiceAgreementStateRequest;
import com.google.shopping.merchant.accounts.v1.TermsOfServiceAgreementState;
import com.google.shopping.merchant.accounts.v1.TermsOfServiceAgreementStateName;
import com.google.shopping.merchant.accounts.v1.TermsOfServiceAgreementStateServiceClient;
import com.google.shopping.merchant.accounts.v1.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\V1\Client\TermsOfServiceAgreementStateServiceClient;
use Google\Shopping\Merchant\Accounts\V1\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_v1 import GetTermsOfServiceAgreementStateRequest
from google.shopping.merchant_accounts_v1 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()

Chấp nhận Điều khoản dịch vụ

Người bán phải chấp nhận Điều khoản dịch vụ mới nhất để duy trì quyền truy cập vào các tính năng của Merchant Center.

Chấp nhận ToS cho tài khoản của riêng bạn

Nếu bạn đang quản lý tài khoản Merchant Center của riêng mình, hãy làm như sau:

  1. Gọi termsOfServiceAgreementStates.retrieveForApplication để xác định xem có ToS nào là required hay không.
  2. Nếu ToS là bắt buộc, hãy lưu ý tên termsOfService trong trường required (chẳng hạn như termsOfService/132).
  3. Gọi termsOfService.accept để chấp nhận ToS. Bạn sẽ cần tên ToS, ACCOUNT_IDregionCode do retrieveForApplication trả về.

    Sau đây là yêu cầu mẫu:

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

    Lệnh gọi thành công sẽ trả về một nội dung phản hồi trống và cập nhật trạng thái thoả thuận ToS của tài khoản.

Hướng dẫn người bán chấp nhận ToS (dành cho nhà cung cấp bên thứ ba)

Nếu bạn là nhà cung cấp bên thứ ba (3P) quản lý tài khoản Merchant Center cho các doanh nghiệp khác, thì bạn không được chấp nhận ToS thay mặt họ. Thay vào đó, bạn nên:

  1. Truy xuất ToS mới nhất: Gọi termsOfService.retrieveLatest cho loại regionCodeMERCHANT_CENTER của người bán để xem thông tin chi tiết về phiên bản ToS mới nhất mà họ có thể cần chấp nhận.

    Yêu cầu mẫu:

    GET https://merchantapi.googleapis.com/accounts/v1/termsOfService:retrieveLatest?regionCode={REGION_CODE}&kind=MERCHANT_CENTER
    

    Phản hồi mẫu:

    {
        "name": "{termsOfService/VERSION}",
        "regionCode": "{REGION_CODE}",
        "kind": "MERCHANT_CENTER",
        "fileUri": "https://www.google.com/intl/{REGION_CODE}/policies/merchants/terms/"
    }
    
  2. Hiển thị ToS: Sử dụng fileUri trong phản hồi để hiển thị toàn bộ văn bản của Điều khoản dịch vụ cho người bán trong giao diện người dùng của ứng dụng.

  3. Yêu cầu người bán chấp nhận: Người bán phải đồng ý một cách rõ ràng với các điều khoản trong giao diện người dùng của bạn.

  4. Ghi lại việc chấp nhận bằng API: Sau khi người bán chấp nhận, hãy gọi termsOfService.accept bằng name của ToS nhận được ở bước 1, ACCOUNT_ID của người bán, và regionCode của họ.

    Yêu cầu mẫu:

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

Sau đây là mẫu mà bạn có thể dùng để chấp nhận thoả thuận Điều khoản dịch vụ cho một tài khoản nhất định (sau khi người bán đã đồng ý):

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AcceptTermsOfServiceRequest;
import com.google.shopping.merchant.accounts.v1.TermsOfServiceServiceClient;
import com.google.shopping.merchant.accounts.v1.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\V1\AcceptTermsOfServiceRequest;
use Google\Shopping\Merchant\Accounts\V1\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_v1 import AcceptTermsOfServiceRequest
from google.shopping.merchant_accounts_v1 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()

Các điểm cần đặc biệt lưu ý dành cho nhà cung cấp bên thứ ba

Với tư cách là nhà cung cấp bên thứ ba, bạn có thể quản lý ToS cho tài khoản khách hàng.

Quản lý ToS cho tài khoản khách hàng

Nếu bạn vận hành một tài khoản nâng cao và tạo tài khoản khách hàng cho các doanh nghiệp khác nhau:

  • Chấp nhận tài khoản nâng cao: Nếu một tài khoản nâng cao cung cấp dịch vụ tổng hợp tài khoản cho tài khoản khách hàng, thì ToS do tài khoản nâng cao chấp nhận cũng sẽ áp dụng cho tất cả tài khoản khách hàng của tài khoản đó có dịch vụ đó.
  • Hiển thị và đồng ý: Ngay cả khi việc chấp nhận của tài khoản nâng cao áp dụng cho tài khoản khách hàng, bạn vẫn nên (và có thể là yêu cầu pháp lý) hiển thị ToS có liên quan của Google Merchant Center cho chủ sở hữu doanh nghiệp thực tế của từng khách hàng như vậy. Bạn phải yêu cầu họ đồng ý một cách rõ ràng rằng họ hiểu và đồng ý với các điều khoản này, ngay cả khi lệnh gọi API để chấp nhận được thực hiện ở cấp tài khoản nâng cao.
  • Kiểm tra trạng thái tài khoản khách hàng: Sử dụng termsOfServiceAgreementStates.retrieveForApplication trên một tài khoản khách hàng cụ thể để xác minh trạng thái ToS của tài khoản đó và xem tài khoản đó có thuộc phạm vi thoả thuận của tài khoản nâng cao hay không hoặc có cần thực hiện hành động trực tiếp nào hay không.

Quản lý ToS cho các tài khoản khác

Như đã nêu chi tiết trong bài viết Hướng dẫn người bán chấp nhận ToS, khi bạn hỗ trợ một doanh nghiệp tạo hoặc quản lý tài khoản của riêng họ, doanh nghiệp đó (chủ sở hữu tài khoản) phải tự chấp nhận Điều khoản dịch vụ . Bạn hỗ trợ việc này bằng cách truy xuất và hiển thị ToS, sau đó gọi phương thức termsOfService.accept thay mặt họ sau khi họ đã đồng ý một cách rõ ràng thông qua giao diện của bạn.