Indian Financial & Statutory Primitives for Go

github.com/abeta-dev/go-fintech-india is a zero-dependency Go library engineered for payment gateways, banking cores, B2B ERPs, and financial ledgers operating under Indian statutory regulations (UIDAI, GSTN, CBDT, RBI, NPCI, and MCA).

Coverage: 100.0% statements
Release: v0.6.0
Dependencies: 0 external (Pure Go stdlib)
Exported API: 182 verified symbols
go get github.com/abeta-dev/go-fintech-india@v0.6.0

Core Statutory & Financial Capabilities

Every validator and formatter is built to execute with zero heap allocations on hot verification paths while preventing floating-point rounding drift and timing side-channels.

Domain Key Symbols Guarantees & Invariants
Exact INR Paise Math Money, NewMoney, Split, Allocate Stores currency as int64 paise (1 INR = 100 paise). Hare-Niemeyer proportional allocation guarantees sum of parts equals total with zero remainder loss.
GST Tax-Split & Statutory TDS CalculateGST, CalculateGSTByState, CalculateTDS, TDSRateBps Deterministic intra-state (CGST + SGST with zero paise drift) vs inter-state (IGST) tax splits and statutory TDS sections (194C, 194J, 194H, 194I, 194Q, 194O) with Section 206AA 20% non-PAN escalation.
Lakhs/Crores & Legal Words FormatINR, AppendINR, ParseINR, InWords Canonical Indian digit grouping (₹12,34,567.89), zero-allocation byte appending, and overflow-safe cheque words (including math.MinInt64).
UIDAI Aadhaar ValidateAadhaar, CalculateVerhoeffCheckDigit, MaskAadhaar Official Verhoeff Dihedral Group D5 checksum verification and statutory storage masking (XXXX-XXXX-1234).
GSTN GSTIN & PAN ValidateGSTIN, StateName, ValidatePAN, EntityType 15-character ISO/IEC 7064 Mod-36 checksum, 37 State/UT code registry lookup, embedded PAN extraction, and 4th-char taxpayer classification.
RBI IFSC, MICR & Accounts ValidateIFSC, NewOfflineIFSCResolver, ValidateMICR, MaskBankAccount 11-character IFSC validation, offline & live Razorpay HTTP branch resolution with fallback, 9-digit MICR clearing validation, and DoT E.164 mobile normalization.
NPCI UPI & Gateway Webhooks GenerateUPIURI, ParseUPIURI, ValidateRazorpayWebhook, ValidateCashfreeWebhook, ValidatePhonePeWebhook CRLF-sanitized upi://pay intent generation, PSP handle directory, and constant-time HMAC-SHA256 / SHA256 webhook verification with replay window enforcement.
Bulk Indian PII Airlock ScanText, RedactText, RedactMask, RedactHash, WithDefaultTestAllowlist Unstructured-text detection and single-pass redaction of GSTIN, PAN, Aadhaar (Verhoeff D5), +91 mobile numbers, IFSC, UPI VPAs (zero email false positives), and context-anchored OTPs for AI/LLM airlocks.
Financial Year & MCA Aging FYFromDate, AdvanceTaxDueDates, NewAgingReport April 1 – March 31 FY/AY resolution, Section 211 quarterly advance tax schedules (15%, 45%, 75%, 100%), and MCA Schedule III receivables aging buckets.

Verified End-to-End Checkout & KYC Example

The complete runnable program in examples/checkout_verification/main.go exercises KYC verification, GST invoice splitting, UPI intent URI generation, Cashfree webhook authentication, and MCA Schedule III aging in a single pipeline:

package main

import (
	"context"
	"fmt"
	"time"

	fintechin "github.com/abeta-dev/go-fintech-india"
)

