Let us follow one order through a checkout, slowly, and note at each step what the tester should be checking. The shop is an illustrative online store selling handloom sarees from Varanasi. The customer, Farhan, adds a saree worth ₹4,200 to the cart and chooses UPI at checkout. The store uses a payment gateway; it does not talk to banks directly.
Step 1: the order exists before the payment does
When Farhan taps Pay, the store creates an order record in a state like “payment initiated” and asks the gateway for a payment attempt, getting back a reference. This ordering matters. If the order were created only after success, a payment that succeeds while the customer’s browser is closed would have nothing to attach to.
Test here: the order has a unique reference, the amount is stored in the system and not trusted from the browser, and tapping Pay twice quickly does not create two orders or two attempts. Change the amount in the request using a proxy tool and confirm the server rejects or ignores it.
Step 2: the customer leaves your page
Farhan is sent to his UPI app, or enters a UPI ID, and approves the payment with his PIN. During this time your website is not in control. He may take two minutes because the PIN is forgotten. He may switch apps and the browser tab may be reloaded by the phone’s memory manager. He may lose mobile data right after approving.
Test here: come back to the store in the middle of the process and see what the page says. Press the browser back button. Open the order page in a second tab. None of these should show “paid” or let him pay for the same order again without warning.
Step 3: there are more than two outcomes
Testers new to payments often write two cases, success and failure. Real UPI flows have at least a third: pending. The bank or the network has not yet confirmed the result when the gateway has to answer. Pending may resolve to success minutes later, or to failure.
So the order can end up in these states, and each needs a defined behaviour:
- Success: order confirmed, stock reserved, confirmation sent once.
- Failure: customer told clearly, retry allowed, no stock lost for good.
- Pending: order held, customer told it is being confirmed, no second charge invited.
- Expired: customer never completed it; the attempt is closed after a set time.
Most gateways offer sandbox modes that let you force these outcomes with specific test values or test accounts. Check your provider’s documentation for how, since each does it differently. If the sandbox cannot produce pending, you can still test your side by simulating the callback or status response with a stub.
Step 4: two ways of learning the result
The store hears about the result in two ways. The browser returns to a redirect URL, and the gateway also sends a server-to-server notification, usually called a webhook or callback. The redirect is convenient but unreliable, because the customer may never come back. The server notification is the one to trust, after verifying its signature.
This leads to the most valuable tests in the whole flow.
- The money is debited, the customer closes the browser, and only the notification arrives. The order should still become confirmed.
- The notification arrives twice, which retries make common. The order should be confirmed once, with one email and one stock deduction.
- The notification arrives before the redirect, or out of order, such as “failed” arriving after “success” for the same attempt. The system should not move backwards.
- A notification with an invalid signature is rejected and logged.
- The notification amount differs from the order amount. The order should be flagged, not confirmed.
Step 5: when nobody tells you
Suppose the notification never comes. A good system does not leave the order pending forever. It runs a status check against the gateway after a delay, repeating on a schedule for a limited period, and settles the order on whatever the gateway reports. Test this by suppressing the callback in your test setup and confirming the scheduled check picks up the final state.
Then there is the awkward case: the customer’s account was debited but the payment is recorded as failed on your side. Banks and payment networks have rules and timelines for reversing such debits automatically, and they vary by case, so your documentation should state what the customer is told and by when. What you test is your own side: that the customer sees honest wording (“if money was deducted, it will be returned as per your bank’s timelines”) and that support can look the order up by gateway reference.
Step 6: the daily reconciliation
Even with every test above passing, the finance team will compare the day’s orders against the gateway’s settlement report. Mismatches fall into three groups: paid at the gateway but not confirmed in the store, confirmed in the store but not paid, and amount differences. A reconciliation job that lists these is worth testing like any feature, with prepared data that includes one of each kind.
Back to Farhan. If all this works, he never notices. He taps Pay, loses network for a minute, sees “confirming your payment”, and then receives one confirmation message for his ₹4,200 saree. The skill in testing payments is spending most of your time on the paths he hopefully never meets.
Figures and names in the examples are illustrative.
Leave a Reply