Skip to content

Commit

Permalink
Added delay in webhook to avoid duplicate orders (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramth05 authored Dec 9, 2020
1 parent cf320d2 commit 96a0040
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Controller/Payment/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,23 @@ protected function orderPaid(array $post)

$quote = $this->getQuoteObject($post, $quoteId);

//before creating order let wait for 15 sec and re-verify if the quote is active or not
$this->logger->info("Razorpay Webhook: Waiting for 15 sec with quoteID:$quoteId.");

sleep(15);

$this->logger->info("Razorpay Webhook: Waiting of 15 sec over with quoteID:$quoteId.");

//validate if the quote Order is still active
$quoteUpdated = $this->quoteRepository->get($quoteId);

//exit if quote is not active
if (!$quoteUpdated->getIsActive())
{
$this->logger->info("Razorpay Webhook: Quote order is inactive for quoteID: $quoteId and Razorpay payment_id(:$paymentId)");
return;
}

$order = $this->quoteManagement->submit($quote);

$payment = $order->getPayment();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "razorpay/magento",
"description": "Razorpay Magento 2.0 plugin for accepting payments.",
"version": "3.2.1",
"version": "3.2.2",
"require": {
"php": "~5.5.0|~5.6.0|^7.0",
"razorpay/razorpay": "2.*"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Razorpay_Magento" setup_version="3.2.1">
<module name="Razorpay_Magento" setup_version="3.2.2">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 96a0040

Please sign in to comment.