คุณสามารถใช้ Accounts API เพื่อจัดการความสัมพันธ์ระหว่างบัญชี Merchant Center กับผู้ให้บริการรายอื่นๆ ความสัมพันธ์คือ การเชื่อมต่ออย่างเป็นทางการที่ช่วยให้ผู้ให้บริการสามารถนำเสนอบริการที่เฉพาะเจาะจงแก่ ธุรกิจของคุณได้ บริการจะกำหนดสิทธิ์และความสามารถที่มอบให้แก่ ผู้ให้บริการ เช่น การจัดการผลิตภัณฑ์หรือการจัดการแคมเปญ เช่น การลิงก์บัญชี Merchant Center กับบัญชี Google Ads จะช่วยให้บัญชี Google Ads ใช้ข้อมูลผลิตภัณฑ์ของคุณเพื่อเรียกใช้แคมเปญโฆษณาได้
ความสัมพันธ์ประกอบด้วยแอตทริบิวต์ต่อไปนี้
- บัญชี Merchant Center ที่รับบริการ
- ผู้ให้บริการ
- บริการหรือชุดบริการที่ให้บริการแก่บัญชี Merchant Center
ชื่อแทน
ผู้ให้บริการสามารถเชื่อมโยงนามแฝงกับบัญชีที่ให้บริการได้ (ซึ่งเทียบเท่ากับฟิลด์ seller_id ที่มีอยู่ในแหล่งข้อมูลบัญชีใน Content API for Shopping) คุณกำหนดชื่อแทนได้โดยใช้ฟิลด์account_id_aliasที่ไม่บังคับภายในทรัพยากรAccountRelationship และใช้เป็นตัวระบุที่กำหนดเอง นามแฝงต้องประกอบด้วยอักขระ 1-50 ตัว
ซึ่งเลือกจากตัวอักษร ASCII, ทศนิยม, ขีดกลาง, ขีดล่าง, จุด หรือ
ตัวหนอน ([A-Za-z0-9_~.-]{1,50})
โครงสร้าง URL สำหรับการเข้าถึงบัญชีโดยใช้นามแฝงคือ
GET /accounts/v1/accounts/{provider}~{account_id_alias}
บริการ
ใน Accounts API บัญชีจะรับบริการต่อไปนี้ได้ คุณสามารถ เพิ่มบริการเหล่านี้ได้หลายรายการในระหว่าง การสร้างบัญชี
การรวบรวมบัญชี: บริการนี้จะลิงก์บัญชีขั้นสูงกับบัญชีอื่น เพื่อให้สิทธิ์เข้าถึงแบบเต็มโดยไม่มีข้อจำกัดแก่บัญชีขั้นสูง โดยปกติแล้ว มาร์เก็ตเพลส ผู้ค้าปลีกที่มีหลายแบรนด์ หรือผู้ค้าปลีกระหว่างประเทศที่ต้องการควบคุมบัญชีที่ซ้อนกันจากส่วนกลางจะใช้บัญชีนี้ หากคุณเป็นแพลตฟอร์มอีคอมเมิร์ซหรือพาร์ทเนอร์ช่องทาง เราขอแนะนำให้ใช้
accountManagementแทน เมื่อสร้างบัญชี โดยใช้การรวบรวมบัญชี คุณต้องละเว้นexternalAccountIdการจัดการแคมเปญ: บริการนี้จำลองลิงก์ระหว่างบัญชี Merchant Center กับบัญชี Google Ads เพื่อให้บัญชี Google Ads มีสิทธิ์เข้าถึงข้อมูลผลิตภัณฑ์และข้อมูลบัญชีที่จำเป็นต่อการเรียกใช้แคมเปญโฆษณา ผู้ให้บริการในกรณีนี้คือ
GOOGLE_ADSและexternalAccountIdคือรหัส ของบัญชี Google Ads นอกจากนี้ยังเสนอการใช้บริการนี้ให้กับบัญชีที่มีอยู่ได้ด้วย
การช็อปปิ้งแบบเปรียบเทียบ: แสดงถึงความสัมพันธ์กับบริการช็อปปิ้งแบบเปรียบเทียบ (CSS) ที่ดำเนินการบัญชี Merchant Center
การจัดการข้อมูลธุรกิจในพื้นที่: แสดงถึงความสัมพันธ์กับผู้จัดการร้านค้าในการจัดการสินค้าคงคลังในร้านและข้อมูลธุรกิจในพื้นที่โดยใช้ Google Business Profile
การจัดการบัญชี: บริการนี้ช่วยให้ผู้ให้บริการดำเนินการด้านการดูแลระบบในบัญชี Merchant Center ได้ เช่น การกำหนดค่าการตั้งค่าบัญชี การจัดการผู้ใช้ หรือการอัปเดตข้อมูลทางธุรกิจ นอกจากนี้ ธุรกิจยังจำกัดการเข้าถึงที่ให้ไว้ได้ด้วย เมื่อใช้ ในระหว่างการสร้างบัญชี บริการนี้จะสร้างบัญชีที่ลิงก์กับผู้ให้บริการ ซึ่ง เป็นแนวทางที่แนะนำสำหรับแพลตฟอร์มอีคอมเมิร์ซและพาร์ทเนอร์ช่อง นอกจากนี้ยังเสนอให้บัญชีที่มีอยู่ได้ด้วย
การจัดการผลิตภัณฑ์: บริการนี้ช่วยให้ผู้ให้บริการจัดการผลิตภัณฑ์ และฟีเจอร์ที่เกี่ยวข้อง เช่น แหล่งข้อมูลและกฎ โดยปกติแล้ว เมื่อเพิ่มในระหว่างการสร้างบัญชี จะเป็นการรวมกับ
accountManagementหรือaccountAggregationนอกจากนี้ยังเสนอการใช้บริการนี้ให้กับบัญชีที่มีอยู่ได้ด้วย
Handshake
หากต้องการสร้างบริการ ทั้งบัญชีที่ให้บริการและบัญชี ที่รับบริการต้องให้สิทธิ์การเชื่อมต่อ กระบวนการให้สิทธิ์นี้ เรียกว่าการแฮนด์เชค
การแฮนด์เชคเป็นกระบวนการ 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 Business Profile) ดูขั้นตอนโดยละเอียดได้ในคำแนะนำในการลิงก์ Google Business Profile
การจัดการบัญชี: สำหรับบริการนี้ กระบวนการแฮนด์เชคปกติ จะมีผลเมื่อใช้
proposeหากเพิ่มบริการระหว่างการสร้างบัญชีโดยใช้createAndConfigureระบบจะอนุมัติโดยอัตโนมัติการจัดการผลิตภัณฑ์: สำหรับบริการนี้ กระบวนการเริ่มต้นการเชื่อมต่อตามปกติ จะมีผล (เสนอโดยฝ่ายหนึ่งและอีกฝ่ายยอมรับ)
สิทธิ์เข้าถึง
บริการแต่ละประเภทจะให้สิทธิ์เข้าถึงระดับหนึ่งแก่ผู้ใช้บริการ ของผู้ให้บริการในบัญชีที่รับบริการ ดังนี้
การรวมบัญชี: บริการนี้ให้สิทธิ์
ADMINโดยสมบูรณ์การจัดการแคมเปญ: บริการนี้ให้สิทธิ์การเข้าถึงแบบจำกัด เพื่อให้บัญชี Google Ads ที่เชื่อมโยงเข้าถึงผลิตภัณฑ์และข้อมูลบัญชีพื้นฐาน ได้
การเปรียบเทียบราคา: บริการนี้ให้
ADMINสิทธิ์เต็มรูปแบบโดยค่าเริ่มต้น อย่างไรก็ตาม ธุรกิจสามารถจำกัดสิทธิ์เข้าถึงที่ให้ไว้ใน Merchant Center ได้การจัดการข้อมูลธุรกิจในพื้นที่: บริการนี้ไม่ได้ให้สิทธิ์เข้าถึงโดยตรง แต่จะช่วยให้ข้อมูลสามารถซิงค์ผลิตภัณฑ์กับบัญชี Merchant Center ได้
สำคัญ: สิทธิ์การเข้าถึงที่อธิบายไว้สำหรับบริการประเภทต่อไปนี้มีผล
เฉพาะกับผู้ให้บริการที่ได้รับอนุมัติเท่านั้น โปรดติดต่อทีมสนับสนุนหากคุณเป็น
ผู้ให้บริการและต้องการใช้ความสามารถนี้ หากคุณได้รับอนุมัติให้ใช้accounts.linkวิธีจัดการผลิตภัณฑ์ใน Content API for Shopping อยู่แล้ว คุณจะใช้บริการนี้ใน Merchant API ได้โดยไม่ต้องขออนุมัติเพิ่มเติม
การจัดการบัญชี: บริการนี้ให้
ADMINสิทธิ์โดยสมบูรณ์โดยค่าเริ่มต้นการจัดการผลิตภัณฑ์: บริการนี้ให้สิทธิ์
ADMINโดยสมบูรณ์ โปรดทราบ ว่าในอนาคต สิทธิ์นี้จะจำกัดไว้เฉพาะสิทธิ์การเข้าถึงที่เกี่ยวข้องกับผลิตภัณฑ์ เท่านั้น
ความสัมพันธ์มีผลกับแพลตฟอร์มของบุคคลที่สามอย่างไร
หากคุณเป็นแพลตฟอร์มของบุคคลที่สามที่จัดการบัญชีในนามของธุรกิจอื่นๆ ต่อไปนี้จะแสดงวิธีที่แนวคิดต่างๆ สอดคล้องกับโครงสร้างบัญชีของคุณ
- ผู้ให้บริการ: บัญชี ขั้นสูง
- บัญชีที่รับบริการ: บัญชี Merchant Center ที่ แสดงถึงธุรกิจที่คุณจัดการ
- บริการ
accountManagement: นี่คือบริการที่แนะนำสำหรับแพลตฟอร์มอีคอมเมิร์ซและพาร์ทเนอร์ช่องทางที่สร้างบัญชีใหม่ในนามของผู้ขาย โดยจะสร้างบัญชีที่ผู้ขายเป็นเจ้าของ ซึ่งลิงก์กับคุณ เพื่อการจัดการ ซึ่งสอดคล้องกับโครงสร้าง Merchant Center ที่ต้องการสำหรับกรณีการใช้งานนี้accountAggregation: บริการนี้จะลิงก์บัญชีขั้นสูงของคุณกับ บัญชีอื่น แม้ว่าระบบจะรองรับ แต่เราไม่แนะนำให้ใช้กับแพลตฟอร์มอีคอมเมิร์ซและพาร์ทเนอร์ช่องทาง
ดูรายละเอียดเกี่ยวกับวิธีตั้งค่าบัญชี ขั้นสูงและลิงก์กับบัญชี Merchant Center ใหม่ได้ที่สร้าง บัญชี