Try the live demo
See the full flow without setting anything up locally
View the reference app
The full reference code for saved cards and order intents
Prerequisites
- Node.js and pnpm — Node.js 20 or later.
- Stytch account — a Stytch account. The example uses Stytch to sign in users. Any supported auth provider works in your own app.
Eligible CardsAgent Cards works with any credit or debit card. What varies by card is who issues the agent’s credential: a card-network program, or Crossmint’s encrypted card fallback.Card-network rails — Visa Intelligent Commerce and Mastercard Agent Pay — support a subset of cards, and Visa and Mastercard keep expanding that coverage:
- Mastercard Agent Pay: Mastercard credit and debit cards
- Visa Intelligent Commerce: U.S.-issued Visa credit and debit cards, except business cards, prepaid cards, Chase cards, and Fidelity cards
Run the App
1
Clone the repository and install dependencies
2
Get a Crossmint staging client key
Sign in to the Crossmint Staging Console, create a project, and create a client-side API key. In staging, all scopes are included by default.Your AI assistant can also do this step with the Crossmint MCP server: in staging, create a project and a web client key for
http://localhost:3000 with the payment-methods.* and order-intents.* scopes.Paste the key into .env.local:.env.local
3
Set up Stytch
In the Stytch dashboard, in the Test environment of a B2C project:
- In Configuration → SDK Configuration → OAuth, enable Google. The shared Stytch test client works, with no Google Cloud setup.
- In Configuration → Redirect URLs, add
http://localhost:3000as both Login and Signup. Use exactly that value, with no trailing slash and no/callback. - In Project Settings → API Keys, copy the Public token (
public-token-test-...) into.env.local:
.env.local
4
Register Stytch as your auth provider in Crossmint
In the Crossmint Staging Console, under 3P Auth providers:
- Select Stytch in the provider list.
- Paste your Stytch Project ID (
project-test-...). Stytch shows it in Project Settings → Project ID. - Keep Verifier Id as
sub, the default.
5
Run the dev server
Understand the User Flow
The app takes the user through six steps:- Sign in. The user signs in with Google through Stytch. The app passes the Stytch JWT to the Crossmint SDK, so that every API call belongs to that user.
- Save a card. The
CrossmintPaymentMethodManagementcomponent collects the card in a PCI-compliant form and returns apaymentMethodId. - Register the card. Registration finds the card’s rails, such as Visa Intelligent Commerce or Mastercard Agent Pay. It gives no spending permission and needs no verification.
- Create an order intent. The app creates an order intent with an amount, a description, an expiration, and, when known, the merchant. The response can have several rails, each with its own status. If no card network rail can be used, the response also has an
encrypted-cardrail. In production, the app gets the encrypted card only when the project has encrypted card access. - Verify the rail that you use. If that rail has
status: "pending_verification", theOrderIntentVerificationcomponent runs the card network’s step. Other rails can stay pending. A returning Visa user approves with the passkey that is already on the device. - Get a card number. The app asks for a credential for a specific amount, with the rail’s
railandprovider. If the order intent has no merchant, the app gives the merchant now. The response has a one-time card number, an expiration date, and a CVC. For theencrypted-cardrail, the app sends an RSA public key and gets the saved card as a JWE to decrypt.
rails as a menu, not a checklist. Only the rail that you use must be active. Other rails do not block it.
Launching in Production
- Create a production project and a production client key in the Crossmint Console, with the
payment-methods.*andorder-intents.*scopes. - Register your auth provider in the production project, under 3P Auth providers, and add your app’s origins to the key.
- Replace the staging key in your app with the production key.
- Test with real cards: a production project can save up to 50 cards. Before you launch to your users, contact the Crossmint team to enable your project fully.
- To buy on any website with the saved card, add Agent Checkouts. See the Agent Checkouts Quickstart.
Learn More
Card Rails and PCI
The rails, the card data path, and your PCI scope
Customize UI
Style the approval and the CVC form to match your brand

