Skip to content

Conversation

@AxatSachani
Copy link

@AxatSachani AxatSachani commented Jul 3, 2025

  • Tested
Test Case Document URL
View Test Case

✅ 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


🔗 References


- 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.
@AxatSachani
Copy link
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
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