Overview
Stripe offers a secure method for tokenizing credit card information using Stripe.js on the frontend. Use this method to collect and tokenize card data directly in the browser. This reduces your PCI scope by avoiding sensitive data transmission through your servers.Note: The Stripe payment flow will be deprecated. A new Basis Theory flow will be released soon, and integration details will be added to this page.
Generate a Stripe Token Using Demo App
You can use this page to generate a Stripe token for testing payments in the Rye staging environment. For the card number, use Stripe’s test card numbers provided at https://docs.stripe.com/testing. Alternatively, you can use the steps below to create a simple React app to generate the Stripe token.Generate a Stripe Token Using React App
This guide walks through the Stripe.js approach, including a React demo app.Create a New React App
Install Stripe Dependencies
React Example Code
- Replace the code in src/App.jsx with the code below.
- For testing in Rye staging: use the key on line 14.
- For testing in Rye production: use the key on line 11.
Run the App Locally
The app will run locally at http://localhost:5173. Open that page in your browser to enter card details and generate a Stripe token. The token will be returned in the formattok_XXXXXXXXXXXXXXXX
, where the tok_ prefix is followed by a unique identifier.
For testing in the Rye staging environment, use Stripe’s test card numbers provided at https://docs.stripe.com/testing.
Generate a Stripe Token Using Other Stripe SDKs
In addition to React, Stripe provides client SDKs for other platforms, such as iOS and Android. For example, if you’re building a mobile app, you can use the Stripe iOS SDK to securely collect card details and generate a payment token directly from your app. The flow is similar across SDKs: Initialize Stripe with your publishable key, present the card entry UI, and Stripe will return a token that you can pass to Rye.Notes
- A Stripe token generated through these steps is valid for one-time use only. To submit another order after using a Stripe token, you’ll need to generate a new one.