ChargebeeAPI

Regenerate an invoice

Idempotency Supported
Try in API Explorer

Use this API to regenerate the current-term invoice for a subscription. The new invoice will contain non-metered charges from the current term and metered charges from the previous term. If a customer was billed incorrectly, because of a wrong plan, price, or tax configuration, you can first void or delete the erroneous invoice, update the subscription or usage records, and then run this operation to issue the corrected invoice.

Prerequisites & Constraints

Before regenerating an invoice, ensure the following conditions are met:

  • The subscription's current-term invoice must be voided or deleted.
  • The subscription status must be active or non_renewing.
  • There should be no unbilled charges for non-metered subscribed items for the current term.
  • There should be no unbilled charges for metered items for the previous term.
  • The subscription must not have any advance invoices

Impacts

Current-Term Invoice

Chargebee does not modify the voided or deleted invoice for the current term. Instead, it creates a new invoice.

The new invoice includes:

  • Subscription-item charges for the current term.
  • Usage charges from the previous term.

The new invoice does not include:

  • One-time addon charges, including mandatory addons.
  • Ad hoc or other one-time charges from the voided or deleted invoice.
  • Unbilled charges.
  • Usage charges for the current term.

If every charge for the current-term has a value of zero, and your site is configured to hide zero-value line items, the invoice is not generated.

If you delete the original invoice, the associated usage data is also deleted. To ensure accurate billing for metered items, add or bulk import usage records before regenerating the invoice.

Payment Collection

If auto-collection is on, Chargebee attempts to collect payment for the regenerated invoice. If the payment collection fails, the invoice regeneration also fails.

Note: Chargebee applies any customer balances, such as unapplied payment from the voided invoice, before attempting to collect the remaining amount.

Order

Any orders associated with the invoice are regenerated automatically when the invoice is regenerated.

Implementation Notes

Before calling this API, perform the following checks:

  • Confirm that the subscription status is active or non_renewing.
  • The invoice regeneration is supported for the current term only. If you're using the date_from and date_to parameters, ensure that their values fall within the range defined by subscription.current_term_start and subscription.current_term_end.

Sample Request

URL Format

POST https://[site].chargebee.com/api/v2/subscriptions/{subscription-id}/regenerate_invoice

Input Parameters

date_from
optional, timestamp(UTC) in seconds

The start date of the period being invoiced. The default value is current_term_start .

date_to
optional, timestamp(UTC) in seconds

The end date of the period being invoiced. The default value is current_term_end .

prorate
optional, boolean

Whether the charges should be prorated according to the term specified by date_from and date_to. Should not be passed without date_from and date_to .

invoice_immediately
optional, boolean

Only applicable when Consolidated Invoicing is enabled for the customer. Set to false to leave the current term charge for the subscription as unbilled. Once you have done this for all suitable subscriptions of the customer, call Create an invoice for unbilled charges to invoice them.

Returns

invoiceInvoice object

Resource object representing invoice

Resource object representing unbilled_charge