Class: Stripe::Charge
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Charge
- Extended by:
- APIOperations::Create, APIOperations::List, APIOperations::Search
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/charge.rb
Overview
The ‘Charge` object represents a single attempt to move money into your Stripe account. PaymentIntent confirmation is the most common way to create Charges, but transferring money to a different Stripe account through Connect also creates Charges. Some legacy payment flows create Charges directly, which is not recommended for new integrations.
Constant Summary collapse
- OBJECT_NAME =
"charge"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary
Attributes inherited from APIResource
Class Method Summary collapse
-
.capture(charge, params = {}, opts = {}) ⇒ Object
Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.
- .search(params = {}, opts = {}) ⇒ Object
- .search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
Instance Method Summary collapse
-
#capture(params = {}, opts = {}) ⇒ Object
Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::Search
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
Class Method Details
.capture(charge, params = {}, opts = {}) ⇒ Object
Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.
Uncaptured payments expire a set number of days after they are created ([7 by default](stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail.
Don’t use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](stripe.com/docs/api/payment_intents/capture).
36 37 38 39 40 41 42 43 |
# File 'lib/stripe/resources/charge.rb', line 36 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 |
.search(params = {}, opts = {}) ⇒ Object
45 46 47 |
# File 'lib/stripe/resources/charge.rb', line 45 def self.search(params = {}, opts = {}) _search("/v1/charges/search", params, opts) end |
.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
49 50 51 |
# File 'lib/stripe/resources/charge.rb', line 49 def self.search_auto_paging_each(params = {}, opts = {}, &blk) search(params, opts).auto_paging_each(&blk) end |
Instance Method Details
#capture(params = {}, opts = {}) ⇒ Object
Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.
Uncaptured payments expire a set number of days after they are created ([7 by default](stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail.
Don’t use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](stripe.com/docs/api/payment_intents/capture).
22 23 24 25 26 27 28 29 |
# File 'lib/stripe/resources/charge.rb', line 22 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 |