Skip to content
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)
provider.request()
Why it matters

Why this earns its place in your stack

1

Composable Pipeline

Plugins chain sequentially through a clean middleware pipeline architecture.

2

Request & Response Hooks

Enrich requests with tracking IDs or sanitize responses before leaving the engine.

3

Community & Custom Plugins

Author your own in-house plugins or leverage pre-built community packages.

4

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.

plugins-setup.tsTypeScript
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]
});