Stripe Crypto SDK ES Module
This introductory guide shows you how to install the Stripe crypto ES module client-side SDK with a script tag or package manager. The SDK wraps the global StripeOnramp
function provided by the Stripe crypto script as an ES module. It allows you to use the onramp widget to help your customers to acquire crypto using fiat.
Manually load the Stripe crypto script
Installation
Include the following scripts using script tags within the <head>
element of your HTML. These scripts must always load directly from Stripe’s domains, https://js.stripe.com and https://crypto-js.stripe.com, for compatibility and PCI compliance. Don’t include the scripts in a bundle or host a copy yourself. If you do, your integration might break without warning.
<head> <title>Onramp</title> <script src="https://js.stripe.com/v3/"></script> <script src="https://crypto-js.stripe.com/crypto-onramp-outer.js"></script> </head>
StripeOnramp constructor
Set the API publishable key to allow Stripe to retrieve the OnrampSession
object created by your backend. For example:
const stripeOnramp = StripeOnramp(
);'pk_test_TYooMQauvdEDq54NiTphI7jx'
Load Stripe crypto SDK as an ES module
Installation
To install through the package manager, install the Stripe.js ES module and Stripe crypto ES module from the npm public registry. The package includes Typescript type definitions.
npm install @stripe/stripe-js @stripe/crypto
StripeOnramp constructor
Import the module and set the API publishable key to allow Stripe to retrieve the OnrampSession
object created by your backend. The function returns a Promise
object that resolves with a newly created StripeOnramp
object after the scripts load.
import {loadStripeOnramp} from '@stripe/crypto'; const stripeOnramp = await loadStripeOnramp(
);'pk_test_TYooMQauvdEDq54NiTphI7jx'