Collect payment details before creating an Intent
The Payment Element allows you to accept multiple payment methods using a single integration. In this integration, learn how to build a custom payment flow where you render the Payment Element, create the PaymentIntent, and confirm the payment from the buyer’s browser. If you prefer to confirm the payment from the server instead, see Finalize payments on the server.
Set up StripeServer-side
First, register for a Stripe account and then use the Dashboard to create an account name. You can always edit your account name later.
Use our official libraries to access the Stripe API from your application:
Enable payment methods
Stripe doesn’t currently support BLIK for this integration path, and US bank account support is in limited beta. For access to US bank account payments, contact us
View your payment methods settings and enable the payment methods you want to support. You need at least one payment method enabled to create a PaymentIntent.
By default, Stripe enables cards and other prevalent payment methods that can help you reach more customers, but we recommend turning on additional payment methods that are relevant for your business and customers. See Payment method integration options for product and payment method support, and our pricing page for fees.
Collect payment detailsClient-side
You’re ready to collect payment details on the client with the Payment Element. The Payment Element is a prebuilt UI component that simplifies collecting payment details for a variety of payment methods.
The Payment Element contains an iframe that securely sends the payment information to Stripe over an HTTPS connection. The checkout page address must also start with https://
rather than http://
for your integration to work.
You can test your integration without using HTTPS. Enable it when you’re ready to accept live payments.
The Payment Element renders a dynamic form that allows your customer to pick a payment method. The form automatically collects all necessary payments details for the payment method selected by the customer.
You can customize the Payment Element to match the design of your site by passing the appearance object into options
when creating the Elements
provider.
By default, the Payment Element only collects the necessary billing address details. If you need to collect a customer’s full billing address (for example, for calculating the tax for digital goods and services) use the Address Element in billing mode.
Create a PaymentIntentServer-side
When the customer submits your payment form, use a PaymentIntent to facilitate the confirmation and payment process. Create a PaymentIntent on your server with an amount
, currency
, and automatic_payment_methods
enabled. Always decide how much to charge on the server-side, a trusted environment, as opposed to the client-side. This prevents malicious customers from choosing their own prices.
Included on a PaymentIntent is a client secret. Return this value to your client for Stripe.js to use to securely complete the payment process.
Submit the payment to StripeClient-side
Use stripe.confirmPayment to complete the payment using details from the Payment Element.
Provide a return_url to this function to indicate where Stripe should redirect the user after they complete the payment. Your user might be initially redirected to an intermediate site, like a bank authorization page, before being redirected to the return_url
. Card payments immediately redirect to the return_url
when a payment is successful.
If you don’t want to redirect for card payments after payment completion, you can set redirect to if_required
. This only redirects customers that check out with redirect-based payment methods.