Accept USDC payments in Next.js

Nexus takes USDC payments on Algorand. Customers pay from any Algorand wallet (Pera, Defly), you are paid directly, and there is no card processor or approval queue. This is the whole Next.js integration.

1. Create the checkout (server-side)

Create the session on your server so the price is fixed and the buyer cannot change it. Amounts are integer US cents.

app/api/checkout/route.ts
import { NextResponse } from 'next/server';

export async function POST(req: Request) {
  const { cents } = await req.json();
  const r = await fetch(`${process.env.NEXUS_URL}/v1/sessions`, {
    method: 'POST',
    headers: { 'content-type': 'application/json', 'x-nexus-api-key': process.env.NEXUS_API_KEY! },
    body: JSON.stringify({ creatorId: process.env.NEXUS_CREATOR_ID, amount: cents }),
  });
  const s = await r.json();
  return NextResponse.json({ url: `${process.env.NEXUS_URL}/pay/${s.sessionId}?t=${s.confirmToken}` });
}

2. Check it before you fulfil the order

Never trust the browser. Nexus matches the payment on-chain and only marks the session completed when the USDC has actually arrived.

const s = await (await fetch(`${process.env.NEXUS_URL}/v1/sessions/${id}`, { headers: { 'x-nexus-api-key': process.env.NEXUS_API_KEY! } })).json();
if (s.status === 'completed') fulfil(order);

3. Set it up

Honest limits

See how it works

Using an AI coding agent? Point it at /llms.txt or the OpenAPI spec, or install the Nexus MCP server.