Skip to content

feat(utility): add verify_invoice_payment_signature method - #348

Open
Sreejith088 wants to merge 1 commit into
razorpay:masterfrom
Sreejith088:fix/add-invoice-payment-signature-verification
Open

Sreejith088 wants to merge 1 commit into
razorpay:masterfrom
Sreejith088:fix/add-invoice-payment-signature-verification

Conversation

@Sreejith088

Copy link
Copy Markdown

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 the Utility class, following the same pattern as verify_payment_signature and verify_subscription_payment_signature.

Message format: invoice_id|invoice_receipt|invoice_status|payment_id

A None/null razorpay_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: added verify_invoice_payment_signature(parameters) method
  • tests/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 receipt
  • test_verify_invoice_payment_signature_null_receipt — valid signature when receipt is None
  • test_verify_invoice_payment_signature_with_exception — raises SignatureVerificationError on bad signature
  • All existing tests continue to pass (9 passed)

References

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not able to verify the invoice signature

1 participant