Atomic Balance
No overdrafts, no double-charges. SELECT FOR UPDATE ensures safe concurrent spending.
Atomic Balance
No overdrafts, no double-charges. SELECT FOR UPDATE ensures safe concurrent spending.
Append-only Ledger
Every transaction is permanently recorded. Auditable, replayable, and tamper-evident.
Idempotent Webhooks
Dual idempotency guards handle retry storms from any payment gateway.
Gateway-agnostic
Midtrans Snap, Xendit Checkout, and Stripe built-in. Add your own with a simple interface.
Token Expiration
Set expiry dates on credits. Run expiration jobs to automatically reclaim unused tokens.
Usage Reporting
Generate per-user usage reports with aggregated credits, debits, and transaction counts over any date range.
import { createWallet, createCheckoutManager, createLedger, createDrizzleStorage, createMidtransGateway,} from '@murai-wallet/murai';
const storage = createDrizzleStorage(db);const gateway = createMidtransGateway({ serverKey, clientKey, sandbox: true });const wallet = createWallet({ storage });const ledger = createLedger(storage);const checkout = createCheckoutManager(gateway, ledger, storage);
// Top upconst session = await checkout.createSession({ userId: 'user_123', amount: 100_000, successRedirectUrl: 'https://yourapp.com/success', failureRedirectUrl: 'https://yourapp.com/fail',});
// Spendawait wallet.spend('user_123', 5_000, 'usage-key');Live Demo
Try the complete example app — top up tokens, spend credits, and explore the ledger.
Open the demo →