From 2ea2efb30f3bae98f9c8221a1bd161a1ca373e92 Mon Sep 17 00:00:00 2001 From: ChetanGN Date: Thu, 12 May 2022 09:03:29 +0530 Subject: [PATCH 1/3] Handled draft order update on webhook --- includes/razorpay-webhook.php | 14 +++++++++++--- woo-razorpay.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/includes/razorpay-webhook.php b/includes/razorpay-webhook.php index e1de5c26..c3abae9e 100644 --- a/includes/razorpay-webhook.php +++ b/includes/razorpay-webhook.php @@ -214,13 +214,21 @@ protected function paymentAuthorized(array $data) set_transient('webhook_trigger_count_for_' . $orderId, $triggerCount, 180); + $orderStatus = $order->get_status(); + rzpLogInfo("Woocommerce orderId: $orderId order status: $orderStatus"); + // If it is already marked as paid, ignore the event - if ($order->needs_payment() === false) { - rzpLogInfo("Woocommerce orderId: $orderId webhook process exited"); + if ($orderStatus != 'draft' && $order->needs_payment() === false) { + rzpLogInfo("Woocommerce orderId: $orderId webhook process exited with need payment status :". $order->needs_payment()); return; } - + + if($orderStatus == 'draft') + { + updateOrderStatus($orderId, 'wc-pending'); + } + $razorpayPaymentId = $data['payload']['payment']['entity']['id']; $payment = $this->getPaymentEntity($razorpayPaymentId, $data); diff --git a/woo-razorpay.php b/woo-razorpay.php index 6237df48..60817cfc 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -1280,7 +1280,7 @@ public function updateOrder(& $order, $success, $errorMessage, $razorpayPaymentI rzpLogInfo("updateOrder orderId: $orderId , errorMessage: $errorMessage, razorpayPaymentId: $razorpayPaymentId , success: $success"); - if (($success === true) and ($order->needs_payment() === true)) + if ($success === true) { try { From 346046cc04b94a03e4f043d4a9b962e158e75b53 Mon Sep 17 00:00:00 2001 From: ChetanGN Date: Thu, 12 May 2022 09:05:43 +0530 Subject: [PATCH 2/3] Console error log fix --- templates/rzp-pdp-checkout-btn.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/rzp-pdp-checkout-btn.php b/templates/rzp-pdp-checkout-btn.php index ce3e9f7c..a18aad01 100644 --- a/templates/rzp-pdp-checkout-btn.php +++ b/templates/rzp-pdp-checkout-btn.php @@ -34,10 +34,10 @@ class="button alt single_add_to_cart_button" jQuery('.qty').on('change',function(e) { - let i = 0; + let x = 0; while (typeof quantity === 'undefined') { - var quantity = document.getElementsByClassName("qty")[i].value; - i++; + var quantity = document.getElementsByClassName("qty")[x].value; + x++; } btnPdp.setAttribute('quantity', quantity); From 8bd76a20a6ef1821c00e070de56d9f65fff68ab7 Mon Sep 17 00:00:00 2001 From: ChetanGN Date: Thu, 12 May 2022 18:57:05 +0530 Subject: [PATCH 3/3] Added version bump 3.5.1 --- readme.txt | 5 ++++- woo-razorpay.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index 861a5460..a5407c20 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: razorpay Tags: razorpay, payments, india, woocommerce, ecommerce Requires at least: 3.9.2 Tested up to: 5.9 -Stable tag: 3.5.0 +Stable tag: 3.5.1 Requires PHP: 5.6 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -41,6 +41,9 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has == Changelog == += 3.5.1 = +* Bug fix for magic checkout blank order issue. + = 3.5.0 = * Feature Auto Enable webhook. * Tested up to Woocommerce 6.4.1 diff --git a/woo-razorpay.php b/woo-razorpay.php index 60817cfc..6cf2f6bb 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -3,8 +3,8 @@ * Plugin Name: Razorpay for WooCommerce * Plugin URI: https://razorpay.com * Description: Razorpay Payment Gateway Integration for WooCommerce - * Version: 3.5.0 - * Stable tag: 3.5.0 + * Version: 3.5.1 + * Stable tag: 3.5.1 * Author: Team Razorpay * WC tested up to: 6.4.1 * Author URI: https://razorpay.com