Accept a payment
Securely accept payments online.
Build a payment form or use a prebuilt checkout page to start accepting online payments.
Build a checkout page on your website using Stripe Elements and Checkout Sessions, an integration that manages tax, discounts, shipping rates, and more.
Set up the serverServer-side
Before you begin, you need to register for a Stripe account.
Use the official Stripe libraries to access the API from your application.
Set the SDK to use at least the 2025-03-31.
API version.
Create a Checkout SessionServer-side
Add an endpoint on your server that creates a Checkout Session and returns its client secret to your front end. A Checkout Session represents your customer’s session as they pay for one-time purchases or subscriptions. Checkout Sessions expire 24 hours after creation.
Collect payment detailsClient-side
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.
Test your integration
- Navigate to your checkout page.
- Fill out the payment details with a payment method from the following table. For card payments:
- Enter any future date for card expiry.
- Enter any 3-digit number for CVC.
- Enter any billing postal code.
- Submit the payment to Stripe.
- Go to the Dashboard and look for the payment on the Transactions page. If your payment succeeded, you’ll see it in that list.
- Click your payment to see more details, like billing information and the list of purchased items. You can use this information to fulfill the order.
See Testing for additional information to test your integration.
OptionalCreate products and prices
Before you create a Checkout Session, you can create Products and Prices upfront. Use products to represent different physical goods or levels of service, and Prices to represent each product’s pricing.
For example, you can create a T-shirt as a product with a price of 20 USD. This allows you to update and add prices without needing to change the details of your underlying products. You can either create products and prices with the Stripe Dashboard or API. Learn more about how products and prices work.
Each price you create has an ID. When you create a Checkout Session, reference the price ID and quantity. If you’re selling in multiple currencies, make your Price multi-currency. Checkout automatically determines the customer’s local currency and presents that currency if the Price supports it.
OptionalPrefill customer dataServer-side
If you’ve already collected your customer’s email and want to prefill it in the Checkout Session for them, pass customer_email when creating a Checkout Session.
OptionalSave payment method details
Learn how to accept a payment and save your customer’s payment details for future purchases.
OptionalListen for Checkout Session changes
Listen for Checkout Session changes 
You can listen for changes to the Checkout Session by adding an event listener on the change
event with checkout.on.
OptionalCollect billing and shipping addresses
Collect a billing address 
By default, a Checkout Session collects the minimal billing details required for payment through the Payment Element.
Using the Billing Address Element 
You can collect complete billing addresses using the Billing Address Element.
First, pass billing_address_collection=required when you create the Checkout Session.
Using a custom form 
You can build your own form to collect billing addresses.
- If your checkout page has a distinct address collection step before confirmation, call updateBillingAddress when your customer submits the address.
- Otherwise, you can submit the address when your customer clicks the “pay” button by passing billingAddress to confirm.
Collect partial billing addresses
To collect partial billing addresses, such as only the country and postal code, pass billing_address_collection=auto.
When collecting partial billing addresses, you must collect addresses manually. By default, the Payment Element automatically collects the minimal billing details required for payment. To avoid double collection of billing details, pass fields.billingDetails=never when creating the Payment Element. If you only intend to collect a subset of billing details (such as the customer’s name), pass never
for only the fields you intend to collect yourself.
Collect a shipping address 
To collect a customer’s shipping address, pass the shipping_address_collection parameter when you create the Checkout Session.
When you collect a shipping address, you must also specify which countries to allow shipping to. Configure the allowed_countries property with an array of two-letter ISO country codes.
How to use the Shipping Address Element 
You can collect complete shipping addresses with the Shipping Address Element.
Listen for Checkout Session changes 
You can listen for changes to the Checkout Session by adding an event listener to handle address-related changes.
Use a custom form 
You can build your own form to collect shipping addresses.
- If your checkout page has a distinct address collection step before confirmation, call updateShippingAddress when your customer submits the address.
- Otherwise, you can submit the address when your customer clicks the “pay” button by passing shippingAddress to confirm.
OptionalSeparate authorization and captureServer-side
Stripe supports two-step card payments so you can first authorize a card, then capture funds later. When Stripe authorizes a payment, the card issuer guarantees the funds and places a hold for the payment amount on the customer’s card. You then have a certain amount of time to capture the funds, depending on the card). If you don’t capture the payment before the authorization expires, the payment is cancelled and the issuer releases the held funds.
Separating authorization and capture is useful if you need to take additional actions between confirming that a customer is able to pay and collecting their payment. For example, if you’re selling stock-limited items, you may need to confirm that an item purchased by your customer using Checkout is still available before capturing their payment and fulfilling the purchase. Accomplish this using the following workflow:
- Confirm that Stripe authorized the customer’s payment method.
- Consult your inventory management system to confirm that the item is still available.
- Update your inventory management system to indicate that a customer has purchased the item.
- Capture the customer’s payment.
- Inform your customer whether their purchase was successful on your confirmation page.
To indicate that you want to separate authorization and capture, you must set the value of payment_intent_data.capture_method to manual
when creating the Checkout Session. This instructs Stripe to only authorize the amount on the customer’s card.
To capture an uncaptured payment, you can use either the Dashboard or the capture endpoint. Programmatically capturing payments requires access to the PaymentIntent created during the Checkout Session, which you can get from the Session object.
OptionalCustomer account managementNo code
Let your customers manage their own accounts by sharing a link to your customer portal. The customer portal lets customers log in with their email to manage subscriptions, update payment methods, and so on.
OptionalOrder fulfillment
Learn how to programmatically get a notification when a customer pays.