Introducing the Chargebee CLI

Apply credits for an invoice

Open in Postman

Applies a customer's refundable credits to a specified invoice.

You can specify the credit notes to apply, including the amount to apply from each credit note and the time it is applied. If you omit the credit notes, Chargebee applies the available credit notes automatically.

Prerequisites & Constraints

  • The customer must have refundable credits available.
  • The invoice status must be not_paid, payment_due, or posted.

Impacts

Invoice

  • The amount_due decreases by the amount of credits applied.
  • The invoice status:
    • changes to paid if the applied credits fully cover the amount due.
    • remains unchanged if the applied credits only partially cover the amount due.
  • When the invoice becomes paid, paid_at is set to the credit_notes[applied_at] of the application that brought amount_due to zero. If that parameter is omitted, paid_at is the current time.

Credit Notes

The credit note status:

  • changes to refunded if the entire credit_note.amount_available is applied to the invoice.
  • remains refund_due if only part of the credit_note.amount_available is applied.

Implementation Notes

Before calling this API, make sure the following conditions are met:

  • customer.refundable_credits is non-zero.
  • The invoice status is not_paid, payment_due, or posted.
  • The credit_note.customer_id matches the invoice.customer_id.

Sample Request

Open in Postman

Sample Result[JSON]

URL Format

POST https://[site].chargebee.com/api/v2/invoices/{invoice-id}/apply_credits

Input Parameters

comment
optional, string, max chars=300

An internal comment to be added for this operation, to the invoice. This comment is displayed on the Chargebee UI. It is not displayed on any customer-facing Hosted Page or any document such as the Invoice PDF .

credit_notes[0..n]
Parameters for credit_notes. Multiple credit_notes can be passed by specifying unique indices.
pass parameters as credit_notes[<param name>][<idx:0..n>]

Returns

Invoice object

Resource object representing invoice