POST /subscriptions/{subscription-id}/regenerate_invoice
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 {#PreRequisites}
Before regenerating an invoice, ensure the following conditions are met:
- The Multi-frequency billing feature must be disabled for the site.
- The subscription's current-term invoice must be voided or deleted.
- The subscription
status
must beactive
ornon_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 {#ImpactsOfTheOperation}
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.
Implementation Notes {#ImplNotes}
Before calling this API, perform the following checks:
- Confirm that the subscription
status
isactive
ornon_renewing
. - The invoice regeneration is supported for the current term only. If you're using the
date_from
anddate_to
parameters, ensure that their values fall within the range defined bysubscription.current_term_start
andsubscription.current_term_end
.
Servers
- {protocol}://{site}.{environment}:{port}/api/v2
- {protocol}://{site}-test.{environment}:{port}/api/v2
Path parameters
Name | Type | Required | Description |
---|---|---|---|
subscription-id |
String | Yes |
Request headers
Name | Type | Required | Description |
---|---|---|---|
chargebee-request-origin-device |
String | No |
The device from which the customer has made the request |
Content-Type |
String | Yes |
The media type of the request body.
Default value: "application/x-www-form-urlencoded" |
chargebee-event-webhook |
String | No |
skip only webhooks Possible values:
|
chargebee-business-entity-id |
String | No |
If the site has multiple business entities, you can use this custom HTTP header to specify the business entity for which Chargebee should perform the operation. |
chargebee-event-actions |
String | No |
skip all actions to be done on the events Possible values:
|
chargebee-request-origin-user |
String | No |
The email address of your customer/user. Use this when the email address has only ASCII characters. |
chargebee-request-origin-ip |
String | No |
The IP address of the customer where the request originated |
chargebee-request-origin-user-encoded |
String | No |
The Base64-encoded email address of your customer/user. Use this if the email address has UTF-8 characters. When this header is provided, the header |
chargebee-event-email |
String | No |
skip only emails Possible values:
|
Request body fields
Name | Type | Required | Description |
---|---|---|---|
prorate |
Boolean | No |
Whether the charges should be prorated according to the term specified by |
invoice_immediately |
Boolean | No |
Only applicable when Consolidated Invoicing is enabled for the customer. Set to |
date_from |
Integer | No |
The start date of the period being invoiced. The default value is current_term_start. |
date_to |
Integer | No |
The end date of the period being invoiced. The default value is current_term_end. |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.