Processes pay-per-use purchases for meditations, teachings, and live experiences with token-backed authorization, settlement, ledgering, and refunds.
Pipeline#
- Compliance guard – validates purchase and refund policies per asset type.
- Payment gateway – authorizes micro-payments and executes settlements/refunds.
- Ledger – records debit/credit entries for accounting and audit trails.
- Batch scheduler – groups transactions into settlement batches for treasury.
- Transaction store – persists micro-payment states and statuses.
- Event bus & analytics – emits lifecycle events and publishes telemetry.
Usage#
ts
import { createMicroTransactionService } from './service';
const service = createMicroTransactionService({
paymentGateway,
ledger,
batchScheduler,
eventBus,
analyticsReporter,
complianceGuard,
transactionStore,
settlementStore,
});
const payment = await service.authorizePurchase({
accountId: '0xAya',
assetId: 'meditation-333',
assetType: 'meditation',
amount: '50000000000000000',
currency: 'MATIC',
paymentMethod: 'token_balance',
});
Tests#
bash
npx jest --config apps/lilith/svc-micro-transaction/jest.config.cjs --runInBand