Overview
Every mechanic has a wallet backed by the double-entry ledger. Earnings flow through three balance stages before reaching the mechanic’s bank account:Wallet Balances
Each mechanic wallet tracks three balances:
All balances are cached in the
wallets table but derived from wallet_transactions, which are themselves linked to ledger_entries. If drift is detected, WalletService.recalculateWalletBalance() recomputes from the transaction log.
Earnings Lifecycle
Wallet API (Mechanic)
Get Wallet Summary
Get Transaction History
Get Payout History
UPI Account Management
Mechanics must add and verify a UPI account before receiving payouts. Verification uses RazorpayX’s VPA validation pipeline.Verification Flow
Add UPI Account
Verification happens asynchronously. The mechanic receives a push notification when verified or if manual review is needed. The first UPI account added is automatically set as primary.
List UPI Accounts
Admin: Manually Approve UPI
Disputes
Either party can raise a dispute on acompleted or paid job. Disputes freeze the mechanic’s pending earnings until resolved.
Dispute Lifecycle
Raise a Dispute
- Dispute row created (status:
open) - Mechanic’s pending earnings for this job are frozen in the ledger
- Both parties receive push notifications
Get Disputes for a Job
Admin: Resolve a Dispute
Refunds
Refunds are admin-initiated only. The flow:Initiate Refund
- Omit
amountfor a full refund - Over-refunding is rejected (400)
- Deduction is from mechanic’s available balance first, then pending
List Refunds for a Payment
Settlement Cycle
Settlements run automatically via BullMQ cron:Settlement Batch Flow
Eligibility Criteria
A mechanic is included in a settlement batch when:- Their available wallet balance ≥
MIN_PAYOUT_AMOUNT_PAISA(default ₹100) - They have a verified UPI account set as primary
- The UPI account has a valid
razorpay_fund_account_id
Ledger Architecture
Every financial operation creates immutableledger_entries using double-entry accounting:
System Accounts
Immutability Guarantee
Ledger entries are append-only. Database triggers preventUPDATE and DELETE on ledger_entries. Corrections are made by inserting reversal entries with reversal_of_id pointing to the original.
Configuration
Financial parameters are dynamic via theplatform_config table:
These can be changed at runtime without redeployment. Environment variables serve as fallback defaults.
