# File generated from our OpenAPI spec # frozen_string_literal: true module Stripe # 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](https://stripe.com/docs/refunds) class Refund < APIResource extend Stripe::APIOperations::Create extend Stripe::APIOperations::List include Stripe::APIOperations::Save OBJECT_NAME = "refund" # 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. def cancel(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/refunds/%s/cancel", { refund: CGI.escape(self["id"]) }), params: params, opts: opts ) end # 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. def self.cancel(refund, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/refunds/%s/cancel", { refund: CGI.escape(refund) }), params: params, opts: opts ) end def test_helpers TestHelpers.new(self) end class TestHelpers < APIResourceTestHelpers RESOURCE_CLASS = Refund # Expire a refund with a status of requires_action. def self.expire(refund, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/test_helpers/refunds/%s/expire", { refund: CGI.escape(refund) }), params: params, opts: opts ) end # Expire a refund with a status of requires_action. def expire(params = {}, opts = {}) @resource.request_stripe_object( method: :post, path: format("/v1/test_helpers/refunds/%s/expire", { refund: CGI.escape(@resource["id"]) }), params: params, opts: opts ) end end end end