A Credit Note is a document that specifies the money owed by a business to its customer. The seller usually issues a Credit Note for the same or lower amount than the invoice, and then repays the money to the customer or set it off against other 'due' invoices.
Credit notes in Chargebee are categorized into three types:
1. adjustment
: Adjustment credit notes are used to adjust the amount of an existing invoice in the payment_due
or not_paid
status. Use this type of credit note to reduce the invoice amount, typically as a discount to the customer.
Adjustment credit notes are automatically created in the following cases:
payment_due
or not_paid
status.2. refundable
: Refundable credit notes allow you to return a certain amount to the customer. These credits can be:
Refundable credit notes are automatically created in the following cases:
paid
status. Refundable credits are applied to future invoices or can be refunded to the original payment method.3. store
: Store credit notes are created for paid
or partially_paid
invoice status during subscription changes, such as upgrades, downgrades, or cancellations.
Key characteristics of store credits:
{
"allocations": [],
"amount_allocated": 0,
"amount_available": 500,
"amount_refunded": 0,
"base_currency_code": "USD",
"create_reason_code": "Product Unsatisfactory",
"currency_code": "USD",
"customer_id": "__test__KyVnHhSBWSy4m5e",
"date": 1517501405,
"deleted": false,
"exchange_rate": 1,
"fractional_correction": 0,
"id": "__demo_cn__1",
"line_item_discounts": [],
"line_item_taxes": [],
"line_items": [
{
"amount": 500,
"customer_id": "__test__KyVnHhSBWSy4m5e",
"date_from": 1517501405,
"date_to": 1517501405,
"description": "Support Charge",
"discount_amount": 0,
"entity_type": "adhoc",
"id": "li___test__KyVnHhSBWSyHE5r",
"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": 500
}
],
"linked_refunds": [],
"object": "credit_note",
"price_type": "tax_exclusive",
"reason_code": "product_unsatisfactory",
"reference_invoice_id": "__demo_inv__1",
"resource_version": 1517501405000,
"round_off_amount": 0,
"status": "refund_due",
"sub_total": 500,
"taxes": [],
"total": 500,
"type": "refundable",
"updated_at": 1517501405
}
ChargeBee::CreditNote
round_off_amount
. If there is no round-off amount
, it will display 0
. 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. reference_invoice_id
. invoice.linked_taxes_withheld
component of the invoice
associated with this credit_note
. Creates a credit_note
for the specified invoice.
Note:
If the credit_note
type
is refundable
, then linked_taxes_withheld.amount
for the invoice specified can also be included in the total
.
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.create({ :reference_invoice_id => "__demo_inv__1", :total => 500, :type => "REFUNDABLE", :reason_code => "PRODUCT_UNSATISFACTORY", :customer_notes => "Products were returned because they were defective" }) credit_note = result.credit_note invoice = result.invoice
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.create({ :reference_invoice_id => "__demo_inv__1", :total => 500, :type => "REFUNDABLE", :reason_code => "PRODUCT_UNSATISFACTORY", :customer_notes => "Products were returned because they were defective" }) credit_note = result.credit_note invoice = result.invoice
ChargeBee::CreditNote.create({<param name> => <value>,<param name> => <value> ...})
line_item
. The value is in major units of the currency. Applicable for the line_item when the pricing_model
is flat_fee
, per_unit
or volume
. Can be provided only when multi-decimal pricing is enabled. line_item
. Applicable for the line_item
when the pricing_model
is per_unit
and volume
. Can be provided only when multi-decimal pricing is enabled. require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.retrieve("__demo_cn__7") credit_note = result.credit_note
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.retrieve("__demo_cn__7") credit_note = result.credit_note
ChargeBee::CreditNote.retrieve(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.pdf("__demo_cn__4") download = result.download
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.pdf("__demo_cn__4") download = result.download
ChargeBee::CreditNote.pdf(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
Download the e-invoice for the credit note 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
or registered
.cbc:EmbeddedDocumentBinaryObject
, which is the Base64-encoded version of the PDF.require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.download_einvoice("__demo_cn__1") downloads = result.downloads
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.download_einvoice("__demo_cn__1") downloads = result.downloads
ChargeBee::CreditNote.download_einvoice(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
Refunds a (refundable) credit note to the payment source associated with the transaction. Any linked_tax_withheld_refunds
recorded against the credit note are not refunded.
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.refund("__demo_cn__6",{ :customer_notes => "Refunding as customer canceled the order.", :refund_amount => 1000 }) credit_note = result.credit_note transaction = result.transaction
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.refund("__demo_cn__6",{ :customer_notes => "Refunding as customer canceled the order.", :refund_amount => 1000 }) credit_note = result.credit_note transaction = result.transaction
ChargeBee::CreditNote.refund(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
credit_note
is refunded.
Note: Any linked_tax_withheld_refunds
associated with the credit_note
cannot be refunded via this operation. Refunds a (refundable) credit note. The refund is provided against linked_payments
first and then against any linked_taxes_withheld
for the invoice
associated with the credit_note
. For payments made via online transactions, the refund request is processed via the payment source associated with the transaction.
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.record_refund("__demo_cn__5",{ :comment => "Refunding as customer canceled the order.", :transaction => { :amount => 100, :payment_method => "BANK_TRANSFER", :date => 1517501412 } }) credit_note = result.credit_note transaction = result.transaction
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.record_refund("__demo_cn__5",{ :comment => "Refunding as customer canceled the order.", :transaction => { :amount => 100, :payment_method => "BANK_TRANSFER", :date => 1517501412 } }) credit_note = result.credit_note transaction = result.transaction
ChargeBee::CreditNote.record_refund(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
credit_note
is refunded.
Note: Any linked_tax_withheld_refunds
associated with the credit_note
can also be recorded as refunded via this operation. type
= refund
. This value is set by Chargebee when an automated chargeback occurs. You can also set this explicitly when recording a refund.bank_transferBank TransferotherPayment Methods other than the above typescustomCustompayment_method
= check
. Use this API to void a credit note. A voided credit is a null entity and cannot be used again. A credit note which has already been voided or refunded cannot be voided. An error message will be displayed when you render such credit notes void.
Note: When adjustment credit notes are voided, the associated invoice will reflect as NOT PAID, and the amount in the invoice will be recalculated to reflect the amount after considering the voided credit note.
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.void_credit_note("__demo_cn__8") credit_note = result.credit_note
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.void_credit_note("__demo_cn__8") credit_note = result.credit_note
ChargeBee::CreditNote.void_credit_note(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
Lists all the Credit Notes.
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") list = ChargeBee::CreditNote.list({ :limit => 3, "type[is]" => "refundable", "sort_by[asc]" => "date" }) list.each do |entry| credit_note = entry.credit_note end
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") list = ChargeBee::CreditNote.list({ :limit => 3, "type[is]" => "refundable", "sort_by[asc]" => "date" }) list.each do |entry| credit_note = entry.credit_note end
ChargeBee::CreditNote.list({<param name> => <value>,<param name> => <value> ...})
status
, see message
. Possible values are : scheduled, skipped, in_progress, success, failed, registered This API deletes a credit note. A credit note once deleted, is deleted permanently. You cannot delete a credit which has already been deleted or refunded. If you try to delete a refunded or deleted credit note, an error message will be displayed.
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.delete("__demo_cn__2") credit_note = result.credit_note
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.delete("__demo_cn__2") credit_note = result.credit_note
ChargeBee::CreditNote.delete(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
linked_tax_withheld_refunds
record from the credit_note
.require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.remove_tax_withheld_refund("__demo_cn__1",{ :tax_withheld => { :id => "tax_wh___test__8astRSmw2zLr24" } }) credit_note = result.credit_note
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.remove_tax_withheld_refund("__demo_cn__1",{ :tax_withheld => { :id => "tax_wh___test__8astRSmw2zLr24" } }) credit_note = result.credit_note
ChargeBee::CreditNote.remove_tax_withheld_refund(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.resend_einvoice("__demo_cn__1") credit_note = result.credit_note
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.resend_einvoice("__demo_cn__1") credit_note = result.credit_note
ChargeBee::CreditNote.resend_einvoice(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
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
.
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.send_einvoice("__demo_cn__1") credit_note = result.credit_note
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.send_einvoice("__demo_cn__1") credit_note = result.credit_note
ChargeBee::CreditNote.send_einvoice(<credit_note_id>,{<param name> => <value>,<param name> => <value> ...})
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.import_credit_note({ :id => "old_cn_001", :customer_id => "__test__XpbBxQiS4HD1nWYL", :subscription_id => "__test__XpbBxQiS4HD1nWYL", :reference_invoice_id => "__demo_inv__7", :type => "REFUNDABLE", :currency_code => "USD", :create_reason_code => "Product Unsatisfactory", :date => 1517429430, :total => 4900, :status => "REFUND_DUE", :line_items => [ { :date_from => 1517429430, :date_to => 1519848630, :description => "Support Charge", :unit_amount => 4900, :quantity => 1, :entity_type => "PLAN_ITEM_PRICE", :entity_id => "plan1" }] }) credit_note = result.credit_note
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::CreditNote.import_credit_note({ :id => "old_cn_001", :customer_id => "__test__XpbBxQiS4HD1nWYL", :subscription_id => "__test__XpbBxQiS4HD1nWYL", :reference_invoice_id => "__demo_inv__7", :type => "REFUNDABLE", :currency_code => "USD", :create_reason_code => "Product Unsatisfactory", :date => 1517429430, :total => 4900, :status => "REFUND_DUE", :line_items => [ { :date_from => 1517429430, :date_to => 1519848630, :description => "Support Charge", :unit_amount => 4900, :quantity => 1, :entity_type => "PLAN_ITEM_PRICE", :entity_id => "plan1" }] }) credit_note = result.credit_note
ChargeBee::CreditNote.import_credit_note({<param name> => <value>,<param name> => <value> ...})
round_off_amount
. If there is no round-off amount
, it will display 0
. 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. metered
line items, this value is updated from usages once when the invoice is generated as pending
and finally when the invoice is closed.line_item
. The value is in major units of the currency. Returned when the line_item
is quantity-based and multi-decimal pricing is enabled. line_item
is quantity-based and multi-decimal pricing is enabled. line_item
, in major units of the currency. Typically equals to unit_amount_in_decimal
x quantity_in_decimal
. Returned when multi-decimal pricing is enabled. stairtstep
pricing , or the price of each unit in the tier if the charge model is tiered
/volume
pricing. ending_unit_in_decimal
of the next lower tier. Returned only when the line_items.pricing_model
is tiered
, volume
or stairstep
and multi-decimal pricing is enabled. starting_unit_in_decimal
of the next higher tier. Returned only when the line_items.pricing_model
is tiered
, volume
or stairstep and multi-decimal pricing is enabled. line_item
is quantity-based and multi-decimal pricing is enabled. pricing_model
is tiered
or volume
. When the pricing_model
is stairstep
, it is the decimal representation of the total price for line_item
. The value is in major units of the currency. Returned when the line_item
is quantity-based and multi-decimal pricing is enabled. discounts[entity_type]
is item_level_coupon
or document_level_coupon
. id
is passed as entity_id
.document_level_couponThe deduction is due to a coupon applied to the invoice sub_total
. The coupon id is passed as entity_id
.promotional_creditsThe deduction is due to a promotional credit applied to the invoice.item_level_discountThe deduction is due to a discount applied to a line item of the invoice. The discount id
is available as the entity_id
. document_level_discountThe deduction is due to a discount applied to the invoice sub_total
. The discount id
is available as the entity_id
. coupon
, then this is the id
of the coupon. Is required when discounts[entity_type]
is item_level_coupon
or document_level_coupon
.