Menu

How to Verify Razorpay Payments in ASP.NET Core
📰

How to Verify Razorpay Payments in ASP.NET Core

DEV Community: csharp·Naheel Muhammed·3 days ago
#7yyn3ttw
#devtocsharp#devto#dev#order#razorpay
Long article (1163 words) — no AI summary yet.
Reading 0:00
15s threshold

A browser can tell my API that a payment succeeded. It can also tell my API that it paid ₹1 for a ₹4,399 order. Both requests arrive in the same shape, so I stopped trying to tell them apart at the edge. My server proves the money itself.

GameHub is my .NET 8 store: 46 endpoints across 11 controllers. I built it to work through the whole commerce lifecycle, and payments were the part I couldn't fake. The file I use to decide whether an order is paid is RazorpayPaymentService.cs , 487 lines. Here's what's in it that matters.

I treat the client as a pointer, not proof

My verify endpoint takes RazorpayOrderId , RazorpayPaymentId , RazorpaySignature , and an optional Amount . Four fields a browser can type. I don't trust any of them on their own, so my controller does nothing except pass them to the service.

There's no try/catch in that controller either. ExceptionMiddleware maps BusinessRuleException to 400 and NotFoundException to 404.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.