應付憑據

您可以使用 InvoiceService 擷取 Google Ads 帳戶的月結單。

必要條件

  • 為 Google Ads 帳戶啟用月結。請參閱帳戶帳單設定預算指南,瞭解如何使用 Google Ads API 管理帳單。
  • 如果已設定,login-customer-id 必須指定管理員帳戶的客戶 ID,該帳戶負責管理您要擷取月結單的 Google Ads 帳戶。在 Google Ads 使用者介面中,這會標示為「付款管理員」

擷取月結單

如要擷取月結單,您必須要求 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)))
    )
);