Class: Stripe::Charge
- Inherits:
 - 
      APIResource
      
        
- Object
 - StripeObject
 - APIResource
 - Stripe::Charge
 
 
- Extended by:
 - APIOperations::Create, APIOperations::List, APIOperations::NestedResource, 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
Attributes inherited from StripeObject
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.
 - 
  
    
      .create(params = {}, opts = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
This method is no longer recommended—use the [Payment Intents API](stripe.com/docs/api/payment_intents) to initiate a new payment instead.
 - 
  
    
      .list(filters = {}, opts = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a list of charges you’ve previously created.
 - .object_name ⇒ Object
 - .search(params = {}, opts = {}) ⇒ Object
 - .search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
 - 
  
    
      .update(id, params = {}, opts = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Updates the specified charge by setting the values of the parameters passed.
 
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::NestedResource
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).
      42 43 44 45 46 47 48 49  | 
    
      # File 'lib/stripe/resources/charge.rb', line 42 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  | 
  
.create(params = {}, opts = {}) ⇒ Object
This method is no longer recommended—use the [Payment Intents API](stripe.com/docs/api/payment_intents) to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge object used to request payment.
      54 55 56  | 
    
      # File 'lib/stripe/resources/charge.rb', line 54 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/charges", params: params, opts: opts) end  | 
  
.list(filters = {}, opts = {}) ⇒ Object
Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.
      59 60 61  | 
    
      # File 'lib/stripe/resources/charge.rb', line 59 def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/charges", params: filters, opts: opts) end  | 
  
.object_name ⇒ Object
      17 18 19  | 
    
      # File 'lib/stripe/resources/charge.rb', line 17 def self.object_name "charge" end  | 
  
.search(params = {}, opts = {}) ⇒ Object
      63 64 65  | 
    
      # File 'lib/stripe/resources/charge.rb', line 63 def self.search(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/charges/search", params: params, opts: opts) end  | 
  
.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
      67 68 69  | 
    
      # File 'lib/stripe/resources/charge.rb', line 67 def self.search_auto_paging_each(params = {}, opts = {}, &blk) search(params, opts).auto_paging_each(&blk) end  | 
  
.update(id, params = {}, opts = {}) ⇒ Object
Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
      72 73 74 75 76 77 78 79  | 
    
      # File 'lib/stripe/resources/charge.rb', line 72 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/charges/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) 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).
      28 29 30 31 32 33 34 35  | 
    
      # File 'lib/stripe/resources/charge.rb', line 28 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  |