ChargebeeAPI

Invoices

An invoice is a commercial document representing a sale of products/services offered by you to a customer. It enumerates all the charges, adjustments, payments, discounts and taxes associated with the sale.

An invoice is said to be a recurring one when it is has at least one charge for a plan or an addon item price. It is a non-recurring one when it has charges for only charge-item prices or one-time charges.

The item prices for any given billing term of a subscription are billed via an invoice at the beginning of the term (unless the charges are left unbilled). However, item prices that belong to metered items are billed at the end of the term via a pending invoice that can close automatically or via an API call. Moreover, when there are no metered items in the subscription, the invoices can still be generated as pending while creating or updating a subscription.

Auto-collection

If auto-collection is enabled, then immediately on invoice generation (or, in case of subscriptions that have create_pending_invoices as true, on invoice closure), the payment method on file is charged:

  • If the payment succeeds, the invoice is marked as paid.
  • On payment failure, the invoice is marked as payment_due and dunning settings are taken into account for payment retries.
  • If no retry attempts are configured, or when retries are exhausted, the invoice is marked as not_paid.
  • the amount due is zero or negative, the invoice is immediately marked as paid and the balance, if any, is added to excess payments for the customer.

Note: If consolidated invoicing is enabled, the attribute subscription_id is unavailable when the invoice has line items from multiple subscriptions. The individual subscription ids are seen under line_items.subscription_id.

Sample InvoiceJSON

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.

payment_owner
optional, string, max chars=50

