Class: Stripe::Refund
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Refund
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/refund.rb
Overview
Refund objects allow you to refund a previously created charge that isn’t refunded yet. Funds are refunded to the credit or debit card that’s initially charged.
Related guide: [Refunds](stripe.com/docs/refunds)
Defined Under Namespace
Classes: CancelParams, CreateParams, DestinationDetails, ExpireParams, ListParams, NextAction, RetrieveParams, TestHelpers, UpdateParams
Constant Summary collapse
- OBJECT_NAME =
"refund"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Amount, in cents (or local equivalent).
-
#balance_transaction ⇒ Object
readonly
Balance transaction that describes the impact on your account balance.
-
#charge ⇒ Object
readonly
ID of the charge that’s refunded.
-
#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.
-
#description ⇒ Object
readonly
An arbitrary string attached to the object.
-
#destination_details ⇒ Object
readonly
Attribute for field destination_details.
-
#failure_balance_transaction ⇒ Object
readonly
After the refund fails, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction.
-
#failure_reason ⇒ Object
readonly
Provides the reason for the refund failure.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#instructions_email ⇒ Object
readonly
For payment methods without native refund support (for example, Konbini, PromptPay), provide an email address for the customer to receive refund instructions.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object.
-
#next_action ⇒ Object
readonly
Attribute for field next_action.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#payment_intent ⇒ Object
readonly
ID of the PaymentIntent that’s refunded.
-
#reason ⇒ Object
readonly
Reason for the refund, which is either user-provided (‘duplicate`, `fraudulent`, or `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`).
-
#receipt_number ⇒ Object
readonly
This is the transaction number that appears on email receipts sent for this refund.
-
#source_transfer_reversal ⇒ Object
readonly
The transfer reversal that’s associated with the refund.
-
#status ⇒ Object
readonly
Status of the refund.
-
#transfer_reversal ⇒ Object
readonly
This refers to the transfer reversal object if the accompanying transfer reverses.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.cancel(refund, params = {}, opts = {}) ⇒ Object
Cancels a refund with a status of requires_action.
-
.create(params = {}, opts = {}) ⇒ Object
When you create a new refund, you must specify a Charge or a PaymentIntent object on which to create it.
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of all refunds you created.
- .object_name ⇒ Object
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates the refund that you specify by setting the values of the passed parameters.
Instance Method Summary collapse
-
#cancel(params = {}, opts = {}) ⇒ Object
Cancels a refund with a status of requires_action.
- #test_helpers ⇒ Object
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)
Amount, in cents (or local equivalent).
450 451 452 |
# File 'lib/stripe/resources/refund.rb', line 450 def amount @amount end |
#balance_transaction ⇒ Object (readonly)
Balance transaction that describes the impact on your account balance.
453 454 455 |
# File 'lib/stripe/resources/refund.rb', line 453 def balance_transaction @balance_transaction end |
#charge ⇒ Object (readonly)
ID of the charge that’s refunded.
456 457 458 |
# File 'lib/stripe/resources/refund.rb', line 456 def charge @charge end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
459 460 461 |
# File 'lib/stripe/resources/refund.rb', line 459 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).
462 463 464 |
# File 'lib/stripe/resources/refund.rb', line 462 def currency @currency end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. You can use this for displaying to users (available on non-card refunds only).
465 466 467 |
# File 'lib/stripe/resources/refund.rb', line 465 def description @description end |
#destination_details ⇒ Object (readonly)
Attribute for field destination_details
468 469 470 |
# File 'lib/stripe/resources/refund.rb', line 468 def destination_details @destination_details end |
#failure_balance_transaction ⇒ Object (readonly)
After the refund fails, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction.
471 472 473 |
# File 'lib/stripe/resources/refund.rb', line 471 def failure_balance_transaction @failure_balance_transaction end |
#failure_reason ⇒ Object (readonly)
Provides the reason for the refund failure. Possible values are: ‘lost_or_stolen_card`, `expired_or_canceled_card`, `charge_for_pending_refund_disputed`, `insufficient_funds`, `declined`, `merchant_request`, or `unknown`.
474 475 476 |
# File 'lib/stripe/resources/refund.rb', line 474 def failure_reason @failure_reason end |
#id ⇒ Object (readonly)
Unique identifier for the object.
477 478 479 |
# File 'lib/stripe/resources/refund.rb', line 477 def id @id end |
#instructions_email ⇒ Object (readonly)
For payment methods without native refund support (for example, Konbini, PromptPay), provide an email address for the customer to receive refund instructions.
480 481 482 |
# File 'lib/stripe/resources/refund.rb', line 480 def instructions_email @instructions_email 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.
483 484 485 |
# File 'lib/stripe/resources/refund.rb', line 483 def @metadata end |
#next_action ⇒ Object (readonly)
Attribute for field next_action
486 487 488 |
# File 'lib/stripe/resources/refund.rb', line 486 def next_action @next_action end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
489 490 491 |
# File 'lib/stripe/resources/refund.rb', line 489 def object @object end |
#payment_intent ⇒ Object (readonly)
ID of the PaymentIntent that’s refunded.
492 493 494 |
# File 'lib/stripe/resources/refund.rb', line 492 def payment_intent @payment_intent end |
#reason ⇒ Object (readonly)
Reason for the refund, which is either user-provided (‘duplicate`, `fraudulent`, or `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`).
495 496 497 |
# File 'lib/stripe/resources/refund.rb', line 495 def reason @reason end |
#receipt_number ⇒ Object (readonly)
This is the transaction number that appears on email receipts sent for this refund.
498 499 500 |
# File 'lib/stripe/resources/refund.rb', line 498 def receipt_number @receipt_number end |
#source_transfer_reversal ⇒ Object (readonly)
The transfer reversal that’s associated with the refund. Only present if the charge came from another Stripe account.
501 502 503 |
# File 'lib/stripe/resources/refund.rb', line 501 def source_transfer_reversal @source_transfer_reversal end |
#status ⇒ Object (readonly)
Status of the refund. This can be ‘pending`, `requires_action`, `succeeded`, `failed`, or `canceled`. Learn more about [failed refunds](stripe.com/docs/refunds#failed-refunds).
504 505 506 |
# File 'lib/stripe/resources/refund.rb', line 504 def status @status end |
#transfer_reversal ⇒ Object (readonly)
This refers to the transfer reversal object if the accompanying transfer reverses. This is only applicable if the charge was created using the destination parameter.
507 508 509 |
# File 'lib/stripe/resources/refund.rb', line 507 def transfer_reversal @transfer_reversal end |
Class Method Details
.cancel(refund, params = {}, opts = {}) ⇒ Object
Cancels a refund with a status of requires_action.
You can’t cancel refunds in other states. Only refunds for payment methods that require customer action can enter the requires_action state.
524 525 526 527 528 529 530 531 |
# File 'lib/stripe/resources/refund.rb', line 524 def self.cancel(refund, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/refunds/%<refund>s/cancel", { refund: CGI.escape(refund) }), params: params, opts: opts ) end |
.create(params = {}, opts = {}) ⇒ Object
When you create a new refund, you must specify a Charge or a PaymentIntent object on which to create it.
Creating a new refund will refund a charge that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged.
You can optionally refund only part of a charge. You can do so multiple times, until the entire charge has been refunded.
Once entirely refunded, a charge can’t be refunded again. This method will raise an error when called on an already-refunded charge, or when trying to refund more money than is left on a charge.
544 545 546 |
# File 'lib/stripe/resources/refund.rb', line 544 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/refunds", params: params, opts: opts) end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of all refunds you created. We return the refunds in sorted order, with the most recent refunds appearing first. The 10 most recent refunds are always available by default on the Charge object.
549 550 551 |
# File 'lib/stripe/resources/refund.rb', line 549 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/refunds", params: params, opts: opts) end |
.object_name ⇒ Object
16 17 18 |
# File 'lib/stripe/resources/refund.rb', line 16 def self.object_name "refund" end |
.update(id, params = {}, opts = {}) ⇒ Object
Updates the refund that you specify by setting the values of the passed parameters. Any parameters that you don’t provide remain unchanged.
This request only accepts metadata as an argument.
556 557 558 559 560 561 562 563 |
# File 'lib/stripe/resources/refund.rb', line 556 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/refunds/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
Instance Method Details
#cancel(params = {}, opts = {}) ⇒ Object
Cancels a refund with a status of requires_action.
You can’t cancel refunds in other states. Only refunds for payment methods that require customer action can enter the requires_action state.
512 513 514 515 516 517 518 519 |
# File 'lib/stripe/resources/refund.rb', line 512 def cancel(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/refunds/%<refund>s/cancel", { refund: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#test_helpers ⇒ Object
565 566 567 |
# File 'lib/stripe/resources/refund.rb', line 565 def test_helpers TestHelpers.new(self) end |