Class: Stripe::CreditNote
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::CreditNote
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/credit_note.rb
Overview
Issue a credit note to adjust an invoice’s amount after the invoice is finalized.
Related guide: [Credit notes](stripe.com/docs/billing/invoices/credit-notes)
Defined Under Namespace
Classes: CreateParams, DiscountAmount, ListParams, ListPreviewLineItemsParams, PretaxCreditAmount, PreviewParams, Refund, RetrieveParams, ShippingCost, TaxAmount, UpdateParams, VoidCreditNoteParams
Constant Summary collapse
- OBJECT_NAME =
"credit_note"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
-
#amount_shipping ⇒ Object
readonly
This is the sum of all the shipping amounts.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#currency ⇒ Object
readonly
Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase.
-
#customer ⇒ Object
readonly
ID of the customer.
-
#customer_balance_transaction ⇒ Object
readonly
Customer balance transaction related to this credit note.
-
#discount_amount ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
-
#discount_amounts ⇒ Object
readonly
The aggregate amounts calculated per discount for all line items.
-
#effective_at ⇒ Object
readonly
The date when this credit note is in effect.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#invoice ⇒ Object
readonly
ID of the invoice.
-
#lines ⇒ Object
readonly
Line items that make up the credit note.
-
#livemode ⇒ Object
readonly
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#memo ⇒ Object
readonly
Customer-facing text that appears on the credit note PDF.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object.
-
#number ⇒ Object
readonly
A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#out_of_band_amount ⇒ Object
readonly
Amount that was credited outside of Stripe.
-
#pdf ⇒ Object
readonly
The link to download the PDF of the credit note.
-
#post_payment_amount ⇒ Object
readonly
Attribute for field post_payment_amount.
-
#pre_payment_amount ⇒ Object
readonly
Attribute for field pre_payment_amount.
-
#pretax_credit_amounts ⇒ Object
readonly
The pretax credit amounts (ex: discount, credit grants, etc) for all line items.
-
#reason ⇒ Object
readonly
Reason for issuing this credit note, one of ‘duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`.
-
#refund ⇒ Object
readonly
Refund related to this credit note.
-
#refunds ⇒ Object
readonly
Refunds related to this credit note.
-
#shipping_cost ⇒ Object
readonly
The details of the cost of shipping, including the ShippingRate applied to the invoice.
-
#status ⇒ Object
readonly
Status of this credit note, one of ‘issued` or `void`.
-
#subtotal ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
-
#subtotal_excluding_tax ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
-
#tax_amounts ⇒ Object
readonly
The aggregate amounts calculated per tax rate for all line items.
-
#total ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
-
#total_excluding_tax ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
-
#type ⇒ Object
readonly
Type of this credit note, one of ‘pre_payment` or `post_payment`.
-
#voided_at ⇒ Object
readonly
The time that the credit note was voided.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Issue a credit note to adjust the amount of a finalized invoice.
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of credit notes.
-
.list_preview_line_items(params = {}, opts = {}) ⇒ Object
When retrieving a credit note preview, you’ll get a lines property containing the first handful of those items.
- .object_name ⇒ Object
-
.preview(params = {}, opts = {}) ⇒ Object
Get a preview of a credit note without creating it.
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates an existing credit note.
-
.void_credit_note(id, params = {}, opts = {}) ⇒ Object
Marks a credit note as void.
Instance Method Summary collapse
-
#void_credit_note(params = {}, opts = {}) ⇒ Object
Marks a credit note as void.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::Save
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Instance Attribute Details
#amount ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
715 716 717 |
# File 'lib/stripe/resources/credit_note.rb', line 715 def amount @amount end |
#amount_shipping ⇒ Object (readonly)
This is the sum of all the shipping amounts.
718 719 720 |
# File 'lib/stripe/resources/credit_note.rb', line 718 def amount_shipping @amount_shipping end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
721 722 723 |
# File 'lib/stripe/resources/credit_note.rb', line 721 def created @created end |
#currency ⇒ Object (readonly)
Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies).
724 725 726 |
# File 'lib/stripe/resources/credit_note.rb', line 724 def currency @currency end |
#customer ⇒ Object (readonly)
ID of the customer.
727 728 729 |
# File 'lib/stripe/resources/credit_note.rb', line 727 def customer @customer end |
#customer_balance_transaction ⇒ Object (readonly)
Customer balance transaction related to this credit note.
730 731 732 |
# File 'lib/stripe/resources/credit_note.rb', line 730 def customer_balance_transaction @customer_balance_transaction end |
#discount_amount ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
733 734 735 |
# File 'lib/stripe/resources/credit_note.rb', line 733 def discount_amount @discount_amount end |
#discount_amounts ⇒ Object (readonly)
The aggregate amounts calculated per discount for all line items.
736 737 738 |
# File 'lib/stripe/resources/credit_note.rb', line 736 def discount_amounts @discount_amounts end |
#effective_at ⇒ Object (readonly)
The date when this credit note is in effect. Same as ‘created` unless overwritten. When defined, this value replaces the system-generated ’Date of issue’ printed on the credit note PDF.
739 740 741 |
# File 'lib/stripe/resources/credit_note.rb', line 739 def effective_at @effective_at end |
#id ⇒ Object (readonly)
Unique identifier for the object.
742 743 744 |
# File 'lib/stripe/resources/credit_note.rb', line 742 def id @id end |
#invoice ⇒ Object (readonly)
ID of the invoice.
745 746 747 |
# File 'lib/stripe/resources/credit_note.rb', line 745 def invoice @invoice end |
#lines ⇒ Object (readonly)
Line items that make up the credit note
748 749 750 |
# File 'lib/stripe/resources/credit_note.rb', line 748 def lines @lines end |
#livemode ⇒ Object (readonly)
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
751 752 753 |
# File 'lib/stripe/resources/credit_note.rb', line 751 def livemode @livemode end |
#memo ⇒ Object (readonly)
Customer-facing text that appears on the credit note PDF.
754 755 756 |
# File 'lib/stripe/resources/credit_note.rb', line 754 def memo @memo end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
757 758 759 |
# File 'lib/stripe/resources/credit_note.rb', line 757 def @metadata end |
#number ⇒ Object (readonly)
A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
760 761 762 |
# File 'lib/stripe/resources/credit_note.rb', line 760 def number @number end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
763 764 765 |
# File 'lib/stripe/resources/credit_note.rb', line 763 def object @object end |
#out_of_band_amount ⇒ Object (readonly)
Amount that was credited outside of Stripe.
766 767 768 |
# File 'lib/stripe/resources/credit_note.rb', line 766 def out_of_band_amount @out_of_band_amount end |
#pdf ⇒ Object (readonly)
The link to download the PDF of the credit note.
769 770 771 |
# File 'lib/stripe/resources/credit_note.rb', line 769 def pdf @pdf end |
#post_payment_amount ⇒ Object (readonly)
Attribute for field post_payment_amount
772 773 774 |
# File 'lib/stripe/resources/credit_note.rb', line 772 def post_payment_amount @post_payment_amount end |
#pre_payment_amount ⇒ Object (readonly)
Attribute for field pre_payment_amount
775 776 777 |
# File 'lib/stripe/resources/credit_note.rb', line 775 def pre_payment_amount @pre_payment_amount end |
#pretax_credit_amounts ⇒ Object (readonly)
The pretax credit amounts (ex: discount, credit grants, etc) for all line items.
778 779 780 |
# File 'lib/stripe/resources/credit_note.rb', line 778 def pretax_credit_amounts @pretax_credit_amounts end |
#reason ⇒ Object (readonly)
Reason for issuing this credit note, one of ‘duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
781 782 783 |
# File 'lib/stripe/resources/credit_note.rb', line 781 def reason @reason end |
#refund ⇒ Object (readonly)
Refund related to this credit note.
784 785 786 |
# File 'lib/stripe/resources/credit_note.rb', line 784 def refund @refund end |
#refunds ⇒ Object (readonly)
Refunds related to this credit note.
787 788 789 |
# File 'lib/stripe/resources/credit_note.rb', line 787 def refunds @refunds end |
#shipping_cost ⇒ Object (readonly)
The details of the cost of shipping, including the ShippingRate applied to the invoice.
790 791 792 |
# File 'lib/stripe/resources/credit_note.rb', line 790 def shipping_cost @shipping_cost end |
#status ⇒ Object (readonly)
Status of this credit note, one of ‘issued` or `void`. Learn more about [voiding credit notes](stripe.com/docs/billing/invoices/credit-notes#voiding).
793 794 795 |
# File 'lib/stripe/resources/credit_note.rb', line 793 def status @status end |
#subtotal ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
796 797 798 |
# File 'lib/stripe/resources/credit_note.rb', line 796 def subtotal @subtotal end |
#subtotal_excluding_tax ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
799 800 801 |
# File 'lib/stripe/resources/credit_note.rb', line 799 def subtotal_excluding_tax @subtotal_excluding_tax end |
#tax_amounts ⇒ Object (readonly)
The aggregate amounts calculated per tax rate for all line items.
802 803 804 |
# File 'lib/stripe/resources/credit_note.rb', line 802 def tax_amounts @tax_amounts end |
#total ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
805 806 807 |
# File 'lib/stripe/resources/credit_note.rb', line 805 def total @total end |
#total_excluding_tax ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
808 809 810 |
# File 'lib/stripe/resources/credit_note.rb', line 808 def total_excluding_tax @total_excluding_tax end |
#type ⇒ Object (readonly)
Type of this credit note, one of ‘pre_payment` or `post_payment`. A `pre_payment` credit note means it was issued when the invoice was open. A `post_payment` credit note means it was issued when the invoice was paid.
811 812 813 |
# File 'lib/stripe/resources/credit_note.rb', line 811 def type @type end |
#voided_at ⇒ Object (readonly)
The time that the credit note was voided.
814 815 816 |
# File 'lib/stripe/resources/credit_note.rb', line 814 def voided_at @voided_at end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result in any combination of the following:
Refund: create a new refund (using refund_amount) or link an existing refund (using refund). Customer balance credit: credit the customer’s balance (using credit_amount) which will be automatically applied to their next invoice when it’s finalized. Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount).
For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.
You may issue multiple credit notes for an invoice. Each credit note will increment the invoice’s pre_payment_credit_notes_amount or post_payment_credit_notes_amount depending on its status at the time of credit note creation.
830 831 832 |
# File 'lib/stripe/resources/credit_note.rb', line 830 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/credit_notes", params: params, opts: opts) end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of credit notes.
835 836 837 |
# File 'lib/stripe/resources/credit_note.rb', line 835 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/credit_notes", params: params, opts: opts) end |
.list_preview_line_items(params = {}, opts = {}) ⇒ Object
When retrieving a credit note preview, you’ll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items.
840 841 842 843 844 845 846 847 |
# File 'lib/stripe/resources/credit_note.rb', line 840 def self.list_preview_line_items(params = {}, opts = {}) request_stripe_object( method: :get, path: "/v1/credit_notes/preview/lines", params: params, opts: opts ) end |
.object_name ⇒ Object
14 15 16 |
# File 'lib/stripe/resources/credit_note.rb', line 14 def self.object_name "credit_note" end |
.preview(params = {}, opts = {}) ⇒ Object
Get a preview of a credit note without creating it.
850 851 852 853 854 855 856 857 |
# File 'lib/stripe/resources/credit_note.rb', line 850 def self.preview(params = {}, opts = {}) request_stripe_object( method: :get, path: "/v1/credit_notes/preview", params: params, opts: opts ) end |
.update(id, params = {}, opts = {}) ⇒ Object
Updates an existing credit note.
860 861 862 863 864 865 866 867 |
# File 'lib/stripe/resources/credit_note.rb', line 860 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/credit_notes/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.void_credit_note(id, params = {}, opts = {}) ⇒ Object
Marks a credit note as void. Learn more about [voiding credit notes](stripe.com/docs/billing/invoices/credit-notes#voiding).
880 881 882 883 884 885 886 887 |
# File 'lib/stripe/resources/credit_note.rb', line 880 def self.void_credit_note(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/credit_notes/%<id>s/void", { id: CGI.escape(id) }), params: params, opts: opts ) end |
Instance Method Details
#void_credit_note(params = {}, opts = {}) ⇒ Object
Marks a credit note as void. Learn more about [voiding credit notes](stripe.com/docs/billing/invoices/credit-notes#voiding).
870 871 872 873 874 875 876 877 |
# File 'lib/stripe/resources/credit_note.rb', line 870 def void_credit_note(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/credit_notes/%<id>s/void", { id: CGI.escape(self["id"]) }), params: params, opts: opts ) end |