Class: Stripe::PaymentIntent
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::PaymentIntent
- Extended by:
- APIOperations::Create, APIOperations::List, APIOperations::Search
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/payment_intent.rb
Overview
A PaymentIntent guides you through the process of collecting a payment from your customer. We recommend that you create exactly one PaymentIntent for each order or customer session in your system. You can reference the PaymentIntent later to see the history of payment attempts for a particular session.
A PaymentIntent transitions through [multiple statuses](stripe.com/docs/payments/intents#intent-statuses) throughout its lifetime as it interfaces with Stripe.js to perform authentication flows and ultimately creates at most one successful charge.
Related guide: [Payment Intents API](stripe.com/docs/payments/payment-intents)
Constant Summary collapse
- OBJECT_NAME =
"payment_intent"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.apply_customer_balance(intent, params = {}, opts = {}) ⇒ Object
Manually reconcile the remaining amount for a customer_balance PaymentIntent.
-
.cancel(intent, params = {}, opts = {}) ⇒ Object
You can cancel a PaymentIntent object when it’s in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](stripe.com/docs/payments/intents), processing.
-
.capture(intent, params = {}, opts = {}) ⇒ Object
Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture.
-
.confirm(intent, params = {}, opts = {}) ⇒ Object
Confirm that your customer intends to pay with current or provided payment method.
-
.create(params = {}, opts = {}) ⇒ Object
Creates a PaymentIntent object.
-
.increment_authorization(intent, params = {}, opts = {}) ⇒ Object
Perform an incremental authorization on an eligible [PaymentIntent](stripe.com/docs/api/payment_intents/object).
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of PaymentIntents.
- .object_name ⇒ Object
- .search(params = {}, opts = {}) ⇒ Object
- .search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates properties on a PaymentIntent object without confirming.
-
.verify_microdeposits(intent, params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a PaymentIntent object.
Instance Method Summary collapse
-
#apply_customer_balance(params = {}, opts = {}) ⇒ Object
Manually reconcile the remaining amount for a customer_balance PaymentIntent.
-
#cancel(params = {}, opts = {}) ⇒ Object
You can cancel a PaymentIntent object when it’s in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](stripe.com/docs/payments/intents), processing.
-
#capture(params = {}, opts = {}) ⇒ Object
Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture.
-
#confirm(params = {}, opts = {}) ⇒ Object
Confirm that your customer intends to pay with current or provided payment method.
-
#increment_authorization(params = {}, opts = {}) ⇒ Object
Perform an incremental authorization on an eligible [PaymentIntent](stripe.com/docs/api/payment_intents/object).
-
#verify_microdeposits(params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a PaymentIntent object.
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
.apply_customer_balance(intent, params = {}, opts = {}) ⇒ Object
Manually reconcile the remaining amount for a customer_balance PaymentIntent.
38 39 40 41 42 43 44 45 |
# File 'lib/stripe/resources/payment_intent.rb', line 38 def self.apply_customer_balance(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/apply_customer_balance", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
.cancel(intent, params = {}, opts = {}) ⇒ Object
You can cancel a PaymentIntent object when it’s in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](stripe.com/docs/payments/intents), processing.
After it’s canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded.
You can’t cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](stripe.com/docs/api/checkout/sessions/expire) instead.
66 67 68 69 70 71 72 73 |
# File 'lib/stripe/resources/payment_intent.rb', line 66 def self.cancel(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/cancel", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
.capture(intent, params = {}, opts = {}) ⇒ Object
Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture.
Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation.
Learn more about [separate authorization and capture](stripe.com/docs/payments/capture-later).
94 95 96 97 98 99 100 101 |
# File 'lib/stripe/resources/payment_intent.rb', line 94 def self.capture(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/capture", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
.confirm(intent, params = {}, opts = {}) ⇒ Object
Confirm that your customer intends to pay with current or provided payment method. Upon confirmation, the PaymentIntent will attempt to initiate a payment. If the selected payment method requires additional authentication steps, the PaymentIntent will transition to the requires_action status and suggest additional actions via next_action. If payment fails, the PaymentIntent transitions to the requires_payment_method status or the canceled status if the confirmation limit is reached. If payment succeeds, the PaymentIntent will transition to the succeeded status (or requires_capture, if capture_method is set to manual). If the confirmation_method is automatic, payment may be attempted using our [client SDKs](stripe.com/docs/stripe-js/reference#stripe-handle-card-payment) and the PaymentIntent’s [client_secret](stripe.com/docs/api#payment_intent_object-client_secret). After next_actions are handled by the client, no additional confirmation is required to complete the payment. If the confirmation_method is manual, all payment attempts must be initiated using a secret key. If any actions are required for the payment, the PaymentIntent will return to the requires_confirmation state after those actions are completed. Your server needs to then explicitly re-confirm the PaymentIntent to initiate the next payment attempt. There is a variable upper limit on how many times a PaymentIntent can be confirmed. After this limit is reached, any further calls to this endpoint will transition the PaymentIntent to the canceled state.
162 163 164 165 166 167 168 169 |
# File 'lib/stripe/resources/payment_intent.rb', line 162 def self.confirm(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/confirm", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
.create(params = {}, opts = {}) ⇒ Object
Creates a PaymentIntent object.
After the PaymentIntent is created, attach a payment method and [confirm](stripe.com/docs/api/payment_intents/confirm) to continue the payment. Learn more about <a href=“/docs/payments/payment-intents”>the available payment flows with the Payment Intents API.
When you use confirm=true during creation, it’s equivalent to creating and confirming the PaymentIntent in the same call. You can use any parameters available in the [confirm API](stripe.com/docs/api/payment_intents/confirm) when you supply confirm=true.
181 182 183 |
# File 'lib/stripe/resources/payment_intent.rb', line 181 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/payment_intents", params: params, opts: opts) end |
.increment_authorization(intent, params = {}, opts = {}) ⇒ Object
Perform an incremental authorization on an eligible [PaymentIntent](stripe.com/docs/api/payment_intents/object). To be eligible, the PaymentIntent’s status must be requires_capture and [incremental_authorization_supported](stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) must be true.
Incremental authorizations attempt to increase the authorized amount on your customer’s card to the new, higher amount provided. Similar to the initial authorization, incremental authorizations can be declined. A single PaymentIntent can call this endpoint multiple times to further increase the authorized amount.
If the incremental authorization succeeds, the PaymentIntent object returns with the updated [amount](stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). If the incremental authorization fails, a [card_declined](stripe.com/docs/error-codes#card-declined) error returns, and no other fields on the PaymentIntent or Charge update. The PaymentIntent object remains capturable for the previously authorized amount.
Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. After it’s captured, a PaymentIntent can no longer be incremented.
Learn more about [incremental authorizations](stripe.com/docs/terminal/features/incremental-authorizations).
242 243 244 245 246 247 248 249 |
# File 'lib/stripe/resources/payment_intent.rb', line 242 def self.(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/increment_authorization", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of PaymentIntents.
252 253 254 |
# File 'lib/stripe/resources/payment_intent.rb', line 252 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/payment_intents", params: params, opts: opts) end |
.object_name ⇒ Object
23 24 25 |
# File 'lib/stripe/resources/payment_intent.rb', line 23 def self.object_name "payment_intent" end |
.search(params = {}, opts = {}) ⇒ Object
256 257 258 259 260 261 262 263 |
# File 'lib/stripe/resources/payment_intent.rb', line 256 def self.search(params = {}, opts = {}) request_stripe_object( method: :get, path: "/v1/payment_intents/search", params: params, opts: opts ) end |
.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
265 266 267 |
# File 'lib/stripe/resources/payment_intent.rb', line 265 def self.search_auto_paging_each(params = {}, opts = {}, &blk) search(params, opts).auto_paging_each(&blk) end |
.update(id, params = {}, opts = {}) ⇒ Object
Updates properties on a PaymentIntent object without confirming.
Depending on which properties you update, you might need to confirm the PaymentIntent again. For example, updating the payment_method always requires you to confirm the PaymentIntent again. If you prefer to update and confirm at the same time, we recommend updating properties through the [confirm API](stripe.com/docs/api/payment_intents/confirm) instead.
276 277 278 279 280 281 282 283 |
# File 'lib/stripe/resources/payment_intent.rb', line 276 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.verify_microdeposits(intent, params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a PaymentIntent object.
296 297 298 299 300 301 302 303 |
# File 'lib/stripe/resources/payment_intent.rb', line 296 def self.verify_microdeposits(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
Instance Method Details
#apply_customer_balance(params = {}, opts = {}) ⇒ Object
Manually reconcile the remaining amount for a customer_balance PaymentIntent.
28 29 30 31 32 33 34 35 |
# File 'lib/stripe/resources/payment_intent.rb', line 28 def apply_customer_balance(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/apply_customer_balance", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#cancel(params = {}, opts = {}) ⇒ Object
You can cancel a PaymentIntent object when it’s in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](stripe.com/docs/payments/intents), processing.
After it’s canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded.
You can’t cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](stripe.com/docs/api/checkout/sessions/expire) instead.
52 53 54 55 56 57 58 59 |
# File 'lib/stripe/resources/payment_intent.rb', line 52 def cancel(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/cancel", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#capture(params = {}, opts = {}) ⇒ Object
Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture.
Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation.
Learn more about [separate authorization and capture](stripe.com/docs/payments/capture-later).
80 81 82 83 84 85 86 87 |
# File 'lib/stripe/resources/payment_intent.rb', line 80 def capture(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/capture", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#confirm(params = {}, opts = {}) ⇒ Object
Confirm that your customer intends to pay with current or provided payment method. Upon confirmation, the PaymentIntent will attempt to initiate a payment. If the selected payment method requires additional authentication steps, the PaymentIntent will transition to the requires_action status and suggest additional actions via next_action. If payment fails, the PaymentIntent transitions to the requires_payment_method status or the canceled status if the confirmation limit is reached. If payment succeeds, the PaymentIntent will transition to the succeeded status (or requires_capture, if capture_method is set to manual). If the confirmation_method is automatic, payment may be attempted using our [client SDKs](stripe.com/docs/stripe-js/reference#stripe-handle-card-payment) and the PaymentIntent’s [client_secret](stripe.com/docs/api#payment_intent_object-client_secret). After next_actions are handled by the client, no additional confirmation is required to complete the payment. If the confirmation_method is manual, all payment attempts must be initiated using a secret key. If any actions are required for the payment, the PaymentIntent will return to the requires_confirmation state after those actions are completed. Your server needs to then explicitly re-confirm the PaymentIntent to initiate the next payment attempt. There is a variable upper limit on how many times a PaymentIntent can be confirmed. After this limit is reached, any further calls to this endpoint will transition the PaymentIntent to the canceled state.
128 129 130 131 132 133 134 135 |
# File 'lib/stripe/resources/payment_intent.rb', line 128 def confirm(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/confirm", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#increment_authorization(params = {}, opts = {}) ⇒ Object
Perform an incremental authorization on an eligible [PaymentIntent](stripe.com/docs/api/payment_intents/object). To be eligible, the PaymentIntent’s status must be requires_capture and [incremental_authorization_supported](stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) must be true.
Incremental authorizations attempt to increase the authorized amount on your customer’s card to the new, higher amount provided. Similar to the initial authorization, incremental authorizations can be declined. A single PaymentIntent can call this endpoint multiple times to further increase the authorized amount.
If the incremental authorization succeeds, the PaymentIntent object returns with the updated [amount](stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). If the incremental authorization fails, a [card_declined](stripe.com/docs/error-codes#card-declined) error returns, and no other fields on the PaymentIntent or Charge update. The PaymentIntent object remains capturable for the previously authorized amount.
Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. After it’s captured, a PaymentIntent can no longer be incremented.
Learn more about [incremental authorizations](stripe.com/docs/terminal/features/incremental-authorizations).
209 210 211 212 213 214 215 216 |
# File 'lib/stripe/resources/payment_intent.rb', line 209 def (params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/increment_authorization", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#verify_microdeposits(params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a PaymentIntent object.
286 287 288 289 290 291 292 293 |
# File 'lib/stripe/resources/payment_intent.rb', line 286 def verify_microdeposits(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |