账单

您可以使用 InvoiceService检索 Google Ads 账号的月度账单。

前提条件

  • 为 Google Ads 账号启用按月账单结算 。如需了解如何使用 Google Ads API 管理结算,请参阅有关账号 结算 设置预算 的指南。
  • 如果已设置,login-customer-id 必须 指定管理 Google Ads 账号的经理账号的客户 ID,您要检索的账单就是针对该 Google Ads 账号的。在 Google Ads 界面中,此 ID 标记为 付款经理账号

检索账单

如需检索账单,您必须请求 InvoiceService.ListInvoices方法 ,并在 ListInvoicesRequest中设置所有必需字段: customer_idbilling_setupissue_yearissue_month

如果您采用合并结算设置,Google Ads API 会返回同一结算设置下的所有客户的账单,而不仅仅是 API 请求中指定的 customer_id 的账单。

customer_id 必须是 Google Ads 广告投放账号。如需获取付款经理账号的所有账单,请针对每个 Google Ads 广告投放账号发送一个请求。

示例如下:

Java

// Issues the request.
ListInvoicesResponse response =
    invoiceServiceClient.listInvoices(
        String.valueOf(customerId),
        ResourceNames.billingSetup(customerId, billingSetupId),
        String.valueOf(oneMonthAgo.getYear()),
        MonthOfYear.valueOf(oneMonthAgo.getMonth().toString()));
      

C#

ListInvoicesResponse response = invoiceServiceClient.ListInvoices(customerId.ToString(),
    ResourceNames.BillingSetup(customerId, billingSetupId),
    // Year must be 2019 or later.
    lastMonthDateTime.Year.ToString("yyyy"),
    lastMonth);
      

PHP

// Issues the request.
$response = $googleAdsClient->getInvoiceServiceClient()->listInvoices(
    ListInvoicesRequest::build(
        $customerId,
        ResourceNames::forBillingSetup($customerId, $billingSetupId),
        // The year needs to be 2019 or later.
        date('Y', $lastMonth),
        MonthOfYear::value(strtoupper(date('F', $lastMonth)))
    )
);
      

Python