Repository navigation
feat(utility): add verify_invoice_payment_signature method - #348
Open
Sreejith088 wants to merge 1 commit into
Open
Sreejith088 wants to merge 1 commit into
Sreejith088 wants to merge 1 commit into
Conversation
Closes razorpay#254 Invoice-based payments use a different signature message format than order-based payments. The existing SDK had no method to verify these signatures, leaving users to implement their own logic without documentation on the message structure. Adds verify_invoice_payment_signature() following the same pattern as verify_payment_signature and verify_subscription_payment_signature. Message format: invoice_id|invoice_receipt|invoice_status|payment_id Null/None invoice_receipt is treated as an empty string. Also adds three tests covering: valid signature, null receipt, and invalid signature (exception path).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #254
Invoice-based payments use a different signature message structure than order-based payments. The existing SDK had no method to verify these signatures, leaving developers to implement their own logic without any documentation on the correct message format.
This PR adds
verify_invoice_payment_signature()to theUtilityclass, following the same pattern asverify_payment_signatureandverify_subscription_payment_signature.Message format:
invoice_id|invoice_receipt|invoice_status|payment_idA
None/nullrazorpay_invoice_receipt(which Razorpay can return when no receipt is set) is treated as an empty string, consistent with how the PHP SDK handles this case (see razorpay/razorpay-php#147).Changes
razorpay/utility/utility.py: addedverify_invoice_payment_signature(parameters)methodtests/test_client_utility.py: added 3 tests covering valid signature, null receipt, and invalid signature (exception path)Test plan
test_verify_invoice_payment_signature— valid signature with receipttest_verify_invoice_payment_signature_null_receipt— valid signature when receipt is Nonetest_verify_invoice_payment_signature_with_exception— raisesSignatureVerificationErroron bad signature9 passed)References