Payment owner of an invoice

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_item`s 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.

posted

Indicates the payment is not yet collected and will be in this state till the due date to indicate the due period

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.

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.

due_date
optional, timestamp(UTC) in seconds

Due date of the invoice

net_term_days
optional, integer, default=0

Number of days within which the invoice has to be paid

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.

exchange_rate
optional, bigdecimal, min=1E-9, max=999999999.999999999

Exchange rate used for base currency conversion.Note that when converting foreign currency invoices to local currency for VAT purposes, the exchange rates used differ from the base currency exchange rate provided in this field. This is due to regulations set by tax authorities, which require the use of official sources such as European Central Bank rates for local currency conversion.

local_currency_exchange_rate
optional, bigdecimal, min=1E-9, max=999999999.999999999

This parameter represents the exchange rate as a relative price of the base currency that appears as local currency in invoices and credit notes. The local currency exchange rate specifically refers to the exchange rate of a country's currency when converting it to another currency.

For example, if you want to convert US dollars to euros, the local currency exchange rate would be the rate at which you can convert US dollars to euros.

currency_code
required, string, max chars=3

The currency code (ISO 4217 format) for the invoice

local_currency_code
optional, string, max chars=3

The currency code (ISO 4217 format) of the place of supply in which VAT needs to be converted and displayed.

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

sub_total_in_local_currency
optional, in cents, min=0

Invoice subtotal in the currency of the place of supply.

total
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.

total_in_local_currency
optional, in cents, min=0

Total invoice amount in the currency of the place of supply.

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.

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

Amount written off against this invoice.

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_at
optional, timestamp(UTC) in seconds

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

voided_at
optional, timestamp(UTC) in seconds

Timestamp indicating the date & time this invoice got voided.

resource_version
optional, long

The version number of this resource. For every change made to the resource, resource_version is updated with a new timestamp in milliseconds.

updated_at
optional, timestamp(UTC) in seconds

Timestamp indicating when this invoice was last updated. This attribute will be present only if the resource has been updated after 2016-09-28. Note: This value does not change when the following attributes are changed: next_retry_at, dunning_status, has_advance_charges

line_items_next_offset
optional, string, max chars=1000

This attribute is returned only if additional resources are available. Use this value as the input parameter for line_items_offset to retrieve the next set of resources.

Note:

  • Applicable only when Enterprise-scale Invoicing is enabled.
  • Enterprise-scale Invoicing is currently in Private Beta. Please reach out to Chargebee Support to enable this feature.
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.

new_sales_amount
optional, in cents, min=0

The share of the invoice total due to new sales. When first_invoice is true , this attribute is the same as total. However, when the invoice is a consolidated one, then it is the sum of all line_items.amount belonging to a new.

has_advance_charges
optional, boolean

Indicates whether an advance charge is present in this invoice.

term_finalized
required, boolean, default=true

Boolean indicating this invoice line_items terms are finalized or not.

is_gifted
required, boolean, default=false

Boolean indicating this invoice is gifted or not.

generated_at
optional, timestamp(UTC) in seconds

The date when the invoice is finalized. This is the date in the invoice lifecycle when its status becomes any one of the following for the first time: payment_due , posted , or paid. For an invoice with status as pending , this happens when it gets closed.

expected_payment_date
optional, timestamp(UTC) in seconds

The date and time at which dunning should resume automatically for the invoice. This attribute is present only if dunning is currently paused for the invoice. See also: Dunning resumption process.

amount_to_collect
optional, in cents, min=0

Payments that are yet to be collected for the invoice. This is the same value as amount_due

  • the sum of linked_payments[].txn_amount for all linked_payments[] that have txn_status as in_progress.
round_off_amount
optional, in cents, min=0

Indicates the rounded-off amount. For example, if your invoice amount is $99.99, and the amount is rounded off to $100.00, in this case, $100.00 is your invoice amount, $0.01 is the round_off_amount. If there is no round-off amount , it will display 0 .

void_reason_code
optional, string, max chars=100

Reason code for voiding the invoice. Select from a list of reason codes set in the Chargebee app in Settings > Configure Chargebee > Reason Codes > Invoices > Void invoice. Must be passed if set as mandatory in the app. The codes are case-sensitive

deleted
required, boolean

Indicates that this resource has been deleted.

tax_category
optional, string

Specifies the customer's category for the Goods and Services Tax (GST). This field is returned only if you've configured GST for the India region.

vat_number_prefix
optional, string, max chars=10

An overridden value for the first two characters of the full VAT number. Only applicable specifically for customers with billing_address

country as XI (which is United Kingdom - Northern Ireland ).

When you have enabled EU VAT in 2021 or have manually enabled the Brexit configuration, you have the option of setting billing_address

country as XI. That's the code for United Kingdom - Northern Ireland. The first two characters of the VAT number in such a case is XI by default. However, if the VAT number was registered in UK, the value should be GB. Set vat_number_prefix to GB for such cases.

channel
optional, enumerated string

The subscription channel this object originated from and is maintained in.

Possible Enum Values
web

The object was created (and is maintained) for the web channel directly in Chargebee via API or UI.

app_store

The object data is synchronized with data from in-app subscription(s) created in Apple App Store. Direct manipulation of this object via UI or API is disallowed.

play_store

The object data is synchronized with data from in-app subscription(s) created in Google Play Store. Direct manipulation of this object via UI or API is disallowed.

In-App Subscriptions is currently in early access. Contact eap@chargebee.com for more information.

business_entity_id
optional, string, max chars=50

The unique ID of the business entity of this invoice. Depending on whether the invoice was created directly for a customer or for a subscription, this is the business entity of the customer or the subscription respectively.

discounts
optional, list of discount

The list of all deductions applied to the invoice.

taxes
optional, list of tax

The list of taxes applied for this invoice

tax_origin
optional, tax_origin

It represents information about the tax details that are applied to an invoice. Additionally, it specifies the country from which the tax is applied, as well as the relevant tax registration number.

linked_taxes_withheld
optional, list of linked_tax_withheld

Details of tax_withheld against this invoice.

linked_payments
optional, list of invoice_transaction

The list of transactions for this invoice

reference_transactions
optional, list of reference_transaction

A list of up to 20 transactions for this invoice. The list can contain authorizations and payments. Transactions are sorted by creation date in ascending order.

dunning_attempts
optional, list of dunning_attempt

The list of dunning_attempts for this invoice

applied_credits
optional, list of applied_credit

Refundable Credits applied on this invoice.

adjustment_credit_notes
optional, list of created_credit_note

Adjustments created for this invoice

issued_credit_notes
optional, list of created_credit_note

Credit notes issued for this invoice

linked_orders
optional, list of linked_order

The list of orders for this invoice

notes
optional, list of note

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
optional, shipping_address

Shipping address for the invoice.

billing_address
optional, billing_address

Billing address for the invoice.

statement_descriptor
optional, statement_descriptor

Statement descriptor for the invoice.

einvoice
optional, einvoice

An e-invoice or electronic invoice is a structured representation of an invoice that is interoperable between computerized invoicing systems. Depending on the country, e-invoicing can be necessary to meet financial/taxation authority regulations.

site_details_at_creation
optional, site_details_at_creation

It contains site-specific information, including timezone and organisational address.

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

line_items
optional, list of line_item

The list of line items for this invoice

line_item_tiers
optional, list of line_item_tier

The list of tiers applicable for this line item

line_item_discounts
optional, list of line_item_discount

The list of deduction(s) applied for each line item of this invoice

line_item_taxes
optional, list of line_item_tax

The list of taxes applied on line items

line_item_credits
optional, list of line_item_credit

A list of store credits applied to line items.

line_item_addresses
optional, list of line_item_address

The list of addresses used for tax calculation on line items.