Payment status updates
Monitor and verify payment status, so that you can respond to successful and failed payments.
PaymentIntents update in response to actions taken by the customer or payment method. Your integration can inspect the PaymentIntent to determine the status of the payment process, so that you can take business actions or respond to states that require further intervention.
You can also use the Stripe Dashboard to configure your account to email you about payment status, such as successful payments. Change your email notifications in your user settings.
Check PaymentIntent status on the client
When completing a payment on the client with the confirmCardPayment function, you can inspect the returned PaymentIntent to determine its current status:
(async () => { const {paymentIntent, error} = await stripe.confirmCardPayment(clientSecret); if (error) { // Handle error here } else if (paymentIntent && paymentIntent.status === 'succeeded') { // Handle successful payment here } })();
The following are the possible outcomes of using the confirmCardPayment
function:
Event | What Happened | Expected Integration |
---|---|---|
Resolves with a PaymentIntent | The customer completed payment on your checkout page | Inform the customer that their payment succeeded |
Resolves with an error | The customer’s payment failed on your checkout page | Display an error message and prompt your customer to attempt payment again |
The promise returned by confirmCardPayment
resolves when the payment process has either completed or failed with an error. When it completes successfully and returns a PaymentIntent, the status is always succeeded
(or requires_
if capturing later). When the payment requires an additional step such as authentication, the promise doesn’t resolve until that step is either complete or has timed out.
Check PaymentIntent status on the client without using confirmCardPayment
To check the status of a PaymentIntent without using the confirmCardPayment
function, retrieve it independently by using the retrievePaymentIntent function and passing in the client secret.
The following are some possible statuses of the PaymentIntent following a confirmation:
What Happened | Expected PaymentIntent Status |
---|---|
The customer completed payment on your checkout page | succeeded |
The customer didn’t complete the checkout | requires_ |
The customer’s payment failed on your checkout page | requires_ |
Read more about the PaymentIntent statuses.
(async () => { const {paymentIntent} = await stripe.retrievePaymentIntent(clientSecret); if (paymentIntent && paymentIntent.status === 'succeeded') { // Handle successful payment here } else { // Handle unsuccessful, processing, or canceled payments and API errors here } })();
Monitor a PaymentIntent with webhooks
Stripe can send webhook events to your server to notify you when the status of a PaymentIntent changes, which you can use for purposes such as determining when to fulfill goods and services.
Don’t attempt to handle order fulfillment on the client side because customers can leave the page after payment is complete but before the fulfillment process initiates. Instead, use webhooks to monitor the payment_
event and handle its completion asynchronously instead of attempting to initiate fulfillment on the client side.
Caution
It’s technically possible to use polling instead of webhooks to monitor for changes caused by asynchronous operations—repeatedly retrieving a PaymentIntent so that you can check its status—but doing so is much less reliable and might cause rate limiiting issues. Stripe enforces rate limiting on API requests, so exercise caution if you decide to use polling.
To handle a webhook event, create a route on your server and configure a corresponding webhook endpoint in the Dashboard. Stripe sends the payment_
event when a payment succeeds, and the payment_
event when a payment fails.
The webhook payload includes the PaymentIntent object. The following example shows how to handle both events:
When payment is unsuccessful, you can find more details by inspecting the PaymentIntent’s last_
property. You can notify the customer that their payment didn’t complete and encourage them to try again with a different payment method. Reuse the same PaymentIntent to continue tracking the customer’s purchase.
Handling specific webhook events
The following list describes how to handle webhook events:
Event | Description | Next steps |
---|---|---|
processing | The customer’s payment was submitted to Stripe successfully. Only applicable to payment methods with delayed success confirmation. | Wait for the initiated payment to succeed or fail. |
succeeded | The customer’s payment succeeded | Fulfill the purchased goods or services |
amount_ | The customer’s payment is authorized and ready for capture | Capture the funds that are available for payment |
payment_ | The customer’s payment was declined by a card network or otherwise expired | Reach out to your customer through email or push notification and prompt them to provide another payment method |
To test webhooks locally, you can use Stripe CLI. After you install it, you can forward events to your server:
stripe listen --forward-to localhost:4242/webhook Ready! Your webhook signing secret is '{{WEBHOOK_SIGNING_SECRET}}' (^C to quit)
Learn more about setting up webhooks.
Identifying charges on a PaymentIntent
When you attempt to collect payment from a customer, the PaymentIntent creates a Charge. To get the ID of the most recent charge, inspect the PaymentIntent’s latest_charge property:
To view all of the charges associated with a PaymentIntent, including any unsuccessful charges, list all charges and specify the payment_
parameter.
Handling next actions
Some payment methods require additional steps, such as authentication, to complete the payment process. Stripe.js handles these automatically when confirming the PaymentIntent, but if you have an advanced integration, you might want to handle these manually.
The PaymentIntent’s next_action property exposes the next step that your integration must handle to complete the payment. The type of possible next actions can differ between various payment methods. You can find a full list of possible next actions in the API documentation.
You can refer to the payment methods documentation for more details about how to handle their required next actions.