Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.
<html><head><title>Buy cool new product</title></head><body><!-- Use action="/create-checkout-session.php" if your server is PHP based. --><formaction="/create-checkout-session"method="POST"><buttontype="submit">Checkout</button></form></body></html>
A Checkout Session is the programmatic representation of what your customer sees when they’re redirected to the payment form. You can configure it with options such as:
You also need to specify success_url, a page on your website that Checkout returns your customer to after they complete the payment. You can optionally provide cancel_url, a page on your website that Checkout returns your customer to if they cancel the payment process.
Checkout Sessions expire 24 hours after creation.
After creating a Checkout Session, redirect your customer to the URL returned in the response.
# This example sets up an endpoint using the Sinatra framework.# Watch this video to get started: https://youtu.be/8aA9Enb8NVc.require'json'require'sinatra'require'stripe'# Set your secret key. Remember to switch to your live secret key in production.# See your keys here: https://dashboard.stripe.com/apikeysStripe.api_key =
mode:'payment',# These placeholder URLs will be replaced in a following step.
By default, Stripe enables cards and other prevalent payment methods that can help you reach more customers, and you can turn on or turn off payment methods right from the Stripe Dashboard. Stripe evaluates the currency, payment method restrictions, and other parameters to determine the list of supported payment methods to show in Checkout.
Test your endpoint by starting your web server (for example, localhost:4242) and running the following command:
curl -X POST -is"http://localhost:4242/create-checkout-session" -d""
You should see a response in your terminal that looks like this:
It’s important for your customer to see a success page after they successfully submit the payment form. Host this success page on your site.
Create a minimal success page:
<html><head><title>Thanks for your order!</title></head><body><h1>Thanks for your order!</h1><p>
We appreciate your business!
If you have any questions, please email
Next, update the Checkout Session creation endpoint to use this new page:
Fill out the payment details with the test card information:
Enter 4242 4242 4242 4242 as the card number.
Enter any future date for card expiry.
Enter any 3-digit number for CVC.
Enter any billing postal code.
You’re redirected to your new success page.
Next, find the new payment in the Stripe Dashboard. Successful payments appear in the Dashboard’s list of payments. When you click a payment, it takes you to the payment details page. The Checkout summary section contains billing information and the list of items purchased, which you can use to manually fulfill the order.
Stripe Checkout doesn’t need configuration or integration changes to enable Apple Pay or Google Pay. Stripe handles these payments the same way as other card payments.
Stripe Checkout doesn’t support Google Pay or Apple Pay for Stripe accounts or customers in India. If your IP address is in India, you can’t test your Google Pay or Apple Pay integration, even if the Stripe account is based outside India.
A Checkout Session displays the Apple Pay button only to customers who can use it. Apple Pay is available when all of the following conditions are true:
Welcome to the Stripe Shell!
Stripe Shell is a browser-based shell with the Stripe CLI pre-installed. Log in to your
Stripe account and press Control + Backtick (`) on your keyboard to start managing your Stripe
resources in test mode.
- View supported Stripe commands:
- Find webhook events:
- Listen for webhook events:
- Call Stripe APIs: stripe [api resource] [operation] (e.g., )