Class: Stripe::ChargeService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::ChargeService
- Defined in:
- lib/stripe/services/charge_service.rb
Defined Under Namespace
Classes: CaptureParams, CreateParams, ListParams, RetrieveParams, SearchParams, UpdateParams
Instance 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(params = {}, opts = {}) ⇒ Object
Returns a list of charges you’ve previously created.
-
#retrieve(charge, params = {}, opts = {}) ⇒ Object
Retrieves the details of a charge that has previously been created.
-
#search(params = {}, opts = {}) ⇒ Object
Search for charges you’ve previously created using Stripe’s [Search Query Language](stripe.com/docs/search#search-query-language).
-
#update(charge, params = {}, opts = {}) ⇒ Object
Updates the specified charge by setting the values of the parameters passed.
Methods inherited from StripeService
#initialize, #request, #request_stream
Constructor Details
This class inherits a constructor from Stripe::StripeService
Instance 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).
1747 1748 1749 1750 1751 1752 1753 1754 1755 |
# File 'lib/stripe/services/charge_service.rb', line 1747 def capture(charge, params = {}, opts = {}) request( method: :post, path: format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(charge) }), params: params, opts: opts, base_address: :api ) 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.
1760 1761 1762 |
# File 'lib/stripe/services/charge_service.rb', line 1760 def create(params = {}, opts = {}) request(method: :post, path: "/v1/charges", params: params, opts: opts, base_address: :api) end |
#list(params = {}, 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.
1765 1766 1767 |
# File 'lib/stripe/services/charge_service.rb', line 1765 def list(params = {}, opts = {}) request(method: :get, path: "/v1/charges", params: params, opts: opts, base_address: :api) end |
#retrieve(charge, params = {}, opts = {}) ⇒ Object
Retrieves the details of a charge that has previously been created. Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information. The same information is returned when creating or refunding the charge.
1770 1771 1772 1773 1774 1775 1776 1777 1778 |
# File 'lib/stripe/services/charge_service.rb', line 1770 def retrieve(charge, params = {}, opts = {}) request( method: :get, path: format("/v1/charges/%<charge>s", { charge: CGI.escape(charge) }), params: params, opts: opts, base_address: :api ) end |
#search(params = {}, opts = {}) ⇒ Object
Search for charges you’ve previously created using Stripe’s [Search Query Language](stripe.com/docs/search#search-query-language). Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
1784 1785 1786 1787 1788 1789 1790 1791 1792 |
# File 'lib/stripe/services/charge_service.rb', line 1784 def search(params = {}, opts = {}) request( method: :get, path: "/v1/charges/search", params: params, opts: opts, base_address: :api ) end |
#update(charge, params = {}, opts = {}) ⇒ Object
Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
1795 1796 1797 1798 1799 1800 1801 1802 1803 |
# File 'lib/stripe/services/charge_service.rb', line 1795 def update(charge, params = {}, opts = {}) request( method: :post, path: format("/v1/charges/%<charge>s", { charge: CGI.escape(charge) }), params: params, opts: opts, base_address: :api ) end |