Class: Stripe::CreditNoteService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::CreditNoteService
- Defined in:
- lib/stripe/services/credit_note_service.rb
Defined Under Namespace
Classes: CreateParams, ListParams, PreviewParams, RetrieveParams, UpdateParams, VoidCreditNoteParams
Instance Attribute Summary collapse
-
#line_items ⇒ Object
readonly
Returns the value of attribute line_items.
-
#preview_lines ⇒ Object
readonly
Returns the value of attribute preview_lines.
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Object
Issue a credit note to adjust the amount of a finalized invoice.
-
#initialize(requestor) ⇒ CreditNoteService
constructor
A new instance of CreditNoteService.
-
#list(params = {}, opts = {}) ⇒ Object
Returns a list of credit notes.
-
#preview(params = {}, opts = {}) ⇒ Object
Get a preview of a credit note without creating it.
-
#retrieve(id, params = {}, opts = {}) ⇒ Object
Retrieves the credit note object with the given identifier.
-
#update(id, params = {}, opts = {}) ⇒ Object
Updates an existing credit note.
-
#void_credit_note(id, params = {}, opts = {}) ⇒ Object
Marks a credit note as void.
Methods inherited from StripeService
Constructor Details
#initialize(requestor) ⇒ CreditNoteService
Returns a new instance of CreditNoteService.
8 9 10 11 12 |
# File 'lib/stripe/services/credit_note_service.rb', line 8 def initialize(requestor) super(requestor) @line_items = Stripe::CreditNoteLineItemService.new(@requestor) @preview_lines = Stripe::CreditNotePreviewLinesService.new(@requestor) end |
Instance Attribute Details
#line_items ⇒ Object (readonly)
Returns the value of attribute line_items.
6 7 8 |
# File 'lib/stripe/services/credit_note_service.rb', line 6 def line_items @line_items end |
#preview_lines ⇒ Object (readonly)
Returns the value of attribute preview_lines.
6 7 8 |
# File 'lib/stripe/services/credit_note_service.rb', line 6 def preview_lines @preview_lines end |
Instance 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.
397 398 399 400 401 402 403 404 405 |
# File 'lib/stripe/services/credit_note_service.rb', line 397 def create(params = {}, opts = {}) request( method: :post, path: "/v1/credit_notes", params: params, opts: opts, base_address: :api ) end |
#list(params = {}, opts = {}) ⇒ Object
Returns a list of credit notes.
408 409 410 411 412 413 414 415 416 |
# File 'lib/stripe/services/credit_note_service.rb', line 408 def list(params = {}, opts = {}) request( method: :get, path: "/v1/credit_notes", params: params, opts: opts, base_address: :api ) end |
#preview(params = {}, opts = {}) ⇒ Object
Get a preview of a credit note without creating it.
419 420 421 422 423 424 425 426 427 |
# File 'lib/stripe/services/credit_note_service.rb', line 419 def preview(params = {}, opts = {}) request( method: :get, path: "/v1/credit_notes/preview", params: params, opts: opts, base_address: :api ) end |
#retrieve(id, params = {}, opts = {}) ⇒ Object
Retrieves the credit note object with the given identifier.
430 431 432 433 434 435 436 437 438 |
# File 'lib/stripe/services/credit_note_service.rb', line 430 def retrieve(id, params = {}, opts = {}) request( method: :get, path: format("/v1/credit_notes/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts, base_address: :api ) end |
#update(id, params = {}, opts = {}) ⇒ Object
Updates an existing credit note.
441 442 443 444 445 446 447 448 449 |
# File 'lib/stripe/services/credit_note_service.rb', line 441 def update(id, params = {}, opts = {}) request( method: :post, path: format("/v1/credit_notes/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts, base_address: :api ) 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).
452 453 454 455 456 457 458 459 460 |
# File 'lib/stripe/services/credit_note_service.rb', line 452 def void_credit_note(id, params = {}, opts = {}) request( method: :post, path: format("/v1/credit_notes/%<id>s/void", { id: CGI.escape(id) }), params: params, opts: opts, base_address: :api ) end |