Generate payment links programmatically with custom parameters
✨ Install with AI
Copy this prompt to your AI code editor (Cursor, Copilot, etc.) to create checkout integration:
Add Waffo Pancake checkout to my project using the official TypeScript SDK.npm install @waffo/pancake-tsCreate a WaffoPancake client with WAFFO_MERCHANT_ID and WAFFO_PRIVATE_KEY.Use client.checkout.createSession({ productId, currency: "USD" })to get a checkoutUrl, then redirect the user with res.redirect(checkoutUrl).For webhooks, use verifyWebhook(rawBody, signature) from the SDK — it has embedded public keys,no secret needed. Handle events: order.completed, subscription.activated, subscription.canceled.Read https://waffo.mintlify.app/llms-full.txt for full API reference.
import { WaffoPancake } from "@waffo/pancake-ts";const client = new WaffoPancake({ merchantId: process.env.WAFFO_MERCHANT_ID!, privateKey: process.env.WAFFO_PRIVATE_KEY!,});const session = await client.checkout.createSession({ productId: "prod_xxx", currency: "USD",});// Redirect the user to the checkout pageres.redirect(session.checkoutUrl);
Do not use window.open() to open the checkout page. Safari and many mobile browsers block popup windows opened from asynchronous callbacks (e.g., after an API call). This causes checkout to silently fail for your customers.
Recommended approaches:
Method
When to Use
Example
Server-side redirect
API route / server action
res.redirect(checkoutUrl)
Client-side redirect
SPA / React
window.location.href = checkoutUrl
Link element
Static links
<a href={checkoutUrl}>
// ✅ Recommended: server-side redirectexport async function POST(req: NextRequest) { const session = await client.checkout.createSession({ ... }); return NextResponse.redirect(session.checkoutUrl);}// ✅ Also fine: client-side redirectconst { checkoutUrl } = await res.json();window.location.href = checkoutUrl;// ❌ Avoid: window.open — blocked by Safari and mobile browserswindow.open(checkoutUrl, "_blank"); // Will be blocked!
After payment, the customer is redirected back to your successUrl. Use the {SESSION_ID} placeholder to verify the payment on your success page.
Metadata is stored on the checkout session and can be retrieved via the checkoutSession GraphQL query. Webhook passthrough for metadata is coming soon.