帳單設定是 Google Ads 帳戶與付款帳戶 (又稱月結單設定) 之間的帳戶層級連結,可有效決定要向誰收取帳單設定帳戶預算產生的費用。每個付款帳戶會對應一份月結單。
關於付款帳戶
每個 BillingSetup 都會識別出一個付款帳戶,該帳戶會收到帳戶預算產生的費用月結單。這個付款帳戶與付款資料相關聯,最終負責支付費用。
帳單設定包含 payments_account 欄位和一組 payments_account_info 欄位,用於識別使用的付款帳戶,包括:
payments_account_info.payments_account_id: 16 位數的 ID,格式為以連字號分隔的字串 (例如"1234-5678-9012-3456"),用於識別與帳單設定相關聯的付款帳戶。payments_account_info.payments_account_name:與帳單設定相關聯的付款帳戶名稱。這個名稱會印在月結單上。payments_account_info.payments_profile_id: 12 位數 ID,格式為以連字號分隔的字串 (例如"1234-5678-9012"),用於識別與帳單設定相關聯的付款資料。
如果付款帳戶符合合併帳單資格,只要將多個 Google Ads 帳戶的帳單設定設為使用同一個基礎付款帳戶,這些帳戶就會合併在同一份月結單中。
建立新的帳單設定
您可以將新的帳單設定連結至現有付款帳戶,或同時建立的帳戶。
使用現有的付款帳戶
如要連結現有的付款帳戶,請將 payments_account 設為有效付款帳戶的資源名稱 (例如 customers/{customer_id}/paymentsAccounts/{payments_account_id})。不過,請不要修改 payments_account_info。
您可以使用 PaymentsAccountService.ListPaymentsAccounts 方法列出可用的付款帳戶。傳回的 PaymentsAccount 物件取決於您用於驗證的管理員帳戶。
每個 PaymentsAccount 的付款管理員資源名稱位於 paying_manager_customer 欄位中。
使用新的付款帳戶
如要連結至新的付款帳戶,請在 payments_account_info 中設定下列欄位 (請勿設定 payments_account):
以下範例說明如何使用現有的付款資料 ID 建立新的帳單設定。如先前所述,這也會建立名為「My New Payments Account」的新付款帳戶。
BillingSetup billingSetup =
BillingSetup.newBuilder()
.setPaymentsAccountInfo(
PaymentsAccountInfo.newBuilder()
.setPaymentsAccountName("My New Payments Account")
.setPaymentsProfileId("1234-5678-9012")
.build())
.setStartTimeType(TimeTypeEnum.TimeType.NOW)
.build();
BillingSetupOperation operation =
BillingSetupOperation.newBuilder().setCreate(billingSetup).build();
try (BillingSetupServiceClient billingSetupServiceClient =
googleAdsClient.getBillingSetupServiceClient()) {
MutateBillingSetupResponse response =
billingSetupServiceClient.mutateBillingSetup(
Long.toString(customerId), operation);
}
如果這是首次為 Google Ads 帳戶新增帳單設定,系統會使用參照的付款資料,為客戶註冊帳單服務。
帳單設定狀態
新的 BillingSetup 執行個體須先經過核准,才會生效。在此之前,他們的 status 處於 PENDING 狀態。
BillingSetup 可含有下列其中一個 status 值:
BillingSetupStatus |
說明 |
|---|---|
PENDING |
待審核。 |
APPROVED_HELD |
已核准,但對應的第一個預算尚未核准。只有設定為月結的帳單設定才會發生這種情況。 |
APPROVED |
設定已獲准。 |
CANCELLED |
使用者在核准前取消了設定。 |
擷取帳戶的帳單設定
與 Google Ads API 中的大多數其他實體一樣,BillingSetup 是透過查詢 GoogleAdsService.Search 或 GoogleAdsService.SearchStream 擷取,並使用 Google Ads 查詢語言 (GAQL) 查詢指定要傳回的欄位:
SELECT
billing_setup.resource_name,
billing_setup.id,
billing_setup.status,
billing_setup.payments_account,
billing_setup.payments_account_info.payments_account_id,
billing_setup.payments_account_info.payments_account_name,
billing_setup.payments_account_info.payments_profile_id,
billing_setup.payments_account_info.payments_profile_name,
billing_setup.start_date_time,
billing_setup.end_date_time,
billing_setup.end_time_type
FROM billing_setup
取得 BillingSetup 的參照後,即可如「帳戶預算」一文所述,使用該參照建立 AccountBudgetProposal。
取消待處理的帳單設定
如要取消尚未生效的 BillingSetup,請傳送 BillingSetupOperation,並將 remove 欄位設為帳單設定的資源名稱 (customers/{customer_id}/billingSetups/{billing_setup_id})。只有在帳單設定的 status 為 PENDING,或APPROVED在未來某個時間開始時,才能取消帳單設定。