Introducing the Better Auth Chargebee plugin: Use it to handle subscriptions, billing, and auth seamlessly.
Chargebeechargebee API

Apply credits for an invoice

Idempotency Supported

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

You can either specify the credit notes to be applied, or let Chargebee apply 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.

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

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