Next.js integration
Create links in a server route and keep secrets off the client.
Build in sandbox. These guides describe the current implementation. Live payments and payouts are disabled; planned capabilities are labelled explicitly.
App Router server route
javascript
// app/api/checkout/route.ts
export async function POST() {
const response = await fetch(
'https://api.unalaunch.com/api/v1/integration/checkout-links',
{
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.UNA_SANDBOX_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ productId: process.env.UNA_PRODUCT_ID }),
cache: 'no-store',
},
);
if (!response.ok) return Response.json({ error: 'Checkout unavailable' }, { status: 502 });
const { checkoutUrl } = await response.json();
return Response.json({ checkoutUrl });
}Server-controlled product selection
Validate a selected product against your own server-side catalog mapping if you accept a browser selection. Do not accept a price or arbitrary redirect URL. Never prefix the API key environment variable with NEXT_PUBLIC_.