mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
45 lines
1.3 KiB
Ruby
45 lines
1.3 KiB
Ruby
# File generated from our OpenAPI spec
|
|
# frozen_string_literal: true
|
|
|
|
module Stripe
|
|
# To charge a credit or a debit card, you create a `Charge` object. You can
|
|
# retrieve and refund individual charges as well as list all charges. Charges
|
|
# are identified by a unique, random ID.
|
|
#
|
|
# Related guide: [Accept a payment with the Charges API](https://stripe.com/docs/payments/accept-a-payment-charges).
|
|
class Charge < APIResource
|
|
extend Stripe::APIOperations::Create
|
|
extend Stripe::APIOperations::List
|
|
extend Stripe::APIOperations::Search
|
|
include Stripe::APIOperations::Save
|
|
|
|
OBJECT_NAME = "charge"
|
|
|
|
def capture(params = {}, opts = {})
|
|
request_stripe_object(
|
|
method: :post,
|
|
path: format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(self["id"]) }),
|
|
params: params,
|
|
opts: opts
|
|
)
|
|
end
|
|
|
|
def self.capture(charge, params = {}, opts = {})
|
|
request_stripe_object(
|
|
method: :post,
|
|
path: format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(charge) }),
|
|
params: params,
|
|
opts: opts
|
|
)
|
|
end
|
|
|
|
def self.search(params = {}, opts = {})
|
|
_search("/v1/charges/search", params, opts)
|
|
end
|
|
|
|
def self.search_auto_paging_each(params = {}, opts = {}, &blk)
|
|
search(params, opts).auto_paging_each(&blk)
|
|
end
|
|
end
|
|
end
|