func main() {
	// 1. Statutory KYC: GSTIN Mod-36, PAN Entity Classification & UIDAI Aadhaar Masking
	gstin := "29AACCG0527D1Z0"
	stateName, _ := fintechin.StateName(fintechin.StateCode(gstin))
	pan := fintechin.ExtractPAN(gstin)
	entityType, _ := fintechin.EntityType(pan)

	resolver := fintechin.NewOfflineIFSCResolver()
	branch, _ := resolver.Resolve(context.Background(), "HDFC0000123")

	fmt.Printf("KYC: GSTIN=%s (%s), PAN=%s (%s), Bank=%s\n",
		gstin, stateName, fintechin.MaskPAN(pan), entityType, branch.Bank)

	// 2. Exact Paise Invoice Math & Remainder-Safe CGST/SGST Split
	subtotal, _ := fintechin.ParseINR("₹1,25,000.00")
	gstTotal := fintechin.NewMoney(subtotal.Paise() * 18 / 100)
	cgstSgst, _ := gstTotal.Split(2)
	grandTotal := subtotal.Add(gstTotal)

	fmt.Printf("Total: %s (CGST: ₹%s, SGST: ₹%s)\n",
		fintechin.FormatINRSymbol(grandTotal.Paise()),
		fintechin.FormatINR(cgstSgst[0].Paise()),
		fintechin.FormatINR(cgstSgst[1].Paise()))
	fmt.Printf("Legal Words: %s\n", fintechin.InWords(grandTotal))

	// 3. NPCI UPI Intent URI Generation & MCA Schedule III Receivables Aging
	upiURI, _ := fintechin.GenerateUPIURI(fintechin.UPIParams{
		PayeeAddress: "abeta.vendor@okhdfcbank",
		PayeeName:    "Abeta Vendor Portal",
		Amount:       grandTotal.String(),
		RefID:        "INV-2026-001",
	})
	invDate := time.Date(2026, time.May, 20, 0, 0, 0, 0, time.UTC)
	fy := fintechin.FYFromDate(invDate)
	fmt.Printf("Settlement: %s | %s (%s)\n", upiURI, fy.Label(), fy.AssessmentYear())
}

Zero-Allocation Benchmark Profile

Measured with go test -bench=. -benchmem ./... on 64-bit architecture. Core validation and currency formatting routines perform zero heap allocations:

Operation Benchmark Symbol Latency Heap Bytes Allocs
PAN Format & Structure BenchmarkValidatePAN 7 ns/op 0 B/op 0 allocs/op
IFSC Code Validation BenchmarkValidateIFSC 7 ns/op 0 B/op 0 allocs/op
Currency Append INR (Streaming) BenchmarkAppendINR 17 ns/op 0 B/op 0 allocs/op
Currency Format INR (Lakhs/Crores) BenchmarkFormatINR 24 ns/op 0 B/op 0 allocs/op
Aadhaar Verhoeff D5 Checksum BenchmarkValidateAadhaar 38 ns/op 0 B/op 0 allocs/op
UPI VPA Validation BenchmarkValidateUPI 47 ns/op 0 B/op 0 allocs/op
GSTIN Mod-36 Checksum BenchmarkValidateGSTIN 51 ns/op 0 B/op 0 allocs/op
Offline IFSC Branch Resolution BenchmarkOfflineIFSCResolver 71 ns/op 144 B/op 1 allocs/op
PhonePe S2S Webhook Verification BenchmarkVerifyPhonePeWebhook 542 ns/op 192 B/op 4 allocs/op

Statutory Authorities & Regulatory Specifications

Module Governing Authority Statutory Standard / Specification
Aadhaar UIDAI Verhoeff Dihedral Group D5 Checksum Algorithm & UIDAI Aadhaar Masking Regulations
GSTIN GSTN / CBIC ISO/IEC 7064:2003 Mod 36,36 Checksum & Central Goods and Services Tax (CGST) Rules 2017
PAN Income Tax Dept (CBDT) Section 139A of Income Tax Act 1961 & Rule 114 of Income Tax Rules
IFSC & MICR Reserve Bank of India (RBI) RBI National Clearing Cell & RTGS / NEFT / IMPS Procedural Guidelines
UPI NPCI Unified Payments Interface (UPI) Linking Specifications & Merchant Intent Guidelines
Mobile DoT (Telecom) National Numbering Plan (NNP) 10-digit series (6/7/8/9) & ITU-T E.164 (+91)
Financial Year & Tax CBDT / Ministry of Finance Section 2(9) & Section 208 / 211 Advance Tax Installments of Income Tax Act 1961
Receivables Aging Ministry of Corporate Affairs (MCA) Companies Act 2013, Schedule III Division I & II Trade Receivables Aging

AI Agent Skills & Multi-Model Context Routing

This repository ships portable SKILL.md modules and a root AGENTS.md routing table so coding agents load only the exact domain context required:

Skill Name Path Scope
go-fintech-india skills/go-fintech-india/SKILL.md Umbrella router for all 182 exported symbols across 18 domain files, zero-dependency rules, and verification gates.
go-fintech-india-money-tax skills/go-fintech-india-money-tax/SKILL.md Exact int64 paise Money, Split, Allocate, CalculateGST, CalculateTDS, FormatINR, InWords, FinancialYear, and AgingReport.
go-fintech-india-kyc-statutory skills/go-fintech-india-kyc-statutory/SKILL.md ScanText, RedactText, ValidateGSTIN, ValidatePAN, ValidateAadhaar, ValidateIFSC, NewOfflineIFSCResolver, ValidateMICR, and ValidateMobile.
go-fintech-india-payments-upi skills/go-fintech-india-payments-upi/SKILL.md ValidateUPI, GenerateUPIURI, ParseUPIURI, and constant-time Razorpay, Cashfree, and PhonePe webhook verifiers.