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.

Register with USDC as the accepted token
curl -X POST https://gate.solknife.xyz/api/merchants/register \
  -H "content-type: application/json" \
  -d '{
    "displayName": "Acme SaaS",
    "ownerWallet": "your business Solana wallet",
    "indexTokenMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "callbackUrl": "https://app.example/solknife/callback",
    "telegramChatId": "123456789"
  }'

Response:
{
  "ok": true,
  "data": {
    "apiKey": "sk_live_...",
    "webhookSecret": "...",
    "merchant": { "id": "...", "displayName": "Acme SaaS", ... },
    "primaryToken": { "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", ... }
  }
}

2. Create a payment intent from your backend

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.

Create a USDC payment intent
const GATE_URL = "https://gate.solknife.xyz";

// 25 USDC. USDC has 6 decimals, so 1 USDC is 1000000 raw units.
const response = await fetch(`${GATE_URL}/api/payments`, {
  method: "POST",
  headers: {
    "content-type": "application/json",
    "x-gateway-key": process.env.GATE_API_KEY,
  },
  body: JSON.stringify({
    checkoutReference: "order-1001",
    customerTelegramChatId: "123456789",
    merchantAmountRaw: "25000000",
  }),
});
const { ok, data, error } = await response.json();
if (!ok) throw new Error(`${error.code}: ${error.message}`);

// data.id, data.reference, data.checkoutUrl, data.expiresAt, data.status ("PENDING")
redirect(data.checkoutUrl);

3. Send the customer to the hosted checkout

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.

Verify the callback signature (Node.js)
import { createHmac, timingSafeEqual } from "node:crypto";

const TOLERANCE_SECONDS = 300;

export const verifySolknifeCallback = (secret, rawBody, headers) => {
  const timestamp = headers["x-solknife-timestamp"] ?? "";
  const signature = headers["x-solknife-signature"] ?? "";
  if (!/^\d+$/.test(timestamp)) return false;
  const nowSeconds = Math.floor(Date.now() / 1000);
  if (Math.abs(nowSeconds - Number(timestamp)) > TOLERANCE_SECONDS) return false;
  const expected = Buffer.from(
    createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex"),
    "hex",
  );
  const received = Buffer.from(signature, "hex");
  return received.length === expected.length && timingSafeEqual(received, expected);
};
payment.confirmed callback body
{
  "eventType": "payment.confirmed",
  "paymentId": "...",
  "checkoutReference": "order-1001",
  "merchantAmountRaw": "25000000",
  "merchantTokenMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "merchantWallet": "your business Solana wallet",
  "gatewayFeeLamports": "1200000",
  "signature": "solana transaction signature",
  "status": "CONFIRMED",
  ...
}

5. Retry a failed 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 });

Start accepting payments

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.