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)

Constant Summary collapse

OBJECT_NAME =
"credit_note"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

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

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.



32
33
34
# File 'lib/stripe/resources/credit_note.rb', line 32

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.



37
38
39
# File 'lib/stripe/resources/credit_note.rb', line 37

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.



42
43
44
45
46
47
48
49
# File 'lib/stripe/resources/credit_note.rb', line 42

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.



52
53
54
55
56
57
58
59
# File 'lib/stripe/resources/credit_note.rb', line 52

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.



62
63
64
65
66
67
68
69
# File 'lib/stripe/resources/credit_note.rb', line 62

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



82
83
84
85
86
87
88
89
# File 'lib/stripe/resources/credit_note.rb', line 82

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



72
73
74
75
76
77
78
79
# File 'lib/stripe/resources/credit_note.rb', line 72

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