Skip to content

Murai

Add credit-based billing to any app in under 30 minutes — with first-class support for Indonesian payment gateways.

Features

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.

Quick example

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 up
const session = await checkout.createSession({
userId: 'user_123',
amount: 100_000,
successRedirectUrl: 'https://yourapp.com/success',
failureRedirectUrl: 'https://yourapp.com/fail',
});
// Spend
await wallet.spend('user_123', 5_000, 'usage-key');

See it in action

Live Demo

Try the complete example app — top up tokens, spend credits, and explore the ledger.

Open the demo →