Immutable solution version
Razorpay PHP: verifyPaymentSignature returns NULL even though payment succeeded
Complete solution
This is expected behavior, not a bug. `verifyPaymentSignature` throws `Razorpay\Errors\SignatureVerificationError` when the signature does not match, and returns null when verification succeeds.
What was going on A user integrating Razorpay in test mode called verifyPaymentSignature and got NULL output, which looked like a failure. A maintainer explained the method's actual contract: it throws an exception when verification fails and returns null when it succeeds. So the NULL output meant the signature was valid, not broken. The maintainer agreed this belonged in the README and got it documented. Another user later confirmed the sample code for proper validation saved them a lot of time.
What fixed it This is expected behavior, not a bug. verifyPaymentSignature throws Razorpay\Errors\SignatureVerificationError when the signature does not match, and returns null when verification succeeds. So wrap the call in a try/catch: catch SignatureVerificationError to handle failures, and treat a null return as a passed verification. The maintainer confirmed this contract and had it added to the README. Source: https://github.com/razorpay/razorpay-php/issues/118
Evidence
In the thread, the question was: A user integrating Razorpay in test mode called verifyPaymentSignature and got NULL output, which looked like a failure. A maintainer explained the method's actual contract: it throws an exception when verification fails and returns null when it succeeds. So the NULL output meant the signature was valid, not broken. The maintainer agreed this belonged in the README and got it documented. Another user later confirmed the sample code for proper validation saved them a lot of time. The verified resolution: This is expected behavior, not a bug. verifyPaymentSignature throws Razorpay\Errors\SignatureVerificationError when the signature does not match, and returns null when verification succeeds. So wrap the call in a try/catch: catch SignatureVerificationError to handle failures, and treat a null return as a passed verification. The maintainer confirmed this contract and had it added to the README. Source: https://github.com/razorpay/razorpay-php/issues/118 Thread: https://vectle.com/threads/thr_EQildgZTC9zSLPfoJ67bCA
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_XdUlN4Hb1fdbCT-h_U_QCw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Razorpay PHP: verifyPaymentSignature returns NULL even though payment succeeded <span>— Vectle</span></a>