管理帳戶關係

你可以使用 Accounts API,管理 Merchant Center 帳戶與其他服務供應商之間的關係。關係是一種正式連結,可讓供應商為您的業務提供特定服務。服務會定義授予供應商的權限和功能,例如產品管理或廣告活動管理。舉例來說,將 Merchant Center 帳戶連結至 Google Ads 帳戶後,Google Ads 帳戶就能使用產品資料放送廣告活動。

關係由下列屬性組成:

  • 接收服務的 Merchant Center 帳戶
  • 服務供應商
  • 提供給 Merchant Center 帳戶的服務或服務組合

別名

服務供應商可以將別名與服務的帳戶建立關聯 (這相當於 Content API for Shopping 中 account 資源中的 seller_id 欄位)。您可以使用 AccountRelationship 資源中的選用 account_id_alias 欄位指派別名,做為自訂 ID。別名必須由 1 到 50 個字元組成,可使用 ASCII 字母、十進位數字、連字號、底線、半形句號或波浪號 ([A-Za-z0-9_~.-]{1,50})。

使用別名存取帳戶的網址結構為 GET /accounts/v1/accounts/{provider}~{account_id_alias}。

服務

在 Accounts API 中,帳戶可以接收下列服務。您可以在建立帳戶時新增許多這類服務。

  • 帳戶匯總:這項服務 (accountAggregation) 會將多重客戶進階帳戶連結至子帳戶,授予進階帳戶完整、不受限制的存取權,並在 Merchant Center 使用者介面中顯示子帳戶。建立新的子帳戶時,Merchant Center UI 會自動將商店建構工具 (電子商務平台)、管道合作夥伴、市集、多品牌零售商和國際零售商的帳戶轉換為進階帳戶,並提供 accountAggregation。如果您是代理商,請改用 accountManagement。使用帳戶匯總建立帳戶時,必須省略 externalAccountId。

  • 廣告活動管理:這項服務會建立 Merchant Center 帳戶和 Google Ads 帳戶之間的連結,讓 Google Ads 帳戶存取放送廣告活動所需的產品和帳戶資料。在本例中,服務供應商為 GOOGLE_ADS,externalAccountId 則是 Google Ads 帳戶的 ID。您也可以向現有帳戶推薦這項服務。

  • 這項服務可讓您在放送商業媒體聯播網廣告活動時,建立合作夥伴專屬的產品篩選器。
  • 目前,您必須使用 Accounts 子 API 的 Alpha 版。
  • 必須加入特定 GMC 許可清單,才能使用這項功能。

詳情請洽詢 Google Ads 帳戶管理團隊。

  • 購物比較:代表與經營 Merchant Center 帳戶的購物比較服務 (CSS) 之間的關係。

  • 本地商家資訊管理:代表與商店經理的關係,可使用 Google 商家檔案管理店面商品目錄資料和商家資訊。

  • 帳戶管理:這項服務 (accountManagement) 可讓供應商對獨立外部 Merchant Center 帳戶執行管理動作,例如調整帳戶設定、管理使用者或更新商家資訊。商家也可以限制授予的存取權。在建立帳戶時使用這項服務,會建立連結至供應商的獨立帳戶。也可以向現有帳戶提出。使用這類服務的代理商,可以在代理商專用 Merchant Center 中查看管理的帳戶。商店建構工具和管道合作夥伴可使用 Merchant API,透過 accountManagement 擷取所管理商家的資訊。

  • 產品管理:供應商可透過這項服務管理產品和相關功能,例如資料來源和規則。在建立帳戶時新增,通常會與 accountManagement 或 accountAggregation 搭配使用。您也可以向現有帳戶推薦這項服務。

  • UCP 結帳管理 (v1alpha,存取權有限):ucpCheckoutManagement 服務可讓核准的服務供應商,代表商家管理 UCP 結帳整合、設定和計畫參與。這項服務只能由現有的 Merchant Center 帳戶提議或核准。

    注意:UCP 結帳功能為 Alpha 版功能,僅開放部分商家使用。如要進一步瞭解服務供應商和 UCP 結帳,請參閱服務供應商適用的 Merchant Center。

畫面中有兩個人在握手

如要建立服務,提供服務的帳戶和接收服務的帳戶都必須授權連線。這項授權程序稱為「交握」。

交握程序分為兩個步驟:

  1. 其中一方提議建立服務連結。
  2. 另一方核准或拒絕提案。

提案獲准後,服務就會獲得核准,並視為完全建立。服務供應商獲得的任何存取權,現在都會授予符合資格的使用者 (請參閱下方的「存取權」)。

請注意,建立、拒絕或核准提案的使用者,必須在啟動程序的帳戶上具備ADMIN 存取權。因此,如果服務供應商提出服務,提出提案的使用者必須是服務供應商帳戶的ADMIN,而接受或拒絕提案的使用者必須是接收帳戶的ADMIN。

以下範例說明如何提議帳戶服務:

