คุณสามารถใช้ 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นอกจากนี้ คุณยังเสนอใช้บริการนี้กับบัญชีที่มีอยู่ได้ด้วย
จับมือ
หากต้องการสร้างบริการ ทั้งบัญชีที่ให้บริการและบัญชีที่รับบริการต้องให้สิทธิ์การเชื่อมต่อ กระบวนการให้สิทธิ์นี้เรียกว่าการจับมือ
การจับมือเป็นกระบวนการ 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 ใหม่ได้ที่สร้าง บัญชี