Retrieve a PaymentIntent
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 object reference for more details.
Parameters
- client_
secretstringRequired if you use a publishable key. The client secret of the PaymentIntent. We require it if you use a publishable key to retrieve the source.
Returns
Returns a PaymentIntent if a valid identifier was provided.
List all PaymentIntents
Returns a list of PaymentIntents.
Parameters
- customerstring
Only return PaymentIntents for the customer that this customer ID specifies.
More parameters
- createdobject
- ending_
beforestring - limitinteger
- starting_
afterstring
Returns
A dictionary with a data
property that contains an array of up to limit
PaymentIntents, starting after PaymentIntent starting_after
. Each entry in the array is a separate PaymentIntent object. If no other PaymentIntents are available, the resulting array is empty.
Cancel a PaymentIntent
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, 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 instead.
Parameters
- cancellation_
reasonstring Reason for canceling this PaymentIntent. Possible values are:
duplicate
,fraudulent
,requested_by_customer
, orabandoned
Returns
Returns a PaymentIntent object if the cancellation succeeds. Returns an error if the PaymentIntent is already canceled or isn’t in a cancelable state.
Capture a PaymentIntent
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.
Parameters
- amount_
to_ captureinteger The amount to capture from the PaymentIntent, which must be less than or equal to the original amount. Any additional amount is automatically refunded. Defaults to the full
amount_capturable
if it’s not provided. - metadataobject
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata
.
More parameters
- application_
fee_ amountintegerConnect only - final_
captureboolean - statement_
descriptorstring - statement_
descriptor_ suffixstring - transfer_
dataobjectConnect only
Returns
Returns a PaymentIntent object with status="succeeded"
if the PaymentIntent is capturable. Returns an error if the PaymentIntent isn’t capturable or if an invalid amount to capture is provided.
Confirm a PaymentIntent
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 and the PaymentIntent’s client_secret. After next_action
s 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.
Parameters
- payment_
methodstring ID of the payment method (a PaymentMethod, Card, or compatible Source object) to attach to this PaymentIntent.
- receipt_
emailstring Email address that the receipt for the resulting payment will be sent to. If
receipt_email
is specified for a payment in live mode, a receipt will be sent regardless of your email settings. - setup_
future_ usageenum Indicates that you intend to make future payments with this PaymentIntent’s payment method.
Providing this parameter will attach the payment method to the PaymentIntent’s Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be attached to a Customer after the transaction completes.
When processing card payments, Stripe also uses
setup_future_usage
to dynamically optimize your payment flow and comply with regional legislation and network rules, such as SCA.If
setup_future_usage
is already set and you are performing a request using a publishable key, you may only update the value fromon_session
tooff_session
. - shippingobject
Shipping information for this PaymentIntent.
More parameters
- capture_
methodenumsecret key only - confirmation_
tokenstring - error_
on_ requires_ actionboolean - mandatestringsecret key only
- mandate_
dataobject - off_
sessionboolean | stringsecret key only - payment_
method_ dataobject - payment_
method_ optionsobjectsecret key only - payment_
method_ typesarray of stringssecret key only - radar_
optionsobjectsecret key only - return_
urlstring - use_
stripe_ sdkboolean
Returns
Returns the resulting PaymentIntent after all possible transitions are applied.