ChargebeeAPI

Invoices

Invoices are statements containing charges, adjustments and any discounts for a subscription specific to a term. For every subscription a draft invoice (upcoming invoice) is used to track all the charges, credits and adjustments for the current term.

Generally, an invoice is closed at start of the next term. However, cancellation and other such operations on subscription may trigger premature closing. While closing the invoice, in addition to recurring charges, credits and coupons are applied to calculate the final amount that is due.

When invoice is closed, an attempt to charge the credit card is made. If the payment succeeds, it is marked as paid. If the payment fails, the invoice is marked as payment_due and retry settings are taken into account. If no retry attempts are configured, the invoice is marked as not_paid. If the amount due is zero or negative, the invoice is immediately marked as paid and the balance if any is carried forward to the next term of the invoice.

Note: If consolidated invoicing is enabled, the attribute invoice.subscription_id should not be used (as it will not be present if the invoice has lines from multiple subscriptions). Instead to know the related subscriptions, their line_items subscription_id attribute should be referred.

Sample InvoiceJSON

API Index URL

https://[site].chargebee.com/api/v1/invoices

Invoices attributes

id
required, string, max chars=50

The invoice number. Acts as a identifier for invoice and typically generated sequentially.

customer_id
required, string, max chars=50

The identifier of the customer this invoice belongs to.

subscription_id
optional, string, max chars=50

The identifier of the subscription this invoice belongs to. Note: When consolidated invoicing is enabled, you have to refer to line_items subscription_id to identify the subscriptions associated with this invoice. However, it is important to avoid using this attribute if the invoice includes charges from multiple subscriptions, as it will be null in such cases.

recurring
required, boolean, default=true

Boolean indicating whether this invoice belongs to a subscription

status
required, enumerated string

Current status of this invoice.

Possible Enum Values
paid

Indicates a paid invoice.

payment_due

Indicates the payment is not yet collected and is being retried as per retry settings.

not_paid

Indicates the payment is not made and all attempts to collect is failed.

voided

Indicates a voided invoice.

pending

The invoice is yet to be closed (sent for payment collection). An invoice is generated with this status when it has line items that belong to items that are metered or when the subscription.create_pending_invoicesattribute is set to true. The invoice is yet to be closed (sent for payment collection). All invoices are generated with this status when Metered Billing is enabled for the site.

start_date
required, timestamp(UTC) in seconds

Start date of the invoice.

end_date
optional, timestamp(UTC) in seconds

The document date displayed on the invoice PDF. By default, it has the same value as the effective date of the action that created the invoice (subscription creation, update, or invoice creation). This date can be backdated (set to a value in the past) while performing the actions. Backdating an invoice is done for reasons such as booking revenue for a previous date or when the subscription or non-recurring charge is effective as of a past date. However, if the invoice is created as pending , and if the site is configured to set invoice dates to the date of closing, then upon invoice closure, this date is changed to the invoice closing date.

po_number
optional, string, max chars=100

Purchase Order Number for this invoice

vat_number
optional, string, max chars=20

VAT/ Tax registration number of the customer. Learn more

price_type
required, enumerated string, default=tax_exclusive

The price type of the invoice.

Possible Enum Values
tax_exclusive

All amounts in the document are exclusive of tax.

tax_inclusive

All amounts in the document are inclusive of tax.

currency_code
required, string, max chars=3

The currency code (ISO 4217 format) for the invoice

tax
required, in cents, min=0

Total tax amount for this invoice

sub_total
required, in cents, min=0

The sum of all the line item amounts minus the sum of all line item discounts. In other words, this is the sum of all line_items[].amount

amount
optional, in cents, min=0

Invoiced amount displayed in cents; that is, a decimal point is not present between the whole number and the decimal part. For example, $499.99 is displayed as 49999, and so on.

amount_due
optional, in cents, min=0

The unpaid amount that is due on the invoice. This is calculated as: total

amount_adjusted
optional, in cents, default=0, min=0

Total adjustments made against this invoice.

amount_paid
optional, in cents, min=0

Payments collected successfully for the invoice. This is the sum of linked_payments[].txn_amount for all linked_payments[] that have txn_status as success.

optional, timestamp(UTC) in seconds

Timestamp indicating the date & time this invoice got paid.

credits_applied
optional, in cents, default=0, min=0

Total credits applied against this invoice.

dunning_status
optional, enumerated string

Current dunning status of the invoice.

Possible Enum Values
in_progress

Dunning is still in progress.

exhausted

Maximum number of attempts have been made.

stopped

Dunning has stopped for this invoice.

success

Payment successfully collected during dunning process.

next_retry
optional, timestamp(UTC) in seconds

Timestamp indicating when will the next attempt to collect payment for this invoice occur.

first_invoice
optional, boolean

Boolean indicating the first invoice raised for the subscription. In the case of a non-recurring invoice, it indicates the first invoice raised for the customer.

discounts

The list of all deductions applied to the invoice.

taxes

The list of taxes applied for this invoice

linked_transactions

The list of transactions for this invoice

linked_orders

The list of orders for this invoice

notes

The list of notes that appear on the invoice PDF sent to the customer. Notes that come from a specific resource related to the invoice have entity_type and entity_id defined. There can be up to two notes in this array for which entity_type and entity_id are not defined:

shipping_address

Shipping address for the invoice.

billing_address

Billing address for the invoice.

GROUPED:line_items

Line items and their associated details including taxes, discounts, and pricing tiers.

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