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.
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:
paid
.payment_due
and dunning settings are taken into account for payment retries. not_paid
. 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
.
{
"adjustment_credit_notes": [],
"amount_adjusted": 0,
"amount_due": 0,
"amount_paid": 2000,
"amount_to_collect": 0,
"applied_credits": [],
"base_currency_code": "USD",
"billing_address": {
"first_name": "John",
"last_name": "Mathew",
"object": "billing_address",
"validation_status": "not_validated"
},
"credits_applied": 0,
"currency_code": "USD",
"customer_id": "__test__KyVkkWS1xLskm8",
"date": 1517463749,
"deleted": false,
"due_date": 1517463749,
"dunning_attempts": [],
"exchange_rate": 1,
"first_invoice": true,
"has_advance_charges": false,
"id": "__demo_inv__1",
"is_gifted": false,
"issued_credit_notes": [],
"line_items": [
{
"amount": 2000,
"customer_id": "__test__KyVkkWS1xLskm8",
"date_from": 1517463749,
"date_to": 1517463749,
"description": "SSL Charge USD Monthly",
"discount_amount": 0,
"entity_id": "ssl-charge-USD",
"entity_type": "charge_item_price",
"id": "li___test__KyVkkWS1xLt9LF",
"is_taxed": false,
"item_level_discount_amount": 0,
"object": "line_item",
"pricing_model": "flat_fee",
"quantity": 1,
"tax_amount": 0,
"tax_exempt_reason": "tax_not_configured",
"unit_amount": 2000
}
],
"linked_orders": [],
"linked_payments": [
{
"applied_amount": 2000,
"applied_at": 1517463750,
"txn_amount": 2000,
"txn_date": 1517463750,
"txn_id": "txn___test__KyVkkWS1xLtFiG",
"txn_status": "success"
}
],
"net_term_days": 0,
"new_sales_amount": 2000,
"object": "invoice",
"paid_at": 1517463750,
"price_type": "tax_exclusive",
"recurring": false,
"resource_version": 1517463750000,
"round_off_amount": 0,
"shipping_address": {
"city": "Walnut",
"country": "US",
"first_name": "John",
"last_name": "Mathew",
"object": "shipping_address",
"state": "California",
"state_code": "CA",
"validation_status": "not_validated",
"zip": "91789"
},
"status": "paid",
"sub_total": 2000,
"tax": 0,
"term_finalized": true,
"total": 2000,
"updated_at": 1517463750,
"write_off_amount": 0
}
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. 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. 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.
linked_payments[].txn_amount
for all linked_payments[]
that have txn_status
as success
. total
- amount_paid
- sum of applied_credits.applied_amount
- sum of adjustment_credit_notes.cn_total
- sum of linked_taxes_withheld.amount
. line_items[].amount
- the sum of all line_item_discounts[].discount_amount
. 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. 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. 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_due
- the sum of linked_payments[].txn_amount
for all linked_payments[]
that have txn_status
as in_progress
. billing_address
country
as XI
(which is United Kingdom - Northern Ireland).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. 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:
invoice_note
parameter for various endpoints in the API that also create invoices. For example, creating a subscription, creating an invoice, and closing a pending invoice.tax_withheld
against this invoice. Creates an invoice for charge-items and one-time charges. The item prices must belong to items of type
charge
.
One-time charges are represented in an invoice as line_items
with entity_type
adhoc
.
Unique ID of the customer this invoice should be created for. Either this or subscription_id
must be provided.
The invoice is linked to the same business entity as this customer.
Unique ID of the subscription this invoice should be created for. Either this or customer_id
must be provided.
The invoice is linked to the same business entity as this subscription.
true
to remove the general note from this invoice. taxes
and
line_item_taxes
are computed based on the tax configuration as of this date. The date should not be more than one calendar month into the past. For example, if today is 13th January, then you cannot pass a value that is earlier than 13th December. Pause dunning for the specified invoice until expected_payment_date
. Chargebee cancels all configured payment collection retry attempts and dunning email notifications for the invoice until expected_payment_date
.
This operation is only permitted for an invoice that meets all the following conditions:
payment_due
.auto_collection
set to on
.Unless you resume dunning for the invoice, Chargebee attempts to collect payment on the expected_payment_date
. If payment collection fails, the next action is taken as follows:
expected_payment_date
is within the dunning period for the invoice, Chargebee resumes any dunning retries and email notifications that remain after the pause period, and not attempt the retries or notifications that were canceled during the pause period.expected_payment_date
is after the dunning period for the invoice, the final action configured in Billing is initiated for the invoice and, if applicable, for the subscription.The date and time at which dunning should resume.
See also: Dunning resumption process.
An internal comment to add to the invoice for this operation. This comment is displayed on the Chargebee Billing UI.
Note: This comment does not appear on any customer-facing hosted pages or documents, such as the invoice PDF.
Immediately resumes dunning for the specified invoice.
This operation is only permitted for an invoice with a status of payment_due
and for which dunning was previously paused.
An internal comment to add to the invoice for this operation. This comment is displayed on the Chargebee Billing UI.
Note: This comment does not appear on any customer-facing hosted pages or documents, such as the invoice PDF.
Imports an invoice into Chargebee Billing. This endpoint allows you to import an invoice from external systems, such as accounting software, into Chargebee.
Caution: Importing Current-Term Invoices
To ensure accurate proration for any changes to the subscription in the current term, only import one current term invoice. Chargebee considers only the first imported invoice for the current term when calculating proration. If there are multiple invoices for the current term in the source system, consolidate them into a single invoice before importing it into Chargebee.
billing_address
country
as XI
(which is United Kingdom - Northern Ireland).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. The API applies excess payments to an invoice. Once an excess payment is applied, the invoice.amount_due
is recalculated. The invoice status
changes to either paid
or payment_due
depending on how much excess payment is applied to the invoice amount.
For example, if you have an excess payment of $25.00, and the invoice to which you want to apply this excess payment has a balance of $50. Once you apply this excess payment, the invoice status changes to paid
, and invoice.amount_due
is adjusted to $25.00.
Updates the quantity
for metered
line_items
of an invoice to reflect the latest usage data.
Note: This operation is done automatically while closing the invoice.
This API applies available credits to an invoice. After credits are applied, invoice.amount_due
is recalculated. The invoice status changes to either paid
or payment_due
depending on how much credit is applied to the invoice amount.
Lists all the Invoices.
linked_payments[].txn_amount
for all linked_payments[]
that have txn_status
as success
. total
- amount_paid
- sum of applied_credits.applied_amount
- sum of adjustment_credit_notes.cn_total
- sum of linked_taxes_withheld.amount
. updated_at
. This attribute will be present only if the resource has been updated after 2016-09-28. It is advisable when using this filter, to pass the sort_by
input parameter as updated_at
for a faster response. status
, see message
. Possible values are : scheduled, skipped, in_progress, success, failed, registered Gets the invoice as PDF. The returned URL is secure and allows download. The URL will expire in 60 minutes.
Download the e-invoice in both XML and PDF formats. The response consists of a download
object for each format. The XML format follows the structure as per Peppol BIS Billing v3.0.
Note
status
is success
.cbc:EmbeddedDocumentBinaryObject
, which is the Base64-encoded version of the PDF.invoice_id
or the payment_reference_number[number]
to retrieve the PRN. Adds a one-time charge to a pending invoice. A one-time charge is a charge that is added ad hoc to the invoice and does not represent a predefined item price. It appears in the invoice as a line_item
of entity_type
adhoc
.
This endpoint is used when metered billing is enabled and it adds a charge-item price to a pending
invoice. To collect the accumulated charges by closing the invoice, call Close a pending invoice.
Invoices for a subscription are created with a pending
status
when the subscription has create_pending_invoices
attribute set to true
. This API call finalizes a pending
invoice. Any refundable_credits
and excess_payments
for the customer are applied to the invoice, and any payment due is collected automatically if auto_collection
is on
for the customer.
This operation can be automated by using a site setting. Moreover, the automation can be overridden at the customer and subscription level.
true
to remove the general note from this invoice. payment_due
associated with the app_store
and play_store
channels.This API is used to collect payments for payment_due
and not_paid invoices
. If no payment methods are present for the customer or if the payment is unsuccessful, the corresponding error will be thrown.
Pass authorization_transaction_id
to capture the already blocked funds to collect payments. Note that if the invoice due amount is greater than the authorized amount, the invoice status is returned as payment_due
.
Use this API to record an offline payment for the invoice. If the payment covers the full outstanding amount, the invoice status changes to Paid.
PAID Invoices
When the entire due amount is recorded as a payment, the invoice status is updated to Paid. However, if only a partial amount is recorded as an offline payment, the due amount is reduced, but the invoice status does not change.
PAYMENT_DUE, NOT_PAID & POSTED INVOICES
When the full due amount is recorded as payment, then the invoice status will change to Paid. If a partial amount is recorded as an offline payment, the due amount will be reduced while the invoice status remains unchanged.
What happens if I try to record a payment that exceeds the invoice amount?
The system does not allow recording a payment amount greater than the invoice's outstanding balance.
The idempotency key provided has already been used for a different request. Use a new idempotency key or ensure the endpoint matches the original request signature. 422 - unable_to_process_request
This API is idempotent. To ensure idempotent behavior, include a custom header named chargebee-idempotency-key with the POST request. If this key is not unique, the Chargebee API returns this error.
Provide a unique idempotency key with the request options to perform an idempotent request.
Operation not supported as the invoice is in Paid, Pending, or Voided state. 409 - invalid_invoice_state
Payments can only be recorded if the invoice has an outstanding due amount. This API cannot be used for invoices with statuses of Paid, Voided, or Pending (Draft Invoice).
Operation not supported as the collectable amount for this invoice is zero. 409 - record_payment_not_supported
Payments can only be accepted if the invoice amount is greater than zero. Attempting to record a payment against an invoice with zero value results in this error.
Use this API with an invoice that has an amount greater than zero.
Records tax_withheld
by the customer against the invoice specified. This operation is allowed only when all of the following conditions are true:
invoice
does not have a linked_taxes_withheld
record associated with it already.invoice.amount_due
is greater than zero.invoice.status
is one of the following: payment_due
, not_paid
, or posted
.Removes a linked_taxes_withheld
record from the invoice
specified. This operation is allowed only when all of the following conditions are true:
invoice.status
is one of the following: payment_due
, not_paid
, or posted
.adjustment_credit_notes
associated with the invoice.issued_credit_notes
associated with the invoice.Refunds the invoice. The refund request is processed via the payment gateway originally used to charge the customer. You can choose to either make a full refund for the entire amount or make many partial refunds until you reach the total amount charged for the invoice. The API returns an error if an attempt is made to:
If the refund transaction succeeds, a credit_note
capturing this refund detail is created for the invoice.
transaction
s, and not already refunded.
Note: Any linked_taxes_withheld
associated with the invoice cannot be refunded via this operation. Refunds the invoice. The refund is provided against the following in order of precedence:
linked_payments
linked_taxes_withheld
linked_payments
Example
Consider an invoice with the following payments and tax withheld.
When recording a refund worth $40, the refund amount is split as follows:
For payments made via online transactions, the refund request is processed via the payment gateway originally used to charge the customer.
Tip
If the order of precendence described above does not work for your use case, and you want to provide a refund against online linked_payments
first, use the Refund an invoice API.
This API removes payments applied to an invoice. Once the applied payment is removed, the invoice status returns to not_paid
or payment_due
. The removed payment is then added to the customer's excess payment balance.
This API removes a credit note attached to an invoice. When you remove a credit note from an invoice, the invoice status returns to not_paid
.
Note: You cannot remove a credit note from an invoice if it has already been refunded.
Voids the specified invoice. Any payments must be removed from the invoice before voiding it.
proration
enabled, no prorated credits are issued. invoice_id
field of said usages. However, before this is done, a usage PDF is generated and saved to the invoice as an attachment. Deletes the specified invoice. Any payments must be removed from the invoice before deleting it.
All associated usages are permanently deleted on deleting an invoice. If you want to regenerate such an invoice, add or bulk import usages before invoice regeneration.
proration
enabled, no prorated credits are issued. This API allows you to update the invoice Billing/Shipping address, VAT and PO number. During this operation if Billing Info (Billing Address, vat_number), Shipping info and PO number are not already present in the system the data will be added. If data is already present, the existing values will be replaced. If info is present in the system, but not passed as part of the request, the info will not be removed from the system.
Note: Incase, tax is already applied will now vary due to address change, you cannot update the address. You cannot update the VAT Number if the billing address is not present in the API request.This will update the invoice only, it won't change the corresponding customer/subscription details.
billing_address
country
as XI
(which is United Kingdom - Northern Ireland).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. payment_due
.This endpoint is used to send an e-invoice for invoice.
To support cases like TDS and invoice edits, we need to stop auto e-invoice sending and be able to send e-invoices manually.
This endpoint schedules e-invoices manually. This operation is not allowed when any of the following condition matches:
If e-invoicing is not enabled at the site and customer level.
If there is an e-invoice generated already for the invoice.
If the “Use automatic e-invoicing “ option is selected.
If there are no generated e-invoices with the failed
or skipped
status.
If the invoice status is voided
or pending
.