Plugin system
Compose Custom Middlewares & Third-Party Extensions
Hook into any phase of payment execution. Mount fraud scoring, structured audit logging, dynamic tax calculators, and analytics with plug-and-play modules.
Plugin pipeline
createPayment(order)
use(logger)
use(fraud-check)
use(retry)
use(metrics)
Why it matters
Why this earns its place in your stack
Composable Pipeline
Plugins chain sequentially through a clean middleware pipeline architecture.
Request & Response Hooks
Enrich requests with tracking IDs or sanitize responses before leaving the engine.
Community & Custom Plugins
Author your own in-house plugins or leverage pre-built community packages.
Zero Runtime Overhead
Lightweight, pure-function execution that adds sub-millisecond overhead.
Simple, readable, direct.
Without Better Payment
Entangling logging, telemetry, and fraud checks directly inside payment controller code.
With Better Payment
Decoupled, reusable plugins that keep core business code pristine.
TypeScript
import { createBetterPayment, type Plugin } from "better-payment";
const fraudDetectionPlugin: Plugin = {
name: "custom-fraud-filter",
async beforePayment(request) {
const isRisky = await checkIpReputation(request.clientIp);
if (isRisky) {
throw new Error("Fraud risk score too high.");
}
return request;
}
};
const payment = createBetterPayment({
providers: { ... },
plugins: [fraudDetectionPlugin]
});