Validate and Normalize UPI VPA Handles Before Payment
Last updated: November 29, 2026
Quick Overview
Write a function that takes a user-typed UPI virtual payment address, normalizes it, and either returns the canonical form or a clear rejection reason, using a fixed set of known PSP handles.
PhonePe
November 29, 20260
0
0 solved
Write a function that takes a user-typed UPI virtual payment address, normalizes it, and either returns the canonical form or a clear rejection reason, using a fixed set of known PSP handles.
Before any pay request goes to NPCI, a PhonePe client or gateway must reject malformed addresses cheaply, because a bad VPA wastes a bank round trip and confuses the user. The interviewer checks that you turn fuzzy rules into exact, testable checks and think about real input like stray spaces and mixed case.
What the Interviewer Expects
- Clarify the exact rules before coding (allowed characters, length, handle list)
- Normalize (trim, lowercase) before validating
- Return a specific reason, not just a boolean, so the UI can show a helpful message
- Handle the mobile-number local part as its own rule
- Write quick tests for each rule and the happy path
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you keep the handle list fresh as new PSP handles go live without a client release?
- Where should this run: client, gateway, or both, and why?
- How would you extend this to verify that the VPA actually exists and show the account holder's name?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Rules (agreed with the interviewer):
- Exactly one
@. Left side is the local part, right side is the PSP handle. - Handle must be in a known set (for example
ybl,ibl,axl,oksbi). - Local p...
High-Level Design
Normalize, split once on @, check the handle against a set (O(1)), then run the local-part regex and the few rules a regex expresses poorly (.., trailing symbol, mobile number). Order the checks f...