Java

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.AccountService;
import com.google.shopping.merchant.accounts.v1.AccountServicesServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountServicesServiceSettings;
import com.google.shopping.merchant.accounts.v1.ProductsManagement;
import com.google.shopping.merchant.accounts.v1.ProposeAccountServiceRequest;
import shopping.merchant.samples.utils.Authenticator;

/** This class demonstrates how to propose a service to an existing Merchant Center account. */
public class ProposeServiceSample {

  public static void proposeService(long accountId, long providerId, String externalAccountId)
      throws Exception {

    // Obtains OAuth token based on the user's configuration.
    // The user that authenticates should have access to the account.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    AccountServicesServiceSettings accountServicesServiceSettings =
        AccountServicesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Calls the API and catches and prints any network failures/errors.
    try (AccountServicesServiceClient accountServicesServiceClient =
        AccountServicesServiceClient.create(accountServicesServiceSettings)) {

      // The service to be proposed.
      // This sample shows how to propose product management.
      // For more information about the different services, see:
      // https://developers.google.com/merchant/api/guides/accounts/services
      AccountService accountService =
          AccountService.newBuilder()
              .setProductsManagement(ProductsManagement.newBuilder().build())
              .setExternalAccountId(externalAccountId)
              .build();

      String accountName =
          AccountName.newBuilder().setAccount(String.valueOf(accountId)).build().toString();

      ProposeAccountServiceRequest request =
          ProposeAccountServiceRequest.newBuilder()
              .setParent(accountName)
              .setProvider("accounts/" + providerId)
              .setAccountService(accountService)
              .build();

      System.out.println("Sending Propose Service request:");
      AccountService response = accountServicesServiceClient.proposeAccountService(request);

      System.out.println("Proposed Service below");
      System.out.println(response);
    } catch (Exception e) {
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    // The ID of the account to propose the service to.
    long accountId = 123L;
    // This is the provider ID of the e-commerce platform.
    long providerId = 456L;
    // An external ID that uniquely identifies the account service.
    String externalAccountId = "ext-acc-id-123";
    proposeService(accountId, providerId, externalAccountId);
  }
}

PHP

require_once __DIR__ . '/../../../../vendor/autoload.php';
require_once __DIR__ . '/../../../Authentication/Authentication.php';
require_once __DIR__ . '/../../../Authentication/Config.php';

use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\AccountAggregation;
use Google\Shopping\Merchant\Accounts\V1\AccountService;
use Google\Shopping\Merchant\Accounts\V1\Client\AccountServicesServiceClient;
use Google\Shopping\Merchant\Accounts\V1\ProposeAccountServiceRequest;

/**
 * This class demonstrates how to propose an account service.
 */
class ProposeAccountServiceSample
{
    /**
     * A helper function to create the account name string.
     *
     * @param string $accountId The ID of the account.
     *
     * @return string The account name has the format: `accounts/{account_id}`
     */
    private static function toAccountName(string $accountId): string
    {
        return sprintf('accounts/%s', $accountId);
    }

    /**
     * Proposes a new account service.
     *
     * @param array $config The configuration data used for authentication and
     *     getting the account ID.
     * @param string $providerId The ID of the provider account.
     */
    public static function proposeAccountService(
        array $config,
        string $providerId
    ): void {
        // Gets the OAuth credentials to make the request.
        $credentials = Authentication::useServiceAccountOrTokenFile();

        // Creates options containing credentials for the client to use.
        $options = ['credentials' => $credentials];

        // Creates a client.
        $accountServicesServiceClient = new AccountServicesServiceClient($options);

        // Calls the API and catches and prints any network failures/errors.
        try {
            $accountAggregation = new AccountAggregation();
            $accountService = (new AccountService())
                ->setAccountAggregation($accountAggregation);

            $request = (new ProposeAccountServiceRequest())
                ->setParent(self::toAccountName($config['accountId']))
                ->setProvider(self::toAccountName($providerId))
                ->setAccountService($accountService);

            print "Sending Propose AccountService request\n";
            $response = $accountServicesServiceClient->proposeAccountService($request);
            print "Proposed AccountService below\n";
            print $response->serializeToJsonString(true) . PHP_EOL;
        } catch (ApiException $e) {
            printf("An error has occurred: %s%s", $e->getMessage(), PHP_EOL);
        }
    }

    /**
     * Helper to execute the sample.
     */
    public function callSample(): void
    {
        $config = Config::generateConfig();

        // Update this with the Merchant Center provider ID you want to get the
        // relationship for.
        $providerId = 111;
        self::proposeAccountService($config, $providerId);
    }
}

// Run the script
$sample = new ProposeAccountServiceSample();
$sample->callSample();

Python

"""This class demonstrates how to propose an account service."""

from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import AccountAggregation
from google.shopping.merchant_accounts_v1 import AccountService
from google.shopping.merchant_accounts_v1 import AccountServicesServiceClient
from google.shopping.merchant_accounts_v1 import ProposeAccountServiceRequest

_ACCOUNT = configuration.Configuration().read_merchant_info()
_PARENT = f"accounts/{_ACCOUNT}"


def propose_account_service(provider_id: int) -> None:
  """Proposes an account service.

  Args:
    provider_id: The Merchant Center ID of the provider.
  """
  # Gets OAuth Credentials.
  credentials = generate_user_credentials.main()

