Ir a contenido
Crea una cuenta
o
Inicia sesión
Logotipo de Stripe Docs
/
Pregúntale a la IA
Crear una cuenta
Iniciar sesión
Empieza ahora
Pagos
Ingresos
Plataformas y marketplaces
Gestión del dinero
Recursos para desarrolladores
Resumen
Control de versiones
Registro de cambios
Actualiza tu versión de API
Actualiza la versión de SDK
Essentials
SDK
    Resumen
    SDK del lado del servidor
    SDK para móviles
    SDK para iOS
    SDK para Android
    SDK para React Native
    SDK para web
    Módulo ES de Stripe.js
    React Stripe.js
    SDK de Terminal
    SDK para iOS
    SDK para Android
    SDK para React Native
    Comunidad
    SDK de la comunidad
    Migraciones móviles
    Migra a SDK de iOS 24
    Migra a SDK de Android 21
API
Pruebas
CLI de Stripe
Herramientas
Workbench
Dashboard para desarrolladores
Stripe Shell
Stripe para Visual Studio Code
Funcionalidades
Flujos de trabajo
Destinos de eventos
Alertas de estado de StripeCargas de archivos
AI solutions
Kit de herramientas para agentes
Build with an LLM
Seguridad y privacidad
Seguridad
Privacidad
Amplía Stripe
Stripe Apps
Stripe Connectors
Socios
Ecosistema de socios
Certificación de socio
InicioRecursos para desarrolladoresSDKs

ES Module Stripe.js SDK

Set up the ES Module Stripe.js client-side SDK in your web application.

See the code

To see how ES Module Stripe.js works or to help develop it, check out the project on GitHub.

This introductory guide shows you how to install the ES Module Stripe.js client-side SDK with a script tag or package manager. The SDK wraps the global Stripe function provided by the Stripe.js script as an ES module. It allows you to use Elements, our prebuilt UI components, to create a payment form that lets you securely collect a customer’s card details without handling the sensitive data.

Antes de comenzar

Enable the payment methods you want to support on the payment methods settings page.

Manually load the Stripe.js script

Installation

To install by script, add the Stripe.js ES Module as a script to the <head> element of your HTML. This allows any newly created Stripe objects to be globally accessible in your code.

<head> <title>Checkout</title> <script src="https://js.stripe.com/basil/stripe.js" async></script> </head>

Stripe.js constructor

Next, set the API publishable key to allow Stripe to tokenize customer information and collect sensitive payment details. For example:

var stripe = Stripe(
'pk_test_TYooMQauvdEDq54NiTphI7jx'
);

Load Stripe.js as an ES Module

Installation

To install by package manager, install the Stripe.js ES Module from the npm public registry.

npm install @stripe/stripe-js

Stripe.js constructor

Next, import the module into a JavaScript file. The following function returns a Promise that resolves with a newly created Stripe object after Stripe.js loads.

import {loadStripe} from '@stripe/stripe-js'; const stripe = await loadStripe(
'pk_test_TYooMQauvdEDq54NiTphI7jx'
);

Consulta también

This wraps up the introductory guide to setting up the ES Module Stripe.js SDK. See the links below to get started with your integration.

  • Accept a payment with a payment element on GitHub
  • Accept a payment with a payment element in Docs
  • Custom payment flow builder
  • Stripe.js reference
¿Te fue útil esta página?
SíNo
¿Necesitas ayuda? Ponte en contacto con soporte.
Únete a nuestro programa de acceso anticipado.
Echa un vistazo a nuestro registro de cambios.
¿Tienes alguna pregunta? Contacto.
¿LLM? Lee llms.txt.
Con tecnología de Markdoc