Skip to content
Sign in
An image of the Stripe logo
Create account
Sign in
Home
Payments
Finance automation
Banking as a service
Developer tools
No-code
All products
Home
Payments
Finance automation
Home
Payments
Finance automation
Banking as a service
Developer tools
Overview
    Find your use case
    Payments
    Create Payment Links
    Create a buy button
    Send invoices
    Create subscriptions
    Send quotes
    Accept in-person payments
    Customer experience
    Create a pricing table
    Set up customer portal
    Payouts
    Pay out money
HomeNo-code

Create an embeddable buy button

Use Payment Links to create an embeddable buy button for your website.

Create an embeddable buy button to sell a product, subscription, or accept a payment on your website. Start by selecting an existing link from the Payment Links list view or by creating a new link where you can decide which products to sell and customize the checkout UI. After you’ve created your link, click Buy button to configure the buy button design and generate the code that you can copy and paste into your website.

Customize the button

By default, your buy button uses the same branding and call to action configured for your payment link. You can:

  • Choose between a simple button and a card widget.
  • Set brand colors, shapes, and fonts to match your website.
  • Set the language of the button and payment page to match your website’s language.
  • Customize your button’s call to action.
Customize the buy button

Customize the buy button

Embed the button

Stripe provides an embed code composed of a <script> tag and a <stripe-buy-button> web component. Click Copy code to copy the code and paste it into your website.

If you’re using HTML, paste the embed code into the HTML. If you’re using React, include the script tag in your index.html page to mount the <stripe-buy-button> component.

Caution

The buy button uses your account’s publishable API key. If you revoke the API key, you need to update the embed code with your new publishable API key.

index.html
<body> <h1>Purchase your new kit</h1> <!-- Paste your embed code script here. --> <script async src="https://js.stripe.com/v3/buy-button.js"> </script> <stripe-buy-button buy-button-id=
'{{BUY_BUTTON_ID}}'
publishable-key=
"pk_test_TYooMQauvdEDq54NiTphI7jx"
>
</stripe-buy-button> </body>

Attributes to customize checkout

ParameterDescriptionSyntax
client-reference-idUse client-reference-id to attach a unique string of your choice to the Checkout Session. The string can be a customer ID or a cart ID (or similar) that you use to reconcile the Session with your internal systems. If you pass this parameter to your <stripe-buy-button>, it’s sent in the checkout.session.completed webhook upon payment completion.client-reference-id can be composed of alphanumeric characters, dashes, or underscores, and be any value up to 200 characters. Invalid values are silently dropped, but your payment page continues to work as expected.
customer-emailUse customer-email to prefill the email address on the payment page. When the property is set, the buy button passes it to the Checkout Session’s customer_email attribute. The email address can’t be edited by the customer on the payment page.customer-email must be a valid email. Invalid values are silently dropped, but your payment pages continues to work as expected.

Content Security Policy

If you’ve deployed a Content Security Policy, the policy directives that the buy button requires are:

  • frame-src, https://js.stripe.com
  • script-src, https://js.stripe.com

Limitations

Rendering the buy button requires a website domain. To test the buy button locally, run a local HTTP server to host your website’s index.html file over the localhost domain. To run a local HTTP server, use Python’s SimpleHTTPServer or the http-server npm module.

Track payments

After your customer makes a payment using a payment link, you can see it in the payments overview in the Dashboard.

If you’re new to Stripe, you will receive an email after your first payment. To receive emails for all successful payments, update your notification preferences in your profile settings.

Stripe creates a new guest customer for one-time payments and a new Customer when selling a subscription or saving a payment method for future use.

Read our full guide for more information on configuring the post-payment experience for a buy button or payment link.

Was this page helpful?
Need help? Contact Support.
Watch our developer tutorials.
Check out our product changelog.
Questions? Contact Sales.
Powered by Markdoc
You can unsubscribe at any time. Read our privacy policy.
Stripe Shell
Test mode
Welcome to the Stripe Shell! Stripe Shell is a browser-based shell with the Stripe CLI pre-installed. Login 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. )
The Stripe Shell is best experienced on desktop.
$