  # Creates a client.
  client = AccountServicesServiceClient(credentials=credentials)

  # Creates the provider resource name from the provider ID.
  provider = f"accounts/{provider_id}"

  # Creates an AccountService object.
  # For this request, only `account_aggregation` is needed.
  account_service = AccountService()
  account_service.account_aggregation = AccountAggregation()

  # Creates the request.
  request = ProposeAccountServiceRequest(
      parent=_PARENT,
      provider=provider,
      account_service=account_service,
  )

  # Makes the request and catches and prints any error messages.
  try:
    print("Sending Propose AccountService request")
    response = client.propose_account_service(request=request)
    print("Proposed AccountService below")
    print(response)
  except RuntimeError as e:
    print(e)


if __name__ == "__main__":
  # Update this with the Merchant Center provider ID you want to get the
  # relationship for.
  provider_id_ = 111
  propose_account_service(provider_id_)

服務專屬握手行為

以下說明各項服務的特定交握要求:

  • 帳戶匯總:這項服務只能在建立帳戶時設定。服務供應商應為進階帳戶,且服務會自動獲得核准,因為進階帳戶的使用者對建立的帳戶具有完整的 ADMIN 存取權。

  • 購物比較:使用 createAndConfigure 建立帳戶時,新增這項服務會自動獲得核准。

  • 廣告活動管理:雖然這項作業遵循正常的交握程序,但提案是在一個系統 (例如 Google Ads) 中提出,核准則是在另一個系統 (例如 Merchant Center 或透過 Merchant API) 中完成。

  • 本地商家資訊管理:這項服務會以專屬方法提出握手要求,並在其他系統 (例如 Google 商家檔案) 中完成核准。詳細步驟請參閱連結 Google 商家檔案指南。

  • 帳戶管理:使用 propose 時,這項服務適用一般交握程序。如果是在使用 createAndConfigure 建立帳戶時新增服務,系統會自動核准。

  • 產品管理:這項服務適用一般交握程序 (由一方提出,另一方接受)。

  • UCP 結帳管理 (v1alpha,存取權有限):商家可透過服務供應商入口網站中由 Google 代管的帳戶連結對話方塊,或使用標準交握程序 (propose,接著 approve) 完成交握。如需整合詳細資料,請參閱 Merchant Center 服務供應商說明文件。

存取權

每種服務類型都會為服務供應商的使用者,提供一定程度的受服務帳戶存取權:

  • 帳戶匯總:這項服務提供完整的 ADMIN 權限。

  • 廣告活動管理:這項服務提供受限的存取權,允許相關聯的 Google Ads 帳戶存取產品和基本帳戶資訊。

  • 購物比較:這項服務預設提供完整的 ADMIN 權限。不過,商家可以限制在 Merchant Center 中授予的存取權。

  • 本地商家資訊管理:這項服務不提供直接存取權。而是讓產品資訊與 Merchant Center 帳戶同步。

重要事項:下列服務類型的存取權僅適用於核准的服務供應商。如果您是服務供應商,且想使用這項功能,請與我們的支援團隊聯絡。如果您先前已獲准在 Content API for Shopping 中使用 accounts.link 方法管理產品,則可在 Merchant API 中使用這項服務,不需進一步核准。

  • 帳戶管理:這項服務預設提供完整的 ADMIN 權限。

  • 產品管理:這項服務提供完整的ADMIN權限。請注意,日後這項權限將僅限於產品相關存取權。

  • UCP 結帳管理 (v1alpha,存取權有限):這項服務提供完整的 ADMIN 權限。請注意,日後這項權限將僅限於 UCP 結帳相關存取權。

第三方平台的關係套用方式

如果您是代表其他商家管理帳戶的第三方平台,以下說明不同概念如何對應至您的帳戶結構:

  1. 服務供應商:您的進階帳戶。
  2. 接受服務的帳戶:代表你所管理商家的 Merchant Center 帳戶。
  3. 服務:
    • accountAggregation:由開店平台 (電子商務平台)、管道合作夥伴、市集和多品牌零售商使用,代表商家建立新的子帳戶。Merchant Center 使用者介面會自動將商店建構工具和管道合作夥伴設為具有 accountAggregation 的進階帳戶,讓他們在 Merchant Center 使用者介面中查看及管理子帳戶。
    • accountManagement:代理商建立或連結商家擁有的獨立客戶帳戶時,會使用這個帳戶,並可在代理商專用 Merchant Center 中查看。其他類型的服務供應商則使用 Merchant API 中的 accounts.list 方法,查看已連結帳戶的資訊。

如要進一步瞭解如何設定進階帳戶,並連結至新的 Merchant Center 帳戶,請參閱「建立帳戶」。