From f81a2a731af99047ef54bb22198195bda0fa553b Mon Sep 17 00:00:00 2001 From: Rohit Rajat Chattopadhyay Date: Fri, 10 Jan 2020 00:58:41 +0530 Subject: [PATCH] Add Signature verification for Invoice entity Invoice entity includes Payment Links and Invoices system --- src/Utility.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Utility.php b/src/Utility.php index 22e588ff..db3c6c8f 100644 --- a/src/Utility.php +++ b/src/Utility.php @@ -35,6 +35,33 @@ public function verifyPaymentSignature($attributes) self::verifySignature($payload, $actualSignature, $secret); } + public function verifyInvoiceSignature($attributes) + { + $actualSignature = $attributes['razorpay_signature']; + + if (isset($attributes['razorpay_invoice_id']) === true) + { + $paymentId = $attributes['razorpay_payment_id']; + $invId = $attributes['razorpay_invoice_id']; + $invStatus = $attributes['razorpay_invoice_status']; + + $invReceipt = ""; + if(isset($attributes['razorpay_invoice_receipt'])==true) + $invReceipt = $attributes['razorpay_invoice_receipt']; + + $payload = $invId . '|' . $invReceipt . '|' . $invStatus . '|' . $paymentId; + } + else + { + throw new Errors\SignatureVerificationError( + 'razorpay_invoice_id must be present.'); + } + + $secret = Api::getSecret(); + + self::verifySignature($payload, $actualSignature, $secret); + } + public function verifyWebhookSignature($payload, $actualSignature, $secret) { self::verifySignature($payload, $actualSignature, $secret);