Skip to main content

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

Response (201):
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 a completed or paid job. Disputes freeze the mechanic’s pending earnings until resolved.

Dispute Lifecycle

Raise a Dispute

What happens:
  1. Dispute row created (status: open)
  2. Mechanic’s pending earnings for this job are frozen in the ledger
  3. 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 amount for 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:
  1. Their available wallet balance ≥ MIN_PAYOUT_AMOUNT_PAISA (default ₹100)
  2. They have a verified UPI account set as primary
  3. The UPI account has a valid razorpay_fund_account_id

Ledger Architecture

Every financial operation creates immutable ledger_entries using double-entry accounting:

System Accounts

Immutability Guarantee

Ledger entries are append-only. Database triggers prevent UPDATE 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 the platform_config table: These can be changed at runtime without redeployment. Environment variables serve as fallback defaults.