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.
Welcome to the Stripe Shell!
Stripe Shell is a browser-based shell with the Stripe CLI pre-installed. Login to Stripe
docs and press Control + Backtick on your keyboard to start managing your Stripe resources
in test mode.
- View supported commands:
- Find webhook events:
- Listen for webhook events:
- Call Stripe APIs: stripe [api resource] [operation] (e.g. )