Create a payment session on your server, then redirect to authorization_url. Zero client SDK required.
WAJUB_SECRET_KEY — never NEXT_PUBLIC_
Full hosted checkout URL from POST /payments
Trust webhooks, not the return URL alone
No @wajub/js on the storefront
// app/api/checkout/session/route.ts
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const { cartId } = await req.json();
const res = await fetch('https://api.wajub.com/payments', {
method: 'POST',
headers: {
Authorization: process.env.WAJUB_SECRET_KEY!,
'Content-Type': 'application/json',
'Idempotency-Key': `cart-${cartId}`,
},
body: JSON.stringify({
amount: 15000,
currency: 'XAF',
customer: { email: 'buyer@example.com' },
callback: 'https://shop.example.com/order/return',
}),
});
const { authorization_url } = await res.json();
return NextResponse.redirect(authorization_url);
}Redirects to pay.wajub.com (or your local checkout URL)
Mock vs live
Without WAJUB_SECRET_KEY, the demo uses mock sessions. Set the key in .env.local for real payments.