Migrate to the Express Checkout Element
Migrate your existing integration with the Payment Request Button Element to the Express Checkout Element.
The Payment Request Button Element allows you to accept card payments only through Apple Pay, Google Pay, or Link. When you migrate to the Express Checkout Element, you can accept card or wallet payments through one or more payment buttons, including PayPal. See the comparison guide for more details.
If your existing integration uses | Do the following |
---|---|
Payment Intents API to create and track payments or save card details during a payment | Follow the steps in this guide to use the Express Checkout Element. |
Charges API with tokens | Migrate to the Payment Intents API before proceeding. |
Enable payment methods
Enable the payment methods you want to support in your payment methods settings. You must enable at least one payment method.
By default, Stripe enables cards and other common payment methods. You can enable additional payment methods that are relevant for your business and customers. See the Payment method support for product and payment method support and our pricing page for fees.
Update Elements instanceClient-side
Next, update your client-side code to pass the mode (payment), amount, and currency. These values determine which payment methods to show to your customers.
For example, if you pass the eur
currency on the PaymentIntent
and enable OXXO in the Dashboard, your customer won’t see OXXO because OXXO doesn’t support eur
payments.
Stripe evaluates the currency, payment method restrictions, and other parameters to determine the list of supported payment methods. We prioritize payment methods that increase conversion and are most relevant to the currency and customer location.
Update your PaymentIntent creation callServer-side
The PaymentIntent
includes the payment methods shown to customers during checkout. You can manage payment methods from the Dashboard. Stripe handles the return of eligible payment methods based on factors such as the transaction’s amount, currency, and payment flow.
If your existing integration supports multiple payment methods or you want to accept payment methods other than cards, you can enable more payment methods in the Dashboard.
Add the Express Checkout ElementClient-side
Replace the Payment Request Button Element with the Express Checkout Element. The examples below demonstrate how to replace PaymentRequestButtonElement
with ExpressCheckoutElement
.
You no longer need to create a paymentRequest
object. Instead, pass the properties through the click
event once.
Update the confirm payment methodClient-side
Listen to the confirm event to handle confirmation. To collect and submit payment information to Stripe, use stripe.confirmPayment instead of individual confirmation methods like stripe.
.
Instead of a PaymentMethod ID, stripe.
uses the Elements instance from the Express Checkout Element and the client secret from the created PaymentIntent
.
When called, stripe.
attempts to complete any required actions, such as authenticating your customers by displaying a 3DS dialog or redirecting them to a bank authorization page. After confirmation completes, users are directed to the return_url that you configured, which corresponds to a page on your website that provides the payment status.
If you want the checkout flow for card payments to redirect only for payment methods that require it, you can set redirect to if_
. This doesn’t apply to the Express Checkout Element.
The example below replaces stripe.
with stripe.
.
Handle post-payment eventsServer-side
Stripe sends a payment_intent.succeeded event when the payment completes. Use the Dashboard webhook tool or follow the webhook guide to receive these events and run actions, such as sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.
Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events is what enables you to accept different types of payment methods with a single integration.
In addition to handling the payment_
event, we recommend handling these other events when collecting payments with the Payment Element:
Event | Description | Action |
---|---|---|
payment_intent.succeeded | Sent when a customer successfully completes a payment. | Send the customer an order confirmation and fulfill their order. |
payment_intent.processing | Sent when a customer successfully initiates a payment, but the payment has yet to complete. This event is most commonly sent when the customer initiates a bank debit. It’s followed by either a payment_ or payment_ event in the future. | Send the customer an order confirmation that indicates their payment is pending. For digital goods, you might want to fulfill the order before waiting for payment to complete. |
payment_intent.payment_failed | Sent when a customer attempts a payment, but the payment fails. | If a payment transitions from processing to payment_ , offer the customer another attempt to pay. |