Prerequisites
- Next.js 14+ with App Router
- Node.js 18+
- A ZendFi account with test API keys
Project Setup
Configure environment variables
Create a
.env.local file in your project root:.env.local
Next.js automatically loads
.env.local and keeps these variables server-side only (no NEXT_PUBLIC_ prefix means they are never exposed to the browser).Create a Payment
Build a Server Action that creates a payment and redirects to checkout:app/actions/checkout.ts
app/checkout/page.tsx
Handle Webhooks
Create a webhook handler route to process payment events:app/api/webhooks/zendfi/route.ts
Order Confirmation Page
Create a page to show after successful payment:app/order/[paymentId]/page.tsx
Payment Links (Alternative)
If you prefer a no-code approach, create a payment link and share it:app/actions/payment-link.ts
Embedded Checkout
For an inline checkout experience without redirects, use the Embedded Checkout component:app/checkout/embedded/page.tsx
Middleware (Optional)
Protect your checkout routes with Next.js middleware:middleware.ts