A unified API for handling payments across multiple gateways. Comes with a Mock driver for testing.
Switch between Stripe, PayPal, or Mock effortlessly.
Standardized interface for handling sensitive data.
Easily register your own payment drivers.
One API for all payment providers.
1import { payment } from "canxjs/payment";23// 1. Use the default driver (mock by default)4await payment.driver().charge(1000, "usd", { source: "tok_visa" });56// 2. Use a specific driver7await payment.driver("stripe").charge(5000, "usd", { customer: "cus_123" });89// 3. Register a custom driver10import { StripeDriver } from "./StripeDriver";11payment.register("stripe", new StripeDriver(process.env.STRIPE_SECRET));
1import { PaymentGateway } from "canxjs/payment";23export class MyCustomGateway implements PaymentGateway {4async charge(amount: number, currency: string, options?: any) {5// Call 3rd party API6return { id: "ch_123", status: "succeeded" };7}89async refund(id: string, amount?: number) {10// ...11}12}