Allow your customers to buy NFTs with credit card and crypto payments, using Crossmint's headless checkout. This quickstart provides a seamless integration for accepting payments in your dApp using the Crossmint Orders API.
Key features:
- Accept fiat payments via credit and debit card
- Accept USDC payments
- Deliver NFTs directly to a buyer's wallet or email address
- Full order management with real-time status updates
- Create a developer account in the Staging Console.
- Create a new collection or import yours in the console, and have your
collectionId
ready. - Make sure your collection has at least one NFT configured.
- From the detail view of your collection, navigate to the Checkout tab to configure the pricing settings and enable Credit Card and Crypto payments.
Easily deploy the template to Vercel with the button below. You will need to set the required environment variables in the Vercel dashboard.
-
Clone the repository and navigate to the project folder:
git clone https://github.com/crossmint/headless-checkout-quickstart.git && cd headless-checkout-quickstart
-
Install all dependencies:
npm install # or yarn install # or pnpm install # or bun install
-
Set up the environment variables by copying the template file:
cp .env.template .env
-
Add your Crossmint
collectionId
to the.env
file.NEXT_PUBLIC_CROSSMINT_COLLECTION_ID=your_collection_id
-
Get your client-side API key from the Crossmint Console Overview and add it to the
.env
file.NEXT_PUBLIC_CROSSMINT_API_KEY=your_api_key
-
Run the development server:
npm run dev # or yarn dev # or pnpm dev # or bun dev
This implementation uses Crossmint's Headless Orders API to create a completely custom checkout experience. The flow works as follows:
The quickstart demonstrates the complete order lifecycle using three core API endpoints:
- Create Order - Creates a new order with initial payment method and recipient details
- Get Order - Retrieves order status and polls for completion
- Update Order - Updates order details like recipient email/wallet or payment method
See API implementation: lib/api.ts
- Pay with Card Guide
- Uses Stripe Elements with customizable UI styling
- No Stripe account required we provide the Stripe keys for you
- Crossmint returns
stripePublishableKey
andstripeClientSecret
for seamless payment processing - Supports credit cards, debit cards, Apple Pay, and Google Pay
- See implementation:
components/card-payment.tsx
- Pay with USDC Guide
- Pay with Any Crypto Guide
- Supports crosschain crypto payments on any blockchain and token (Solana, USDC, USDT, ETH, MATIC, etc.)
- Crossmint returns a
serializedTransaction
that gets parsed and signed by the user's wallet - Transaction signing: Users sign the prepared transaction using their connected wallet (MetaMask, Phantom, etc.)
- No complex transaction building required - just parse and sign the provided transaction
- Get test tokens: USDC Faucet | ETH Faucet
- See implementation:
components/crypto-payment.tsx
Orders progress through different phases, each with specific statuses that you can poll to update your UI:
- Quote Phase: Order is created and pricing is being calculated (
requires-quote
) - Payment Phase: Order is ready for payment (
awaiting-payment
,completed
) - Delivery Phase: NFT is being minted and delivered after successful payment
- Completed Phase: Order is fully processed and NFT delivered
The quickstart demonstrates status polling using the Get Order API to:
- Check payment completion in real-time
- Update the UI based on order status changes
- Handle different payment states (success, failure, insufficient funds)
This quickstart uses a client-side approach with:
- Client-side API key with
orders.read
scope (NEXT_PUBLIC_CROSSMINT_API_KEY
) clientSecret
returned from Create Order API - this JWT token authenticates subsequent Update Order and Get Order calls- No additional API scopes needed for update/get operations when using
clientSecret
- For server-side implementations, use a server-side API key with
orders.create
,orders.update
, andorders.read
scopes
For advanced usage, refer to the Crossmint documentation:
- Add Apple Pay: https://docs.crossmint.com/payments/embedded/guides/apple-pay
- Customize the UI: https://docs.crossmint.com/payments/embedded/guides/ui-customization
- Edit payment methods: https://docs.crossmint.com/payments/embedded/guides/payment-methods
- Headless checkout is available on Staging for testing purposes. If you would like to use this on Production, contact sales to request access.
- Create an account in the Production Console, add your collection and configure the payment settings from the Checkout tab.
- Verify your account as the project owner and verify your collection. Learn more about verifications.
- Update your
.env
file with your production variables. - Deploy your application to a production environment.