Esta página ainda não está disponível no idioma desejado. Estamos trabalhando para tornar nossa documentação disponível em mais idiomas e vamos disponibilizar a tradução assim possível.
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.
Localização do cliente
Tamanho
Tema
Layout
Esta demonstração só exibe o Google Pay ou Apple Pay se você tiver um cartão ativo com qualquer uma das carteiras.
// Set your secret key. Remember to switch to your live secret key in production.// See your keys here: https://dashboard.stripe.com/apikeysimport Stripe from'stripe';const stripe =newStripe(
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.
Include the Stripe.js script on your checkout page by adding it to the head of your HTML file. Always load Stripe.js directly from js.stripe.com to remain PCI compliant. Don’t include the script in a bundle or host a copy of it yourself.
You’ll need to update Stripe.js to basil from v3 by including the following script tag <script src="https://js.stripe.com/basil/stripe.js"></script>. Learn more about Stripe.js versioning.
Stripe provides an npm package that you can use to load Stripe.js as a module. See the project on GitHub. Version 7.0.0 or later is required.
Initialize stripe.js.
checkout.js
// Set your publishable key: remember to change this to your live publishable key in production// See your keys here: https://dashboard.stripe.com/apikeysconst stripe =Stripe(
Create a fetchClientSecret function. This function retrieves the client secret from your server and returns a promise that resolves with the client secret. Call initCheckout, passing in fetchClientSecret. initCheckout returns a promise resolving to a checkout instance.
The checkout object acts as the foundation of your checkout page, containing data from the Checkout Session and methods to update the Session.
The object returned by checkout.session() contains your pricing information. We recommend reading and displaying the total, and lineItems from the session in your UI.
This lets you turn on new features with minimal code changes. For example, adding manual currency prices requires no UI changes if you display the total.
Create an email input to collect your customer’s email address. Call updateEmail when your customer finishes the input to validate and save the email address.
Depending on the design of your checkout form, you can call updateEmail in the following ways:
Directly before submitting the payment. You can also call updateEmail to validate earlier, such as on input blur.
Before transitioning to the next step, such as clicking a Save button, if your form includes multiple steps.
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.
First, create a container DOM element to mount the Payment Element. Then create an instance of the Payment Element using checkout.createPaymentElement and mount it by calling element.mount, providing either a CSS selector or the container DOM element.
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., )
O Stripe Shell oferece uma melhor experiência em desktops.