以下範例說明如何使用現有的付款資料 ID 建立新的帳單設定。如先前所述,系統也會建立名為「My New Payments Account」的新付款帳戶。
BillingSetupbsetup=BillingSetup.newBuilder().setPaymentsAccountInfo(PaymentsAccountInfo.newBuilder().setPaymentsAccountName("My New Payments Account").setPaymentsProfileId("1234-5678-9012").build()).setStartTimeType(TimeType.NOW).build();BillingSetupOperationop=BillingSetupOperation.newBuilder().setCreate(bsetup).build();try(BillingSetupServiceClientbillingSetupServiceClient=googleAdsClient.getBillingSetupServiceClient()){MutateBillingSetupResponseresponse=billingSetupServiceClient.mutateBillingSetup(Long.toString(customerId),op);}
如果這是首次為 Google Ads 帳戶新增帳單設定,系統會使用參照的付款資料,為客戶註冊帳單服務。
[null,null,["上次更新時間:2025-08-26 (世界標準時間)。"],[[["\u003cp\u003eA billing setup links a Google Ads account with a Payments account, determining billing responsibility for ad costs.\u003c/p\u003e\n"],["\u003cp\u003eYou can link billing setups to new or existing Payments accounts, with options for consolidated billing.\u003c/p\u003e\n"],["\u003cp\u003eBilling setups undergo an approval process and can have different statuses like pending, approved, or cancelled.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve and manage billing setup details, including cancellation of pending setups, using the Google Ads API.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003eBillingSetup\u003c/code\u003e resource to connect your Google Ads account with a payment method and manage budgets.\u003c/p\u003e\n"]]],[],null,["# Billing Setup\n\nA billing setup is an account-level link between a Google Ads account and a Payments\naccount (also known as an [invoice\nsetup](//support.google.com/google-ads/answer/2375371)), which effectively\ndetermines who is billed for costs incurred by the billing setup's account\nbudgets. Each Payments account corresponds to a single invoice.\n\nAbout Payments accounts\n-----------------------\n\nEach [`BillingSetup`](/google-ads/api/reference/rpc/v21/BillingSetup) identifies a Payments account\nthat gets invoiced for costs incurred by its account budgets. This Payments\naccount is associated with a [Payments\nprofile](//support.google.com/google-ads/answer/7268503) that is ultimately\nresponsible for charges.\n\n[Billing setups](/google-ads/api/reference/rpc/v21/BillingSetup) contain both a\n[`payments_account`](/google-ads/api/reference/rpc/v21/BillingSetup#payments_account) field and a\ngroup of\n[`payments_account_info`](/google-ads/api/reference/rpc/v21/BillingSetup#payments_account_info)\nfields that identify the Payments account is in use, including the following:\n\n- [`payments_account_info.payments_account_id`](/google-ads/api/reference/rpc/v21/BillingSetup.PaymentsAccountInfo#payments_account_id): A 16-digit ID used to identify the Payments account associated with the billing setup.\n- [`payments_account_info.payments_account_name`](/google-ads/api/reference/rpc/v21/BillingSetup.PaymentsAccountInfo#payments_account_name): The name of the Payments account associated with the billing setup. This name is printed on monthly invoices.\n- [`payments_account_info.payments_profile_id`](/google-ads/api/reference/rpc/v21/BillingSetup.PaymentsAccountInfo#payments_profile_id): A 12-digit ID used to identify the Payments profile associated with the billing setup.\n\nIf a Payments account is eligible for\n[consolidated billing](//support.google.com/google-ads/answer/2375371), then\nmultiple Google Ads accounts can be grouped in the same invoice by setting their\nbilling setups to use the same underlying Payments account.\n\nCreate new billing setups\n-------------------------\n\nYou can link new billing setups to existing Payments accounts or ones created\nat the same time.\n\n### Use an existing Payments account\n\nTo link with an *existing* Payments account, set\n[`payments_account`](/google-ads/api/reference/rpc/v21/BillingSetup#payments_account) to the\nresource ID of a valid Payments account. However, *don't* modify\n[`payments_account_info`](/google-ads/api/reference/rpc/v21/BillingSetup#payments_account_info).\n\nYou can list available payment accounts with the\n[`PaymentsAccountService.ListPaymentsAccounts`\nmethod](/google-ads/api/reference/rpc/v21/PaymentsAccountService/ListPaymentsAccounts). The\n`PaymentsAccounts` returned depend on the manager account you use for\nauthentication.\n\nFor each `PaymentsAccount`, the ID of its [paying\nmanager](//support.google.com/google-ads/answer/9703430) is in the\n[`paying_manager_customer`](/google-ads/api/reference/rpc/v21/PaymentsAccount#paying_manager_customer)\nfield.\n\n### Use a new Payments account\n\nTo link with a new Payments account, set the following fields in\n[`payments_account_info`](/google-ads/api/reference/rpc/v21/BillingSetup#payments_account_info)\n(*don't* set [`payments_account`](/google-ads/api/reference/rpc/v21/BillingSetup#payments_account)):\n\n- [`payments_account_name`](/google-ads/api/reference/rpc/v21/BillingSetup.PaymentsAccountInfo#payments_account_name)\n- [`payments_profile_id`](/google-ads/api/reference/rpc/v21/BillingSetup.PaymentsAccountInfo#payments_profile_id)\n\n| **Note:** `payments_account` and `payments_account_info` will both be populated in subsequent retrievals of the billing setup.\n\nThe following example shows how to create a new billing setup from an existing\nPayments profile ID. As previously indicated, this also creates a new Payments\naccount with the name `My New Payments Account`. \n\n BillingSetup bsetup = BillingSetup.newBuilder()\n .setPaymentsAccountInfo(PaymentsAccountInfo.newBuilder()\n .setPaymentsAccountName(\"My New Payments Account\")\n .setPaymentsProfileId(\"1234-5678-9012\")\n .build())\n .setStartTimeType(TimeType.NOW)\n .build();\n\n BillingSetupOperation op = BillingSetupOperation.newBuilder().setCreate(bsetup).build();\n\n try (BillingSetupServiceClient billingSetupServiceClient = googleAdsClient\n .getBillingSetupServiceClient()) {\n\n MutateBillingSetupResponse response =\n billingSetupServiceClient.mutateBillingSetup(Long.toString(customerId), op);\n }\n\nIf this is the first billing setup being added to a Google Ads account, this will\neffectively sign the customer up for billing using the referenced Payments\nprofile.\n\nBilling setup status\n--------------------\n\nNew [`BillingSetup`](/google-ads/api/reference/rpc/v21/BillingSetup) instances are subject to\napproval before they go into effect. Until then, their\n[`status`](/google-ads/api/reference/rpc/v21/BillingSetup#status) is in a\n[`PENDING`](/google-ads/api/reference/rpc/v21/BillingSetupStatusEnum.BillingSetupStatus#pending)\nstate.\n\nA [`BillingSetup`](/google-ads/api/reference/rpc/v21/BillingSetup) can be in one of the following\n[`status`](/google-ads/api/reference/rpc/v21/BillingSetup#status):\n\n| [Billing Setup Status](/google-ads/api/reference/rpc/v21/BillingSetupStatusEnum.BillingSetupStatus) | Description |\n|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `PENDING` | Pending approval. |\n| `APPROVED_HELD` | Approved but the corresponding first budget has not. This can only occur for billing setups configured for monthly invoicing. |\n| `APPROVED` | Setup was approved. |\n| `CANCELLED` | Setup was cancelled by the user prior to approval. |\n\nRetrieve an account's billing setup\n-----------------------------------\n\nLike most other entities in the Google Ads API, a\n[`BillingSetup`](/google-ads/api/reference/rpc/v21/BillingSetup) is fetched by querying the\n[`GoogleAdsService.SearchStream`](/google-ads/api/reference/rpc/v21/GoogleAdsService/SearchStream)\nusing a Google Ads Query Language query that specifies which fields to return.\n\nOnce you obtain a reference to a [`BillingSetup`](/google-ads/api/reference/rpc/v21/BillingSetup),\nyou can use it to create an\n[`AccountBudgetProposal`](/google-ads/api/reference/rpc/v21/AccountBudgetProposal) as described in\n[Account Budget](/google-ads/api/docs/billing/account-budgets).\n\nCancel a pending billing setup\n------------------------------\n\nA [`BillingSetup`](/google-ads/api/reference/rpc/v21/BillingSetup) that has not yet taken effect can\nbe canceled using the remove operation. Billing setups can be canceled only if\ntheir [`status`](/google-ads/api/reference/rpc/v21/BillingSetup#status) are\n[`PENDING`](/google-ads/api/reference/rpc/v21/BillingSetupStatusEnum.BillingSetupStatus#pending)\nor if they are [`APPROVED`](/google-ads/api/reference/rpc/v21/BillingSetupStatusEnum.BillingSetupStatus#approved)\nto start some time in the future."]]