Class: Stripe::PaymentIntentService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::PaymentIntentService
- Defined in:
- lib/stripe/services/payment_intent_service.rb
Defined Under Namespace
Classes: ApplyCustomerBalanceParams, CancelParams, CaptureParams, ConfirmParams, CreateParams, DecrementAuthorizationParams, IncrementAuthorizationParams, ListParams, RetrieveParams, SearchParams, TriggerActionParams, UpdateParams, VerifyMicrodepositsParams
Instance Attribute Summary collapse
-
#amount_details_line_items ⇒ Object
readonly
Returns the value of attribute amount_details_line_items.
Instance 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](docs.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.
-
#decrement_authorization(intent, params = {}, opts = {}) ⇒ Object
Perform a decremental authorization on an eligible [PaymentIntent](docs.stripe.com/docs/api/payment_intents/object).
-
#increment_authorization(intent, params = {}, opts = {}) ⇒ Object
Perform an incremental authorization on an eligible [PaymentIntent](docs.stripe.com/docs/api/payment_intents/object).
-
#initialize(requestor) ⇒ PaymentIntentService
constructor
A new instance of PaymentIntentService.
-
#list(params = {}, opts = {}) ⇒ Object
Returns a list of PaymentIntents.
-
#retrieve(intent, params = {}, opts = {}) ⇒ Object
Retrieves the details of a PaymentIntent that has previously been created.
-
#search(params = {}, opts = {}) ⇒ Object
Search for PaymentIntents you’ve previously created using Stripe’s [Search Query Language](docs.stripe.com/docs/search#search-query-language).
-
#trigger_action(intent, params = {}, opts = {}) ⇒ Object
Trigger an external action on a PaymentIntent.
-
#update(intent, params = {}, opts = {}) ⇒ Object
Updates properties on a PaymentIntent object without confirming.
-
#verify_microdeposits(intent, params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a PaymentIntent object.
Methods inherited from StripeService
Constructor Details
#initialize(requestor) ⇒ PaymentIntentService
Returns a new instance of PaymentIntentService.
8 9 10 11 |
# File 'lib/stripe/services/payment_intent_service.rb', line 8 def initialize(requestor) super @amount_details_line_items = Stripe::PaymentIntentAmountDetailsLineItemService.new(@requestor) end |
Instance Attribute Details
#amount_details_line_items ⇒ Object (readonly)
Returns the value of attribute amount_details_line_items.
6 7 8 |
# File 'lib/stripe/services/payment_intent_service.rb', line 6 def amount_details_line_items @amount_details_line_items end |
Instance Method Details
#apply_customer_balance(intent, params = {}, opts = {}) ⇒ Object
Manually reconcile the remaining amount for a customer_balance PaymentIntent.
12717 12718 12719 12720 12721 12722 12723 12724 12725 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12717 def apply_customer_balance(intent, params = {}, opts = {}) request( method: :post, path: format("/v1/payment_intents/%<intent>s/apply_customer_balance", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) 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](docs.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](docs.stripe.com/docs/api/checkout/sessions/expire) instead.
12732 12733 12734 12735 12736 12737 12738 12739 12740 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12732 def cancel(intent, params = {}, opts = {}) request( method: :post, path: format("/v1/payment_intents/%<intent>s/cancel", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) 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](docs.stripe.com/docs/payments/capture-later).
12747 12748 12749 12750 12751 12752 12753 12754 12755 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12747 def capture(intent, params = {}, opts = {}) request( method: :post, path: format("/v1/payment_intents/%<intent>s/capture", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) 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](docs.stripe.com/docs/stripe-js/reference#stripe-handle-card-payment) and the PaymentIntent’s [client_secret](docs.stripe.com/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.
12787 12788 12789 12790 12791 12792 12793 12794 12795 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12787 def confirm(intent, params = {}, opts = {}) request( method: :post, path: format("/v1/payment_intents/%<intent>s/confirm", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) end |
#create(params = {}, opts = {}) ⇒ Object
Creates a PaymentIntent object.
After the PaymentIntent is created, attach a payment method and [confirm](docs.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](docs.stripe.com/docs/api/payment_intents/confirm) when you supply confirm=true.
12807 12808 12809 12810 12811 12812 12813 12814 12815 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12807 def create(params = {}, opts = {}) request( method: :post, path: "/v1/payment_intents", params: params, opts: opts, base_address: :api ) end |
#decrement_authorization(intent, params = {}, opts = {}) ⇒ Object
Perform a decremental authorization on an eligible [PaymentIntent](docs.stripe.com/docs/api/payment_intents/object). To be eligible, the PaymentIntent’s status must be requires_capture and [decremental_authorization.status](docs.stripe.com/docs/api/charges/object#charge_object-payment_method_details-card-decremental_authorization) must be available.
Decremental authorizations decrease the authorized amount on your customer’s card to the new, lower amount provided. A single PaymentIntent can call this endpoint multiple times to further decrease the authorized amount.
After decrement, the PaymentIntent object returns with the updated [amount](docs.stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). The PaymentIntent will now be capturable up to the new authorized amount.
Each PaymentIntent can have a maximum of 10 decremental or incremental authorization attempts, including declines. After it’s fully captured, a PaymentIntent can no longer be decremented.
12833 12834 12835 12836 12837 12838 12839 12840 12841 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12833 def (intent, params = {}, opts = {}) request( method: :post, path: format("/v1/payment_intents/%<intent>s/decrement_authorization", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) end |
#increment_authorization(intent, params = {}, opts = {}) ⇒ Object
Perform an incremental authorization on an eligible [PaymentIntent](docs.stripe.com/docs/api/payment_intents/object). To be eligible, the PaymentIntent’s status must be requires_capture and [incremental_authorization_supported](docs.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](docs.stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). If the incremental authorization fails, a [card_declined](docs.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](docs.stripe.com/docs/terminal/features/incremental-authorizations).
12867 12868 12869 12870 12871 12872 12873 12874 12875 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12867 def (intent, params = {}, opts = {}) request( method: :post, path: format("/v1/payment_intents/%<intent>s/increment_authorization", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) end |
#list(params = {}, opts = {}) ⇒ Object
Returns a list of PaymentIntents.
12878 12879 12880 12881 12882 12883 12884 12885 12886 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12878 def list(params = {}, opts = {}) request( method: :get, path: "/v1/payment_intents", params: params, opts: opts, base_address: :api ) end |
#retrieve(intent, params = {}, opts = {}) ⇒ Object
Retrieves the details of a PaymentIntent that has previously been created.
You can retrieve a PaymentIntent client-side using a publishable key when the client_secret is in the query string.
If you retrieve a PaymentIntent with a publishable key, it only returns a subset of properties. Refer to the [payment intent](docs.stripe.com/api#payment_intent_object) object reference for more details.
12893 12894 12895 12896 12897 12898 12899 12900 12901 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12893 def retrieve(intent, params = {}, opts = {}) request( method: :get, path: format("/v1/payment_intents/%<intent>s", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) end |
#search(params = {}, opts = {}) ⇒ Object
Search for PaymentIntents you’ve previously created using Stripe’s [Search Query Language](docs.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.
12907 12908 12909 12910 12911 12912 12913 12914 12915 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12907 def search(params = {}, opts = {}) request( method: :get, path: "/v1/payment_intents/search", params: params, opts: opts, base_address: :api ) end |
#trigger_action(intent, params = {}, opts = {}) ⇒ Object
Trigger an external action on a PaymentIntent.
12918 12919 12920 12921 12922 12923 12924 12925 12926 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12918 def trigger_action(intent, params = {}, opts = {}) request( method: :post, path: format("/v1/test/payment_intents/%<intent>s/trigger_action", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) end |
#update(intent, 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](docs.stripe.com/docs/api/payment_intents/confirm) instead.
12935 12936 12937 12938 12939 12940 12941 12942 12943 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12935 def update(intent, params = {}, opts = {}) request( method: :post, path: format("/v1/payment_intents/%<intent>s", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) end |
#verify_microdeposits(intent, params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a PaymentIntent object.
12946 12947 12948 12949 12950 12951 12952 12953 12954 |
# File 'lib/stripe/services/payment_intent_service.rb', line 12946 def verify_microdeposits(intent, params = {}, opts = {}) request( method: :post, path: format("/v1/payment_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(intent) }), params: params, opts: opts, base_address: :api ) end |