Install, connect, take your first payment.
Typed TypeScript APIs, thorough docs, runnable examples and sandbox cards: everything between npm install and your first verified test charge.
0
100%
Node · Edge
MIT
Where would you like to start?
Official Documentation
Complete guides, core concepts, security architecture, and step-by-step setup walkthroughs.
Explore5-Minute Quick Start
The fastest path from package install to your first verified test charge.
ExploreRunnable Examples & Store
Fully-functional Next.js App Router storefront app with checkout and webhook callbacks.
ExploreAPI & Type Reference
Complete function signatures, return shapes, and exported TypeScript interfaces.
ExploreSandbox Test Cards
Official success, decline, and error simulation card numbers across all providers.
ExploreEdge & Serverless Runtimes
Running Better Payment seamlessly on Cloudflare Workers, Vercel Edge, Bun, and Deno.
ExploreRuns wherever JavaScript runs.
No Node-only builtins: standard Fetch and Web Crypto keep it portable across every modern serverless runtime.
import { createPaymentHandler } from "better-payment/next"
import { paymentInstance } from "@/lib/payment"
export const { GET, POST } = createPaymentHandler({
payment: paymentInstance,
async onPaymentSuccess(result) {
await db.orders.update({ id: result.orderId, status: "PAID" });
},
});