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](docs.stripe.com/billing/invoices/credit-notes)
Defined Under Namespace
Classes: DiscountAmount, PretaxCreditAmount, Refund, ShippingCost, TotalTax
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_account ⇒ Object
readonly
ID of the account representing 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
If the object exists in live mode, the value is ‘true`.
-
#memo ⇒ Object
readonly
Customer-facing text that appears on the credit note PDF.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](docs.stripe.com/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
The amount of the credit note that was refunded to the customer, credited to the customer’s balance, credited outside of Stripe, or any combination thereof.
-
#pre_payment_amount ⇒ Object
readonly
The amount of the credit note by which the invoice’s ‘amount_remaining` and `amount_due` were reduced.
-
#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`.
-
#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.
-
#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.
-
#total_taxes ⇒ Object
readonly
The aggregate tax information for all line items.
-
#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.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.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
#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #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.
161 162 163 |
# File 'lib/stripe/resources/credit_note.rb', line 161 def amount @amount end |
#amount_shipping ⇒ Object (readonly)
This is the sum of all the shipping amounts.
163 164 165 |
# File 'lib/stripe/resources/credit_note.rb', line 163 def amount_shipping @amount_shipping end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
165 166 167 |
# File 'lib/stripe/resources/credit_note.rb', line 165 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).
167 168 169 |
# File 'lib/stripe/resources/credit_note.rb', line 167 def currency @currency end |
#customer ⇒ Object (readonly)
ID of the customer.
169 170 171 |
# File 'lib/stripe/resources/credit_note.rb', line 169 def customer @customer end |
#customer_account ⇒ Object (readonly)
ID of the account representing the customer.
171 172 173 |
# File 'lib/stripe/resources/credit_note.rb', line 171 def customer_account @customer_account end |
#customer_balance_transaction ⇒ Object (readonly)
Customer balance transaction related to this credit note.
173 174 175 |
# File 'lib/stripe/resources/credit_note.rb', line 173 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.
175 176 177 |
# File 'lib/stripe/resources/credit_note.rb', line 175 def discount_amount @discount_amount end |
#discount_amounts ⇒ Object (readonly)
The aggregate amounts calculated per discount for all line items.
177 178 179 |
# File 'lib/stripe/resources/credit_note.rb', line 177 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.
179 180 181 |
# File 'lib/stripe/resources/credit_note.rb', line 179 def effective_at @effective_at end |
#id ⇒ Object (readonly)
Unique identifier for the object.
181 182 183 |
# File 'lib/stripe/resources/credit_note.rb', line 181 def id @id end |
#invoice ⇒ Object (readonly)
ID of the invoice.
183 184 185 |
# File 'lib/stripe/resources/credit_note.rb', line 183 def invoice @invoice end |
#lines ⇒ Object (readonly)
Line items that make up the credit note
185 186 187 |
# File 'lib/stripe/resources/credit_note.rb', line 185 def lines @lines end |
#livemode ⇒ Object (readonly)
If the object exists in live mode, the value is ‘true`. If the object exists in test mode, the value is `false`.
187 188 189 |
# File 'lib/stripe/resources/credit_note.rb', line 187 def livemode @livemode end |
#memo ⇒ Object (readonly)
Customer-facing text that appears on the credit note PDF.
189 190 191 |
# File 'lib/stripe/resources/credit_note.rb', line 189 def memo @memo end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
191 192 193 |
# File 'lib/stripe/resources/credit_note.rb', line 191 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.
193 194 195 |
# File 'lib/stripe/resources/credit_note.rb', line 193 def number @number end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
195 196 197 |
# File 'lib/stripe/resources/credit_note.rb', line 195 def object @object end |
#out_of_band_amount ⇒ Object (readonly)
Amount that was credited outside of Stripe.
197 198 199 |
# File 'lib/stripe/resources/credit_note.rb', line 197 def out_of_band_amount @out_of_band_amount end |
#pdf ⇒ Object (readonly)
The link to download the PDF of the credit note.
199 200 201 |
# File 'lib/stripe/resources/credit_note.rb', line 199 def pdf @pdf end |
#post_payment_amount ⇒ Object (readonly)
The amount of the credit note that was refunded to the customer, credited to the customer’s balance, credited outside of Stripe, or any combination thereof.
201 202 203 |
# File 'lib/stripe/resources/credit_note.rb', line 201 def post_payment_amount @post_payment_amount end |
#pre_payment_amount ⇒ Object (readonly)
The amount of the credit note by which the invoice’s ‘amount_remaining` and `amount_due` were reduced.
203 204 205 |
# File 'lib/stripe/resources/credit_note.rb', line 203 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.
205 206 207 |
# File 'lib/stripe/resources/credit_note.rb', line 205 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`
207 208 209 |
# File 'lib/stripe/resources/credit_note.rb', line 207 def reason @reason end |
#refunds ⇒ Object (readonly)
Refunds related to this credit note.
209 210 211 |
# File 'lib/stripe/resources/credit_note.rb', line 209 def refunds @refunds end |
#shipping_cost ⇒ Object (readonly)
The details of the cost of shipping, including the ShippingRate applied to the invoice.
211 212 213 |
# File 'lib/stripe/resources/credit_note.rb', line 211 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](docs.stripe.com/billing/invoices/credit-notes#voiding).
213 214 215 |
# File 'lib/stripe/resources/credit_note.rb', line 213 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.
215 216 217 |
# File 'lib/stripe/resources/credit_note.rb', line 215 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.
217 218 219 |
# File 'lib/stripe/resources/credit_note.rb', line 217 def subtotal_excluding_tax @subtotal_excluding_tax 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.
219 220 221 |
# File 'lib/stripe/resources/credit_note.rb', line 219 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.
221 222 223 |
# File 'lib/stripe/resources/credit_note.rb', line 221 def total_excluding_tax @total_excluding_tax end |
#total_taxes ⇒ Object (readonly)
The aggregate tax information for all line items.
223 224 225 |
# File 'lib/stripe/resources/credit_note.rb', line 223 def total_taxes @total_taxes 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.
225 226 227 |
# File 'lib/stripe/resources/credit_note.rb', line 225 def type @type end |
#voided_at ⇒ Object (readonly)
The time that the credit note was voided.
227 228 229 |
# File 'lib/stripe/resources/credit_note.rb', line 227 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. A credit note will first reduce the invoice’s amount_remaining (and amount_due), but not below zero. This amount is indicated by the credit note’s pre_payment_amount. The excess amount is indicated by post_payment_amount, and it can result in any combination of the following:
Refunds: create a new refund (using refund_amount) or link existing refunds (using refunds). 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).
The sum of refunds, customer balance credits, and outside of Stripe credits must equal the post_payment_amount.
You may issue multiple credit notes for an invoice. Each credit note may increment the invoice’s pre_payment_credit_notes_amount, post_payment_credit_notes_amount, or both, depending on the invoice’s amount_remaining at the time of credit note creation.
For invoices that also have refunds created through the [Refund API](docs.stripe.com/docs/api/refunds), the credit note API subtracts those refund amounts from the maximum creditable amount. This prevents the combined credit notes and refunds from exceeding the invoice amount. If you use both, ensure the combined total does not exceed the invoice’s paid amount.
244 245 246 |
# File 'lib/stripe/resources/credit_note.rb', line 244 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/credit_notes", params: params, opts: opts) end |
.field_remappings ⇒ Object
313 314 315 |
# File 'lib/stripe/resources/credit_note.rb', line 313 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
303 304 305 306 307 308 309 310 311 |
# File 'lib/stripe/resources/credit_note.rb', line 303 def self.inner_class_types @inner_class_types = { discount_amounts: DiscountAmount, pretax_credit_amounts: PretaxCreditAmount, refunds: Refund, shipping_cost: ShippingCost, total_taxes: TotalTax, } end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of credit notes.
249 250 251 |
# File 'lib/stripe/resources/credit_note.rb', line 249 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.
254 255 256 257 258 259 260 261 |
# File 'lib/stripe/resources/credit_note.rb', line 254 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.
264 265 266 267 268 269 270 271 |
# File 'lib/stripe/resources/credit_note.rb', line 264 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.
274 275 276 277 278 279 280 281 |
# File 'lib/stripe/resources/credit_note.rb', line 274 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](docs.stripe.com/docs/billing/invoices/credit-notes#voiding).
294 295 296 297 298 299 300 301 |
# File 'lib/stripe/resources/credit_note.rb', line 294 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](docs.stripe.com/docs/billing/invoices/credit-notes#voiding).
284 285 286 287 288 289 290 291 |
# File 'lib/stripe/resources/credit_note.rb', line 284 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 |