---
title: "Invoice and collect"
method: POST
path: "/v1/operations/invoice-collect"
tags: ["Operations"]
---

# Invoice and collect

`POST /v1/operations/invoice-collect`

Generates and posts invoices and credit memos, and collects payments for posted invoices. Credit memos are only available if you have the Invoice
Settlement feature enabled and negative charges exist. Credit memos will not be applied to invoices. If draft invoices and credit memos exist when you run
this operation, this operation will post the invoices and credit memos. Note that draft credit memos created from an invoice or a product rate plan charge
will not be posted.

You can use this operation to generate invoices and collect payments on the posted invoices, or else simply collect payment on a specified
existing invoice. The customer's default payment method is used, and the full amount due is collected. The operation depends on the parameters you specify.

* To generate one or more new invoices for that customer and collect payment on the generated and other unpaid invoice(s), leave the `invoiceId` field empty. 
* To collect payment on an existing invoice, specify the invoice ID. 

The operation is atomic; if any part is unsuccessful, the entire operation is rolled back. 

When an error occurs, gateway reason codes and error messages are returned the error response of this operation. The following items are some gateway response code examples. 

* Orbital: `05 Do Not Honor`, `14 Invalid Credit Card Number` 
* Vantiv: `301 Invalid Account Number`, `304 Lost/Stolen Card`   
* CyberSource2: `202 Expired card`, `231 Invalid account number`

For more reason code information, see the corresponding payment gateway documentation.

### Notes 

Timeouts may occur when using this method on an account that has an extremely high number of subscriptions.

### Multiple Currencies limitation

When the  `invoiceId` field is not specified in the request, the "Invoice and collect" operation generates invoices and then attempts to collect payment. 
If the account has the <a href="https://docs.zuora.com/en/zuora-billing/bill-your-customer/leverage-advanced-capabilities/flexible-billing/multiple-currencies/multiple-currencies-overview/enable-multiple-currencies"
target="_blank">Multiple Currencies </a> feature enabled and has subscriptions in currencies that differ from the account's default currency, 
the operation returns a validation error. This occurs because the payment is created using the account's default currency, which may not match the currency of
all generated invoices.

### Workaround
To collect invoices with currencies that differ from the account currency, specify the `invoiceId`. If the invoice already exists, pass the specific `invoiceId` in the request body. The API correctly handles collection for a 
specific invoice regardless of its currency.

## Headers

- `Idempotency-Key` string
- `Accept-Encoding` string
- `Content-Encoding` string
- `Zuora-Track-Id` string
- `Zuora-Entity-Ids` string
- `Zuora-Org-Ids` string
- `Zuora-Version` string

## Request body

- POSTInvoiceCollectType
  - `accountKey` string, required — Customer account ID or account number.
  - `documentDate` string, date — The date that should appear on the invoice and credit memo being generated, in `yyyy-mm-dd` format. If this field is omitted and `invoiceId` is not specified, the current date is used by default. **Note:** The credit memo is only available if you have the Invoice Settlement feature enabled. **Note**: This field is available only if you are on the latest Zuora API version, or you set the `Zuora-Version` request header to `215.0` or [a later available version](https://developer.zuora.com/v1-api-reference/api-versions/#minor-version).
  - `invoiceId` string — The ID or number of an existing invoice for which to collect payment using the account's default payment method. If this value is specified, no new invoice is generated, and the following fields are ignored: - `invoiceDate` and `invoiceTargetDate` (if the Zuora minor API version is 214.0 or earlier) - `documentDate` and `targetDate` (if the Zuora minor API version is 215.0 or [a later available version](https://developer.zuora.com/v1-api-reference/api-versions/#minor-version))
  - `paymentGateway` string — The name of the gateway that will be used for the payment. Must be a valid gateway name and the gateway must support the specific payment method. If a value is not specified, the default gateway on the Account will be used.
  - `targetDate` string, date — The date through which to calculate charges on this account if an invoice or a credit memo is generated, in `yyyy-mm-dd` format. If this field is omitted and `invoiceId` is not specified, the current date is used by default. This field is available only if you are on the latest Zuora API version, or you set the `Zuora-Version` request header to `215.0` or [a later available version](https://developer.zuora.com/v1-api-reference/api-versions/#minor-version). **Note:** The credit memo is only available if you have the Invoice Settlement feature enabled.
  - `paymentMethodId` string — The unique identifier of the payment method.

## Response `200`

OK

- POSTInvoiceCollectResponseType
  - `amountCollected` number, double — Payment amount applied.
  - `creditMemos` POSTInvoiceCollectCreditMemosType[] — Information on one or more credit memos associated with this operation.
    - `id` string — The ID of the credit memo.
    - `totalAmount` number, double — The amount of the credit memo.
    - `memoNumber` string — The unique identification number of the credit memo.
  - `invoices` POSTInvoiceCollectInvoicesType[] — Information on one or more invoices associated with this operation.
    - `invoiceAmount` string, decimal — The amount of the invoice.
    - `invoiceId` string — The ID of the invoice.
    - `invoiceNumber` string — The unique identification number of the invoice.
  - `paymentId` string — Payment ID.
  - `success` boolean — Returns `true` if the request was processed successfully.

## Other responses

- `500` — Internal Server Error
- `4XX` — Request Errors

---

[API](https://skmtc.dev/zuora/apis/api-reference.md) · [All operations](https://skmtc.dev/zuora/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/zuora/api-reference/revisions/d11e237f3e54/schema)
