Skip to content

feat: extend validatePaymentVerification to support invoice payments - #451

Open
AxatSachani wants to merge 5 commits into
razorpay:masterfrom
AxatSachani:feature/invoice-signature-verification
Open

AxatSachani wants to merge 5 commits into
razorpay:masterfrom
AxatSachani:feature/invoice-signature-verification

Conversation

@AxatSachani

@AxatSachani AxatSachani commented Jul 3, 2025 •

Copy link
Copy Markdown
  • Tested
Test Case Document URL
View Test Case, View Test evidence

✅ What this PR does

This PR adds support for verifying invoice-based payments in the validatePaymentVerification utility method in the Razorpay Node.js SDK.

✨ New payload format supported for invoice payments:

razorpay_invoice_id|razorpay_invoice_receipt|razorpay_invoice_status|payment_id


📌 Why this is needed

The existing implementation of validatePaymentVerification only supported:

  • order_id
  • subscription_id
  • payment_link_id

However, many developers (including myself) use the Invoice API to create invoices and collect payments — especially for business compliance and downloadable PDF invoices. Until now, there was no official support for verifying invoice-based payments in the SDK.


🔧 What was added

  • Added a new conditional block to handle invoice-related fields:
    • razorpay_invoice_id
    • razorpay_invoice_receipt
    • razorpay_invoice_status
    • payment_id
  • Updated the error message to reflect all supported verification types.
  • Added a unit test to verify invoice signature using both valid and invalid signature values.

✅ Test Case

View the test case here:
📄 Invoice Payment Verification Test Case

test/utils/razorpay-utils.spec.js#L162


Testing

Test evidence: https://docs.google.com/document/d/1N7lUzFDZRspV833D94V7Pr_JEYza9JTfd7T8p0ozJeE/edit?usp=sharing

  • npm test: 380 passing, 0 failing (includes the new "Invoice Payment Verfication" test)
  • 9 scenario checks pass: valid signature, tampered signature, wrong secret, changed status, changed payment_id, order / subscription / payment link regression, missing-id error
  • Branch is rebased on the latest master (b9e8527)

Testing

Test evidence: https://docs.google.com/document/d/1N7lUzFDZRspV833D94V7Pr_JEYza9JTfd7T8p0ozJeE/edit?usp=sharing

  • npm test: 380 passing, 0 failing (includes the new "Invoice Payment Verfication" test)
  • 9 scenario checks pass: valid signature, tampered signature, wrong secret, changed status, changed payment_id, order / subscription / payment link regression, missing-id error
  • Branch is rebased on the latest master (b9e8527)

🔗 References


@AxatSachani

Copy link
Copy Markdown
Author

@ankitdas13 Could you please add the Tested label?
Test case added here:

it('Invoice Payment Verfication', () => {

@AxatSachani
AxatSachani marked this pull request as draft November 15, 2025 06:03
@AxatSachani
AxatSachani marked this pull request as ready for review November 15, 2025 06:04
@AxatSachani
AxatSachani force-pushed the feature/invoice-signature-verification branch 3 times, most recently from de7ef0d to 865f053 Compare September 30, 2026 04:42
- Extended the `validatePaymentVerification` method to support invoice-based payment verification.
- Added logic to handle the following payload structure:
    - ```razorpay_invoice_id|razorpay_invoice_receipt|razorpay_invoice_status|payment_id```
- This is useful when using Razorpay’s Invoice API to create invoices and collect payments.
- The change is backward compatible and preserves existing flows for order_id, subscription_id, and payment_link_id.
…ayment verification

- Introduced a new interface **```RazorpayVerifyInvoicePayment```** extending RazorpayWebhook.
- This interface defines the required fields for verifying invoice-based payments:
   - invoice_id
   - invoice_receipt_id
   - invoice_status
- Helps improve type safety and developer experience when working with invoice payment signature verification.
- Complements the logic added in ```validatePaymentVerification``` to support invoice-based flows.
…ntVerification

- Added a test case to verify the new invoice payment verification logic in ```validatePaymentVerification```.
- Test uses a sample payload with:
   - invoice_id
   - invoice_receipt_id
   - invoice_status
   - payment_id
- Validates both a correct and incorrect signature to ensure robustness of the verification logic.
- Complements the recent enhancement for invoice-based signature support.
- Error message referenced razorpay_invoice_id; the expected key is invoice_id
- Accept RazorpayVerifyInvoicePayment in validatePaymentVerification typings
- Document invoice payment verification in paymentVerfication.md
@AxatSachani
AxatSachani force-pushed the feature/invoice-signature-verification branch from 7a741a6 to 4d750f3 Compare September 30, 2026 04:48
@AxatSachani

Copy link
Copy Markdown
Author

@rzpamidi @ankitdas13
Hi team, I've added test evidence to the PR description (Google Doc: https://docs.google.com/document/d/1N7lUzFDZRspV833D94V7Pr_JEYza9JTfd7T8p0ozJeE/edit?usp=sharing).

The branch is up to date with master, and all 380 unit tests pass, including the new invoice verification test. Could a maintainer please add the Tested label so the BVT check can pass, and review when you have a moment? Thanks!

Fixes #450

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.

1 participant