Knowledge Center

Knowledge Center > API > REST API > REST API Reference > Transactions > Invoice and collect

Invoice and collect

Generates invoices and collects payments for a specified account.

This method can generate invoices and collect payments on the invoices generated, 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 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.

Request

  • Production: POST https://api.zuora.com/rest/v1/operations/invoice-collect
  • API Sandbox: POST https://apisandbox-api.zuora.com/rest/v1/operations/invoice-collect

Request parameters

accountKey

required

Customer account ID or account number

invoiceId

optional

The ID 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 both invoiceDate and invoiceTargetDate are ignored.

paymentGateway

optional

 

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.

invoiceDate

optional

The invoice date that should appear on the invoice being generated, in yyyy-mm-dd format. If invoiceId is not specified and this value is omitted, the current date is used by default.

invoiceTargetDate

optional

The date, in yyyy-mm-dd format, through which charges on this account will be processed when generating a new invoice.If invoiceId is not specified and this value is omitted, the current date is used by default.

Response

success

Contains true if successful, otherwise false.

processId

Internal process ID to assist Zuora support. Only returned if success is false.

reasons

Information on one or more reasons for the result. Only returned if success is false.

code

Eight-digit numeric error code

message

Description of the error

invoices

Information on one or more invoices associated with this operation:

invoiceId

Invoice ID

invoiceNumber

Invoice number

invoiceAmount

Invoice amount

paymentId

Payment ID

amountCollected

Payment amount applied

Notes

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

Examples

HTTP/JSON request:

POST https://api.zuora.com/rest/v1/operations/invoice-collect

JSON request:

{
  "accountKey":"4028925a4cb74ec9014cb7520fc00005", 
  "invoiceId":"4028925a4cb74ec9014cb7540988002e", 
  "paymentGateway”:"TestGateway"
}
JSON response:
{
    "invoices": [
        {
            "invoiceId": "4028925a4cb74ec9014cb7540988002e",
            "invoiceNumber": "INV00000091",
            "invoiceAmount": 801.73
        }
    ],
    "paymentId": "402892053e100406013e1024ab7c00e3",
    "amountCollected": 801.73,
    "success": true
}

CURL request:

##
## Invoice Collection
##
echo
echo "=============Generate Invoice and Collect Payment============="
echo
curl -i -k -H "apiAccessKeyId:$USER_NAME" -H "apiSecretAccessKey:$PASSWORD" -H "Content-Type:application/json" -H "Accept:application/json" -d '
{
    "accountKey":"A00000067",
    "invoiceDate":"2013-01-01",
    "invoiceTargetDate":"2013-01-01",
    "invoiceId":"id of invoice to be collected, null for all"
}
' -X POST $BASE_URL/v1/operations/invoice-collect

JSON response:

{
    "invoices": [
        {
            "invoiceId": "4028925a4cb74ec9014cb7540988002e",
            "invoiceNumber": "INV00000091",
            "invoiceAmount": 801.73
        }
    ],
    "paymentId": "402892053e100406013e1024ab7c00e3",
    "amountCollected": 801.73,
    "success": true
}
Last modified
10:42, 7 Feb 2016

Tags

Classifications

(not set)