From 53e1e27e127a0918e1494ebfc6fd0dd2060efb76 Mon Sep 17 00:00:00 2001 From: Ram Prakash Singh Date: Tue, 24 Mar 2020 10:02:14 +0530 Subject: [PATCH 1/2] SI-1187: fixed issue related with webhook processing duplicate order --- Controller/Payment/Webhook.php | 10 ++++++++++ composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Controller/Payment/Webhook.php b/Controller/Payment/Webhook.php index 72cce1fc..070a478c 100644 --- a/Controller/Payment/Webhook.php +++ b/Controller/Payment/Webhook.php @@ -167,6 +167,16 @@ protected function orderPaid(array $post) $this->logger->warning("Razorpay Webhook processing started for Razorpay payment_id(:$paymentId)"); + $payment_created_time = $post['payload']['payment']['entity']['created_at']; + + //added check that webhook should not executed, during front end payment processing + if((time() - $payment_created_time) < 10) + { + $this->logger->warning("Razorpay Webhook: Order processing is active for quoteID: $quoteId and Razorpay payment_id(:$paymentId)"); + header('Status: 425 Too Early for processing', true, 425); + exit; + } + //validate if the quote Order is still active $quote = $this->quoteRepository->get($quoteId); diff --git a/composer.json b/composer.json index d1b40738..bb747672 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "razorpay/magento", "description": "Razorpay Magento 2.0 plugin for accepting payments.", - "version": "2.9.2", + "version": "2.9.3", "require": { "php": "~5.5.0|~5.6.0|^7.0", "razorpay/razorpay": "2.*" diff --git a/etc/module.xml b/etc/module.xml index ab2ca7b6..a0e0dbd5 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + From ec5da0b85bc7ae31a51674c6ee6d8276c1108b1b Mon Sep 17 00:00:00 2001 From: Ram Prakash Singh Date: Tue, 24 Mar 2020 14:57:58 +0530 Subject: [PATCH 2/2] Updated header to 409 --- Controller/Payment/Webhook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Payment/Webhook.php b/Controller/Payment/Webhook.php index 070a478c..ae1ff0dd 100644 --- a/Controller/Payment/Webhook.php +++ b/Controller/Payment/Webhook.php @@ -173,7 +173,7 @@ protected function orderPaid(array $post) if((time() - $payment_created_time) < 10) { $this->logger->warning("Razorpay Webhook: Order processing is active for quoteID: $quoteId and Razorpay payment_id(:$paymentId)"); - header('Status: 425 Too Early for processing', true, 425); + header('Status: 409 Conflict, too early for processing', true, 409); exit; }