C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

  • WebSockets
  • Task Scheduling
  • Queues
  • Job Batches
  • Caching
  • Events
  • Broadcasting
  • Notifications
  • SMS Channels
  • File Storage
  • Payment
  • Search
  • Security
  • Security Comparison
  • Performance
  • HTTP/2 Support
  • Deployment
Monetization

Payment

A unified API for handling payments across multiple gateways. Comes with a Mock driver for testing.

Multi-Gateway

Switch between Stripe, PayPal, or Mock effortlessly.

Secure

Standardized interface for handling sensitive data.

Extensible

Easily register your own payment drivers.

Unified API

One API for all payment providers.

Usage

payment.service.ts
1import { payment } from "canxjs/payment";
2
3// 1. Use the default driver (mock by default)
4await payment.driver().charge(1000, "usd", { source: "tok_visa" });
5
6// 2. Use a specific driver
7await payment.driver("stripe").charge(5000, "usd", { customer: "cus_123" });
8
9// 3. Register a custom driver
10import { StripeDriver } from "./StripeDriver";
11payment.register("stripe", new StripeDriver(process.env.STRIPE_SECRET));

Custom Driver

MyCustomGateway.ts
1import { PaymentGateway } from "canxjs/payment";
2
3export class MyCustomGateway implements PaymentGateway {
4 async charge(amount: number, currency: string, options?: any) {
5 // Call 3rd party API
6 return { id: "ch_123", status: "succeeded" };
7 }
8
9 async refund(id: string, amount?: number) {
10 // ...
11 }
12}