helenye-stripe ce8d7ca4cc
Add methods for dynamically referenced constants (#1327)
* Update dynamic constant references

* Manual additionsg

* Fix lint

* Use const_Get

* Remove puts
2024-02-09 17:15:39 -08:00

112 lines
3.7 KiB
Ruby

# 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"
def self.object_name
"refund"
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 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
# 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/%<refund>s/cancel", { refund: CGI.escape(refund) }),
params: params,
opts: opts
)
end
def self.list(filters = {}, opts = {})
request_stripe_object(
method: :get,
path: format("/v1/refunds"),
params: filters,
opts: opts
)
end
# 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.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/refunds", params: params, opts: opts)
end
# 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.
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
def test_helpers
TestHelpers.new(self)
end
class TestHelpers < APIResourceTestHelpers
RESOURCE_CLASS = Refund
def self.resource_class
"Refund"
end
# 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/%<refund>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/%<refund>s/expire", { refund: CGI.escape(@resource["id"]) }),
params: params,
opts: opts
)
end
end
end
end