A Next.js application that enables merchants to accept payments in USDC while allowing customers to pay with their token of choice through Jupiter's exact-out swap feature.
- Accept USDC payments as a merchant
- Allow customers to pay with any verified token on Jupiter (BONK, JUP, TRUMP, etc.)
- Generate Solana Pay QR codes for seamless mobile wallet payments
- Automatic token swaps during transaction (in-flight, exact out swap)
- Simple and intuitive user interface
- Node.js (v16 or higher)
- npm or yarn
- Solana wallet (Phantom, Solflare, etc.)
- Clone the repository
git clone https://github.com/cutemonstersnft/payment-gateway-st.git
cd payment-gateway- Install dependencies
npm install
# or
yarn install-
Download and install ngrok CLI
- Visit ngrok.com to download
- Follow their installation instructions for your operating system
-
Configure RPC URLs
- Open
qr.tsxand replace the RPC URL on line 45 with your own - Open
checkout/route.tsxand replace the RPC URL on line 72 with your own
- Open
- Start the development server
npm run dev
# or
yarn dev- In a separate terminal, start ngrok to expose your local server
ngrok http 3000- Navigate to the ngrok URL provided in the terminal
-
Navigate to the ngrok URL in your browser
-
Fill in the payment details:
- Amount in USDC
- Recipient public key (must have a USDC token account)
- Token of choice (search for symbols like BONK, JUP, or TRUMP - must be from Jupiter's verified list)
-
Click "Checkout" to generate a Solana Pay QR code
-
Scan the QR code with your Solana wallet (Phantom, Solflare, etc.)
-
Approve the transaction in your wallet
-
Transaction complete! You can inspect the Solana transaction to see the in-flight swap
When a customer makes a payment:
- They select their preferred token for payment
- The system calculates the equivalent amount based on current market rates
- During the transaction, an in-flight swap occurs (exact out)
- The customer's selected token is debited from their wallet
- The merchant receives the exact USDC amount requested
It's like magic! The merchant always receives USDC regardless of what token the customer uses to pay.
Once your application is ready for production, you can easily deploy it using either Netlify or Vercel:
- Install the Vercel CLI:
npm install -g vercel- Deploy to production:
vercel --prod- Follow the prompts to complete the deployment process.
- Install the Netlify CLI:
npm install -g netlify-cli- Deploy to Netlify:
netlify deploy --prod- Follow the prompts to complete the deployment process.
Both platforms offer continuous deployment from Git repositories, custom domains, and SSL certificates.
- Ensure your RPC URLs are valid and have sufficient rate limits
- Make sure the recipient wallet has a USDC token account
- Verify that you have sufficient balance in your wallet for the transaction