คุณใช้ Accounts API เพื่อจัดการความสัมพันธ์ระหว่างบัญชี Merchant Center กับผู้ให้บริการรายอื่นๆ ได้ ความสัมพันธ์คือการเชื่อมต่ออย่างเป็นทางการที่ช่วยให้ผู้ให้บริการสามารถเสนอบริการที่เฉพาะเจาะจงแก่ธุรกิจของคุณได้ บริการจะกำหนดสิทธิ์และความสามารถที่มอบให้แก่ผู้ให้บริการ เช่น การจัดการผลิตภัณฑ์หรือการจัดการแคมเปญ ตัวอย่างเช่น การลิงก์บัญชี Merchant Center กับบัญชี Google Ads จะช่วยให้บัญชี Google Ads ใช้ข้อมูลผลิตภัณฑ์เพื่อแสดงแคมเปญโฆษณาได้
ความสัมพันธ์ประกอบด้วยแอตทริบิวต์ต่อไปนี้
- บัญชี Merchant Center ที่รับบริการ
- ผู้ให้บริการ
- บริการหรือชุดบริการที่มอบให้กับบัญชี Merchant Center
ชื่อแทน
ผู้ให้บริการสามารถเชื่อมโยงชื่อแทนกับบัญชีที่ให้บริการ (ซึ่งเทียบเท่ากับช่อง seller_id ที่อยู่ในทรัพยากร account ใน 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 บัญชีจะรับบริการต่อไปนี้ได้ คุณสามารถเพิ่มบริการเหล่านี้ได้หลายรายการในระหว่างการสร้างบัญชี
การรวมบัญชี: บริการนี้ (
accountAggregation) จะลิงก์บัญชีขั้นสูงแบบหลายลูกค้ากับบัญชีย่อย ซึ่งจะให้สิทธิ์เข้าถึงแบบไม่จำกัดแก่บัญชีขั้นสูง และทำให้บัญชีย่อยปรากฏใน UI ของ Merchant Center UI ของ Merchant Center จะเปลี่ยนบัญชีเป็นบัญชีขั้นสูงโดยอัตโนมัติด้วยaccountAggregationสำหรับเครื่องมือสร้างร้านค้า (แพลตฟอร์มอีคอมเมิร์ซ) พาร์ทเนอร์ช่องทาง มาร์เก็ตเพลส ผู้ค้าปลีกหลายแบรนด์ และผู้ค้าปลีกระหว่างประเทศเมื่อสร้างบัญชีย่อยใหม่ หากคุณเป็นเอเจนซี ให้ใช้accountManagementแทน เมื่อคุณสร้างบัญชีโดยใช้การรวมบัญชี คุณต้องละเว้นexternalAccountIdการจัดการแคมเปญ: บริการนี้จะจำลองการลิงก์ระหว่างบัญชี Merchant Center กับบัญชี Google Ads เพื่อให้บัญชีโฆษณาเข้าถึงข้อมูลผลิตภัณฑ์และข้อมูลบัญชีที่จำเป็นต่อการแสดงแคมเปญโฆษณาได้ ผู้ให้บริการในกรณีนี้คือ
GOOGLE_ADSและexternalAccountIdคือรหัสของบัญชี Google Ads นอกจากนี้ คุณยังเสนอบริการนี้ให้กับบัญชีที่มีอยู่ได้ด้วย
- บริการนี้ช่วยให้สร้างตัวกรองผลิตภัณฑ์เฉพาะพาร์ทเนอร์ได้เมื่อใช้งานแคมเปญเครือข่ายสื่อสำหรับธุรกิจอีคอมเมิร์ซ
- ในตอนนี้ คุณต้องใช้ API ย่อยของบัญชีเวอร์ชันอัลฟ่า
- การใช้ฟีเจอร์นี้ต้องมีการเพิ่ม GMC ลงในรายการที่อนุญาตโดยเฉพาะ
โปรดติดต่อทีมดูแลลูกค้า Google Ads เพื่อขอรายละเอียดเพิ่มเติม
การช็อปปิ้งแบบเปรียบเทียบสินค้า: แสดงถึงความสัมพันธ์กับบริการช็อปปิ้งแบบเปรียบเทียบสินค้า (CSS) ที่ดำเนินการบัญชี Merchant Center
การจัดการข้อมูลในพื้นที่: แสดงถึงความสัมพันธ์กับผู้จัดการร้านค้าสำหรับการจัดการสินค้าคงคลังในร้านและข้อมูลโดยใช้ Google Business Profile
การจัดการบัญชี: บริการนี้ (
accountManagement) ช่วยให้ผู้ให้บริการสามารถดำเนินการด้านการดูแลระบบในบัญชี Merchant Center ภายนอกแบบสแตนด์อโลนได้ เช่น การกำหนดการตั้งค่าบัญชี การจัดการผู้ใช้ หรือการอัปเดตข้อมูลทางธุรกิจ นอกจากนี้ ธุรกิจยังจำกัดสิทธิ์เข้าถึงที่ให้ไว้ได้ด้วย เมื่อใช้ในระหว่างการสร้างบัญชี บริการนี้จะสร้างบัญชีแบบสแตนด์อโลนที่ลิงก์กับผู้ให้บริการ นอกจากนี้ยังเสนอให้ใช้กับบัญชีที่มีอยู่ได้ด้วย เอเจนซีที่ใช้บริการประเภทนี้จะเห็นบัญชีที่ตนจัดการใน Merchant Center สำหรับเอเจนซี ผู้สร้างร้านค้าและพาร์ทเนอร์ช่องทางสามารถใช้ Merchant API เพื่อดึงข้อมูลเกี่ยวกับผู้ขายที่ตนจัดการผ่านaccountManagementการจัดการผลิตภัณฑ์: บริการนี้ช่วยให้ผู้ให้บริการจัดการผลิตภัณฑ์และฟีเจอร์ที่เกี่ยวข้อง เช่น แหล่งข้อมูลและกฎได้ เมื่อเพิ่มในระหว่างการสร้างบัญชี โดยทั่วไปจะใช้ร่วมกับ
accountManagementหรือaccountAggregationนอกจากนี้ คุณยังเสนอบริการนี้ให้กับบัญชีที่มีอยู่ได้ด้วยการจัดการการชำระเงินผ่าน UCP (
v1alpha, สิทธิ์เข้าถึงแบบจำกัด): บริการucpCheckoutManagementช่วยให้ผู้ให้บริการที่ได้รับอนุมัติสามารถจัดการการผสานรวม การตั้งค่า และการเข้าร่วมโปรแกรมการชำระเงินผ่าน UCP ในนามของผู้ขายได้ บริการนี้เสนอหรืออนุมัติได้โดยบัญชี Merchant Center ที่มีอยู่เท่านั้นหมายเหตุ: การชำระเงินด้วย UCP เป็นฟีเจอร์เวอร์ชันอัลฟ่าที่มีการจำกัดการเข้าถึง ดูข้อมูลเพิ่มเติมเกี่ยวกับผู้ให้บริการและจุดชำระเงิน UCP ใน Merchant Center สำหรับผู้ให้บริการ
การจับมือ
หากต้องการสร้างบริการ ทั้งบัญชีที่ให้บริการและบัญชีที่รับบริการต้องให้สิทธิ์การเชื่อมต่อ กระบวนการให้สิทธิ์นี้เรียกว่าการแฮนด์เชค
การแฮนด์เชคมี 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ระบบจะอนุมัติโดยอัตโนมัติการจัดการผลิตภัณฑ์: สำหรับบริการนี้ จะใช้กระบวนการแฮนด์เชคปกติ (เสนอโดยฝ่ายหนึ่ง ตามด้วยการยอมรับจากอีกฝ่าย)
การจัดการการชำระเงินของ UCP (
v1alpha, สิทธิ์เข้าถึงแบบจำกัด): สำหรับบริการนี้ ผู้ขายสามารถทำแฮนด์เชคให้เสร็จสมบูรณ์ผ่านกล่องโต้ตอบการลิงก์บัญชีที่โฮสต์โดย Google ในพอร์ทัลของผู้ให้บริการ หรือใช้กระบวนการแฮนด์เชคมาตรฐาน (proposeตามด้วยapprove) ดูรายละเอียดการผสานรวมได้ที่เอกสารประกอบของผู้ให้บริการ Merchant Center
สิทธิ์เข้าถึง
บริการแต่ละประเภทจะให้สิทธิ์เข้าถึงในระดับหนึ่งแก่ผู้ใช้ของผู้ให้บริการในบัญชีที่ได้รับบริการ ดังนี้
การรวมบัญชี: บริการนี้ให้สิทธิ์
ADMINเต็มรูปแบบการจัดการแคมเปญ: บริการนี้ให้สิทธิ์การเข้าถึงแบบจำกัด ซึ่งช่วยให้บัญชี Google Ads ที่เชื่อมโยงเข้าถึงผลิตภัณฑ์และข้อมูลบัญชีพื้นฐานได้
การช็อปปิ้งแบบเปรียบเทียบสินค้า: โดยค่าเริ่มต้น บริการนี้จะให้สิทธิ์
ADMINแบบเต็มรูปแบบ อย่างไรก็ตาม ธุรกิจสามารถจำกัดสิทธิ์เข้าถึงที่ให้ไว้ใน Merchant Center ได้การจัดการข้อมูลธุรกิจในพื้นที่: บริการนี้ไม่มีสิทธิ์เข้าถึงโดยตรง แต่จะช่วยให้ข้อมูลสามารถซิงค์ผลิตภัณฑ์กับบัญชี Merchant Center ได้
สำคัญ: สิทธิ์การเข้าถึงที่อธิบายไว้สำหรับประเภทบริการต่อไปนี้ใช้ได้กับผู้ให้บริการที่ได้รับอนุมัติเท่านั้น โปรดติดต่อทีมสนับสนุนหากคุณเป็นผู้ให้บริการและต้องการใช้ความสามารถนี้ หากคุณได้รับอนุมัติให้ใช้เมธอด accounts.link สำหรับการจัดการผลิตภัณฑ์ใน Content API for Shopping อยู่แล้ว คุณจะใช้บริการนี้ใน Merchant API ได้โดยไม่ต้องขออนุมัติเพิ่มเติม
การจัดการบัญชี: โดยค่าเริ่มต้น บริการนี้จะให้สิทธิ์
ADMINแบบเต็มรูปแบบการจัดการผลิตภัณฑ์: บริการนี้ให้สิทธิ์
ADMINอย่างเต็มรูปแบบ โปรดทราบว่าในอนาคต เราจะจำกัดสิทธิ์นี้ไว้เฉพาะสิทธิ์การเข้าถึงที่เกี่ยวข้องกับผลิตภัณฑ์เท่านั้นการจัดการการชำระเงินด้วย UCP (
v1alpha, สิทธิ์เข้าถึงแบบจำกัด): บริการนี้ให้สิทธิ์ADMINแบบเต็มรูปแบบ โปรดทราบว่าในอนาคต สิทธิ์นี้จะจำกัดไว้เฉพาะสิทธิ์การเข้าถึงที่เกี่ยวข้องกับการชำระเงินของ UCP เท่านั้น
ความสัมพันธ์มีผลกับแพลตฟอร์มของบุคคลที่สามอย่างไร
หากคุณเป็นแพลตฟอร์มของบุคคลที่สามที่จัดการบัญชีในนามของธุรกิจอื่นๆ ข้อมูลต่อไปนี้จะแสดงให้เห็นว่าแนวคิดต่างๆ สอดคล้องกับโครงสร้างบัญชีของคุณอย่างไร
- ผู้ให้บริการ: บัญชีขั้นสูงของคุณ
- บัญชีที่รับบริการ: บัญชี Merchant Center ที่แสดงถึงธุรกิจที่คุณจัดการ
- บริการ
accountAggregation: ใช้โดยเครื่องมือสร้างร้านค้า (แพลตฟอร์มอีคอมเมิร์ซ) พาร์ทเนอร์ช่องทาง มาร์เก็ตเพลส และผู้ค้าปลีกหลายแบรนด์ที่สร้างบัญชีย่อยใหม่ในนามของผู้ขาย UI ของ Merchant Center จะกำหนดค่าเครื่องมือสร้างร้านค้าและพาร์ทเนอร์ช่องทางเป็นบัญชีขั้นสูงโดยอัตโนมัติด้วยaccountAggregationซึ่งช่วยให้พาร์ทเนอร์ดูและจัดการบัญชีย่อยใน UI ของ Merchant Center ได้accountManagement: ใช้โดยเอเจนซีที่สร้างหรือลิงก์กับบัญชีลูกค้าแบบสแตนด์อโลนที่ผู้ขายเป็นเจ้าของ ซึ่งสามารถดูได้ใน Merchant Center สำหรับเอเจนซี ผู้ให้บริการประเภทอื่นๆ จะใช้เมธอดaccounts.listใน Merchant API เพื่อดูข้อมูลบัญชีที่ลิงก์
ดูรายละเอียดเกี่ยวกับวิธีตั้งค่าบัญชีขั้นสูงและลิงก์กับบัญชี Merchant Center ใหม่ได้ที่สร้างบัญชี