Class: Stripe::CreditNote

Inherits:
APIResource show all
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

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #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

included

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

#amountObject (readonly)

The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.



610
611
612
# File 'lib/stripe/resources/credit_note.rb', line 610

def amount
  @amount
end

#amount_shippingObject (readonly)

This is the sum of all the shipping amounts.



612
613
614
# File 'lib/stripe/resources/credit_note.rb', line 612

def amount_shipping
  @amount_shipping
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



614
615
616
# File 'lib/stripe/resources/credit_note.rb', line 614

def created
  @created
end

#currencyObject (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).



616
617
618
# File 'lib/stripe/resources/credit_note.rb', line 616

def currency
  @currency
end

#customerObject (readonly)

ID of the customer.



618
619
620
# File 'lib/stripe/resources/credit_note.rb', line 618

def customer
  @customer
end

#customer_balance_transactionObject (readonly)

Customer balance transaction related to this credit note.



620
621
622
# File 'lib/stripe/resources/credit_note.rb', line 620

def customer_balance_transaction
  @customer_balance_transaction
end

#discount_amountObject (readonly)

The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.



622
623
624
# File 'lib/stripe/resources/credit_note.rb', line 622

def discount_amount
  @discount_amount
end

#discount_amountsObject (readonly)

The aggregate amounts calculated per discount for all line items.



624
625
626
# File 'lib/stripe/resources/credit_note.rb', line 624

def discount_amounts
  @discount_amounts
end

#effective_atObject (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.



626
627
628
# File 'lib/stripe/resources/credit_note.rb', line 626

def effective_at
  @effective_at
end

#idObject (readonly)

Unique identifier for the object.



628
629
630
# File 'lib/stripe/resources/credit_note.rb', line 628

def id
  @id
end

#invoiceObject (readonly)

ID of the invoice.



630
631
632
# File 'lib/stripe/resources/credit_note.rb', line 630

def invoice
  @invoice
end

#linesObject (readonly)

Line items that make up the credit note



632
633
634
# File 'lib/stripe/resources/credit_note.rb', line 632

def lines
  @lines
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



634
635
636
# File 'lib/stripe/resources/credit_note.rb', line 634

def livemode
  @livemode
end

#memoObject (readonly)

Customer-facing text that appears on the credit note PDF.



636
637
638
# File 'lib/stripe/resources/credit_note.rb', line 636

def memo
  @memo
end

#metadataObject (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.



638
639
640
# File 'lib/stripe/resources/credit_note.rb', line 638

def 
  @metadata
end

#numberObject (readonly)

A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.



640
641
642
# File 'lib/stripe/resources/credit_note.rb', line 640

def number
  @number
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



642
643
644
# File 'lib/stripe/resources/credit_note.rb', line 642

def object
  @object
end

#out_of_band_amountObject (readonly)

Amount that was credited outside of Stripe.



644
645
646
# File 'lib/stripe/resources/credit_note.rb', line 644

def out_of_band_amount
  @out_of_band_amount
end

#pdfObject (readonly)

The link to download the PDF of the credit note.



646
647
648
# File 'lib/stripe/resources/credit_note.rb', line 646

def pdf
  @pdf
end

#post_payment_amountObject (readonly)

Attribute for field post_payment_amount



648
649
650
# File 'lib/stripe/resources/credit_note.rb', line 648

def post_payment_amount
  @post_payment_amount
end

#pre_payment_amountObject (readonly)

Attribute for field pre_payment_amount



650
651
652
# File 'lib/stripe/resources/credit_note.rb', line 650

def pre_payment_amount
  @pre_payment_amount
end

#pretax_credit_amountsObject (readonly)

The pretax credit amounts (ex: discount, credit grants, etc) for all line items.



652
653
654
# File 'lib/stripe/resources/credit_note.rb', line 652

def pretax_credit_amounts
  @pretax_credit_amounts
end

#reasonObject (readonly)

Reason for issuing this credit note, one of ‘duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`



654
655
656
# File 'lib/stripe/resources/credit_note.rb', line 654

def reason
  @reason
end

#refundObject (readonly)

Refund related to this credit note.



656
657
658
# File 'lib/stripe/resources/credit_note.rb', line 656

def refund
  @refund
end

#refundsObject (readonly)

Refunds related to this credit note.



658
659
660
# File 'lib/stripe/resources/credit_note.rb', line 658

def refunds
  @refunds
end

#shipping_costObject (readonly)

The details of the cost of shipping, including the ShippingRate applied to the invoice.



660
661
662
# File 'lib/stripe/resources/credit_note.rb', line 660

def shipping_cost
  @shipping_cost
end

#statusObject (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).



662
663
664
# File 'lib/stripe/resources/credit_note.rb', line 662

def status
  @status
end

#subtotalObject (readonly)

The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.



664
665
666
# File 'lib/stripe/resources/credit_note.rb', line 664

def subtotal
  @subtotal
end

#subtotal_excluding_taxObject (readonly)

The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.



666
667
668
# File 'lib/stripe/resources/credit_note.rb', line 666

def subtotal_excluding_tax
  @subtotal_excluding_tax
end

#tax_amountsObject (readonly)

The aggregate amounts calculated per tax rate for all line items.



668
669
670
# File 'lib/stripe/resources/credit_note.rb', line 668

def tax_amounts
  @tax_amounts
end

#totalObject (readonly)

The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.



670
671
672
# File 'lib/stripe/resources/credit_note.rb', line 670

def total
  @total
end

#total_excluding_taxObject (readonly)

The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.



672
673
674
# File 'lib/stripe/resources/credit_note.rb', line 672

def total_excluding_tax
  @total_excluding_tax
end

#typeObject (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.



674
675
676
# File 'lib/stripe/resources/credit_note.rb', line 674

def type
  @type
end

#voided_atObject (readonly)

The time that the credit note was voided.



676
677
678
# File 'lib/stripe/resources/credit_note.rb', line 676

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.



692
693
694
# File 'lib/stripe/resources/credit_note.rb', line 692

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.



697
698
699
# File 'lib/stripe/resources/credit_note.rb', line 697

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.



702
703
704
705
706
707
708
709
# File 'lib/stripe/resources/credit_note.rb', line 702

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_nameObject



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.



712
713
714
715
716
717
718
719
# File 'lib/stripe/resources/credit_note.rb', line 712

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.



722
723
724
725
726
727
728
729
# File 'lib/stripe/resources/credit_note.rb', line 722

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



742
743
744
745
746
747
748
749
# File 'lib/stripe/resources/credit_note.rb', line 742

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



732
733
734
735
736
737
738
739
# File 'lib/stripe/resources/credit_note.rb', line 732

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