Documentation Archive

B2B SaaS Aggregation & Automated TDS Reconciliation

Business Narrative

We are acting as the Lead Architect for CloudMatrix, an Enterprise B2B SaaS Platform billing corporations ₹50,000 per month for infrastructure access.

Because the RBI enforces a ₹15,000 limit on recurring Card AutoPay (AFA), enterprise clients cannot simply attach a credit card. To solve this, CloudMatrix utilizes a Smart-Collect Waterfall: if an AutoPay mandate fails, Razorpay automatically spans up a temporary, unique Virtual Bank Account (e.g., RAZOR12345) and emails the NEFT/RTGS wire instructions directly to the client's finance department.

The system is highly automated. The State Machine listens for exactly ₹50,000 to hit the Virtual Account. If the API sees ₹50,000, it flips the invoice to PAID and keeps the SaaS servers online. If an invoice remains unpaid past the deadline, the system automatically suspends the client's API keys at midnight.


The Trap: The Indian Tax Reality

A Junior PM deploys this Smart-Collect architecture. The next day, the biggest Enterprise client's production servers are suspended, taking their business offline. The VP of Sales is furious.

What broke? Modality 2: The State Synchronization Modality.

The 10% Statutory Deduction (Section 194J)

Under Indian Tax Law, when an enterprise pays a B2B software invoice, they are legally required to deduct Tax Deducted at Source (TDS) before wiring the money. They send the tax directly to the government under the vendor's PAN, and send the net remainder to the vendor.

  • The Math: The invoice is ₹50,000. 10% TDS is ₹5,000. The client’s finance team wires exactly ₹45,000 to the Virtual Account via NEFT.
  • The State Machine Failure: The Payment Aggregator fires a webhook: amount_received = ₹45,000. The State Machine expects ₹50,000.
  • The Result: The system flags the payment as fundamentally incomplete, marking it PARTIALLY_PAID. Since the full amount wasn't cleared by the deadline, the automated dunning engine forcefully suspends the client's software access at midnight.

The architecture just punished an enterprise client for obeying federal tax laws, triggering an immediate churn risk.


️ The Architectural Pivot

To solve this, a naive developer might suggest changing the PA Virtual Account to accept "Any Amount" or "Partial Payments." This is financially fatal. If you drop the programmatic boundary, clients will intentionally short-pay invoices (e.g., wiring ₹25,000 to "manage cash flow"). The platform bleeds revenue.

We must build an automated State Machine that respects the rigid bounds of Indian tax law, without relying on manual reconciliations from the finance team.

We will deploy the Dynamic Tolerance & Forward Offsetting Architecture.