Ir a contenido
Crea una cuenta
o
inicia sesión
Logotipo de la documentación de Stripe
/
Pregúntale a la IA
Crear cuenta
Iniciar sesión
Empezar
Pagos
Ingresos
Plataformas y marketplaces
Gestión del dinero
Recursos para desarrolladores
Resumen
Control de versiones
Registro de cambios
Actualiza tu versión de la API
Mejora tu versión de SDK
Essentials
SDK
    Resumen
    SDK del lado del servidor
    Web
    Módulo ES de Stripe.js
    React Stripe.js
    Mobile
    SDK de iOS
    SDK de Android
    SDK de React Native
    Migrar a SDK de iOS 24
    Migrar a SDK de Android 21
    Terminal
    SDK de iOS
    SDK de Android
    SDK de React Native
    Comunidad
    SDK de la comunidad
API
Pruebas
CLI de Stripe
Proyectos de muestra
Herramientas
Espacio de trabajo
Dashboard de desarrolladores
Stripe Shell
Stripe para Visual Studio Code
Funciones
Flujos de trabajo
Destinos de eventos
Alertas de estado de StripeCargas de archivos
Soluciones de IA
Kit de herramientas para agentes
Protocolo de Contexto del Modelo
Seguridad y privacidad
Seguridad
Rastreo web de Stripebot
Privacidad
Ampliar Stripe
Desarrolla aplicaciones de Stripe
Usa aplicaciones de Stripe
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.

Cosas a tener en cuenta

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'
);

Véase 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 ha sido útil la página?
SíNo
  • ¿Necesitas ayuda? Ponte en contacto con el equipo de soporte.
  • Únete a nuestro programa de acceso anticipado.
  • Echa un vistazo a nuestro registro de cambios.
  • ¿Tienes alguna pregunta? Ponte en contacto con el equipo de ventas.
  • ¿LLM? Lee llms.txt.
  • Con tecnología de Markdoc