From 77ae8599abfc6c04c35331d87ba9adebb0f67ed5 Mon Sep 17 00:00:00 2001 From: ChetanGN Date: Tue, 25 May 2021 18:25:24 +0530 Subject: [PATCH 1/2] Handled the null event and secret field case for auto webhook --- readme.txt | 2 +- woo-razorpay.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/readme.txt b/readme.txt index 09a65956..90c4e1e2 100644 --- a/readme.txt +++ b/readme.txt @@ -42,7 +42,7 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has == Changelog == = 2.7.1 = -* Update the Razorpay Order notes key. +* Updated the Razorpay Order notes key from woocommerce_order_id to woocommerce_order_number. = 2.7.0 = * Added auto-webhook setup feature. diff --git a/woo-razorpay.php b/woo-razorpay.php index 232d1363..b0b90ecc 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -286,7 +286,7 @@ public function autoEnableWebhook() if(in_array($_SERVER['SERVER_ADDR'], ["127.0.0.1","::1"])) { - error_log(json_encode('Could not enable webhook for localhost')); + error_log('Could not enable webhook for localhost'); return; } @@ -303,18 +303,24 @@ public function autoEnableWebhook() { ?>
-

+

-

+

Date: Thu, 27 May 2021 17:32:31 +0530 Subject: [PATCH 2/2] Added check condition for key and secret null --- woo-razorpay.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/woo-razorpay.php b/woo-razorpay.php index b0b90ecc..661a0c1a 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -269,8 +269,23 @@ public function autoEnableWebhook() $webhookExist = false; $webhookUrl = esc_url(admin_url('admin-post.php')) . '?action=rzp_wc_webhook'; - $enabled = $this->getSetting('enable_webhook'); - $secret = $this->getSetting('webhook_secret'); + $key_id = $this->getSetting('key_id'); + $key_secret = $this->getSetting('key_secret'); + $enabled = $this->getSetting('enable_webhook'); + $secret = $this->getSetting('webhook_secret'); + + //validating the key id and key secret set properly or not. + if($key_id == null || $key_secret == null) + { + ?> +
+

+
+ getSetting('webhook_events'); @@ -299,7 +314,8 @@ public function autoEnableWebhook() } else { - if (empty($eventsSubscribe) === true) + //validating event is not empty + if(empty($eventsSubscribe) === true) { ?>
@@ -311,7 +327,8 @@ public function autoEnableWebhook() return; } - if (empty($secret) === true) + //validating webhook secret is not empty + if(empty($secret) === true) { ?>