How to accept USDC payments in a SaaS app on Solana
Accept USDC in a SaaS app on Solana: register a business wallet, create a payment intent from your backend, send the customer to a hosted checkout, and verify the signed callback.
How the payment works
Your backend creates a payment intent with the amount in USDC. Gateway returns a hosted checkout URL. The customer opens it and pays from a Solana wallet. The USDC goes straight from the customer wallet to your business wallet, so there is no custody and no payout to wait for.
The same transaction carries a fixed gateway fee of 0.0012 SOL (1,200,000 lamports) from the customer wallet to SolKnife. Gateway finds the transaction on Solana, verifies the amount, token, and recipient at finalized commitment, marks the payment CONFIRMED, and sends a signed payment.confirmed callback to your backend. Your app unlocks the order only after it verifies that callback.
1. Register your business with USDC
Register once, on the register page or through the API. Set indexTokenMint to the USDC mint (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v), ownerWallet to the wallet that receives payments, callbackUrl to an HTTPS endpoint of your backend, and telegramChatId to the chat that gets a notice for each confirmed payment.
The response holds your API key and your webhook secret. Gateway shows both only once. Store them on your backend, never in client code.
Amounts are raw token units. USDC has 6 decimals, so 25 USDC is 25000000. Leave out merchantTokenMint to use the token you registered with.
checkoutReference is your own order ID; it comes back in the callback. customerTelegramChatId is required: the customer gets it from the Gateway Telegram bot and receives a confirmation there.
Redirect the customer to checkoutUrl. On a desktop, the customer scans the Solana Pay QR code with a wallet app. On a phone, the customer opens the wallet from the page. The checkout shows the amount, your business name, and the gateway fee, and refreshes when the payment is confirmed.
A payment intent expires 15 minutes after you create it. Create a new one if the customer comes back later. You do not need to call a confirm endpoint: Gateway watches Solana for the payment reference and confirms the payment on its own.
4. Verify the signed callback
Gateway sends a POST to your callbackUrl with the headers x-solknife-event, x-solknife-delivery-id, x-solknife-timestamp, and x-solknife-signature. The signature is the hex HMAC-SHA256 of the timestamp, a dot, and the raw body, keyed with your webhook secret.
Reject a callback whose signature does not match or whose timestamp is more than 5 minutes from your clock. Drop a delivery ID you already processed, and make the order update idempotent on paymentId. Return a 2xx status when you accept the callback.
Gateway records every delivery. When your endpoint was down or returned an error, the delivery has status FAILED. List the deliveries and send a failed one again. Retries share a limit of 10 per minute per merchant.
List and retry callback deliveries
const GATE_URL = "https://gate.solknife.xyz";
const headers = { "x-gateway-key": process.env.GATE_API_KEY };
// The latest callback attempts, with status DELIVERED or FAILED.
const deliveries = await fetch(`${GATE_URL}/api/webhooks`, { headers }).then((r) => r.json());
// Send one again. A retry is a new delivery with a new delivery id.
await fetch(`${GATE_URL}/api/webhooks/${deliveryId}/retry`, { method: "POST", headers });
Register your business to get a Gateway API key and a webhook secret. Payments go straight to your wallet; Gateway takes a fixed 0.0012 SOL fee per payment.