Version Description
- Added delay of 5 minutes to webhook process.
Download this release
Release Info
Developer | razorpay |
Plugin | Razorpay for WooCommerce |
Version | 3.9.4 |
Comparing to | |
See all releases |
Code changes from version 3.9.3 to 3.9.4
- includes/razorpay-webhook.php +28 -24
- readme.txt +4 -1
- woo-razorpay.php +2 -2
includes/razorpay-webhook.php
CHANGED
@@ -8,6 +8,16 @@ use Razorpay\Api\Errors;
|
|
8 |
|
9 |
class RZP_Webhook
|
10 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* Instance of the razorpay payments class
|
13 |
* @var WC_Razorpay
|
@@ -79,6 +89,7 @@ class RZP_Webhook
|
|
79 |
if (empty($data['event']) === false) {
|
80 |
|
81 |
$orderId = $data['payload']['payment']['entity']['notes']['woocommerce_order_number'];
|
|
|
82 |
|
83 |
// Skip the webhook if not the valid data and event
|
84 |
if ($this->shouldConsumeWebhook($data) === false) {
|
@@ -123,6 +134,23 @@ class RZP_Webhook
|
|
123 |
return;
|
124 |
}
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
rzpLogInfo("Woocommerce orderId: $orderId webhook process intitiated");
|
127 |
|
128 |
switch ($data['event']) {
|
@@ -216,18 +244,6 @@ class RZP_Webhook
|
|
216 |
{
|
217 |
$order = $this->checkIsObject($orderId);
|
218 |
}
|
219 |
-
//To give the priority to callback script to compleate the execution fist adding this locking.
|
220 |
-
$transientData = get_transient('webhook_trigger_count_for_' . $orderId);
|
221 |
-
|
222 |
-
if (empty($transientData) || $transientData == 1) {
|
223 |
-
rzpLogInfo("Woocommerce orderId: $orderId with transientData: $transientData webhook halted for 60 sec");
|
224 |
-
|
225 |
-
sleep(60);
|
226 |
-
}
|
227 |
-
|
228 |
-
$triggerCount = !empty($transientData) ? ($transientData + 1) : 1;
|
229 |
-
|
230 |
-
set_transient('webhook_trigger_count_for_' . $orderId, $triggerCount, 180);
|
231 |
|
232 |
$orderStatus = $order->get_status();
|
233 |
rzpLogInfo("Woocommerce orderId: $orderId order status: $orderStatus");
|
@@ -325,18 +341,6 @@ class RZP_Webhook
|
|
325 |
{
|
326 |
$order = $this->checkIsObject($orderId);
|
327 |
}
|
328 |
-
//To give the priority to callback script to compleate the execution fist adding this locking.
|
329 |
-
$transientData = get_transient('webhook_trigger_count_for_' . $orderId);
|
330 |
-
|
331 |
-
if (empty($transientData) || $transientData == 1) {
|
332 |
-
rzpLogInfo("Woocommerce orderId: $orderId with transientData: $transientData webhook halted for 60 sec");
|
333 |
-
|
334 |
-
sleep(60);
|
335 |
-
}
|
336 |
-
|
337 |
-
$triggerCount = !empty($transientData) ? ($transientData + 1) : 1;
|
338 |
-
|
339 |
-
set_transient('webhook_trigger_count_for_' . $orderId, $triggerCount, 180);
|
340 |
|
341 |
$orderStatus = $order->get_status();
|
342 |
rzpLogInfo("Woocommerce orderId: $orderId order status: $orderStatus");
|
8 |
|
9 |
class RZP_Webhook
|
10 |
{
|
11 |
+
/**
|
12 |
+
* @var HTTP CONFLICT Request
|
13 |
+
*/
|
14 |
+
protected const HTTP_CONFLICT_STATUS = 409;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var Webhook Notify Wait Time
|
18 |
+
*/
|
19 |
+
protected const WEBHOOK_NOTIFY_WAIT_TIME = (5 * 60);
|
20 |
+
|
21 |
/**
|
22 |
* Instance of the razorpay payments class
|
23 |
* @var WC_Razorpay
|
89 |
if (empty($data['event']) === false) {
|
90 |
|
91 |
$orderId = $data['payload']['payment']['entity']['notes']['woocommerce_order_number'];
|
92 |
+
$razorpayOrderId = $data['payload']['payment']['entity']['order_id'];
|
93 |
|
94 |
// Skip the webhook if not the valid data and event
|
95 |
if ($this->shouldConsumeWebhook($data) === false) {
|
134 |
return;
|
135 |
}
|
136 |
|
137 |
+
$rzpWebhookNotifiedAt = get_post_meta($orderId, "rzp_webhook_notified_at", true);
|
138 |
+
if ($rzpWebhookNotifiedAt === '')
|
139 |
+
{
|
140 |
+
update_post_meta($orderId, "rzp_webhook_notified_at", time());
|
141 |
+
error_log("ORDER NUMBER $orderId:webhook conflict due to early execution for razorpay order: $razorpayOrderId ");
|
142 |
+
header('Status: ' . static::HTTP_CONFLICT_STATUS . ' Webhook conflicts due to early execution.', true, static::HTTP_CONFLICT_STATUS);// nosemgrep : php.lang.security.non-literal-header.non-literal-header
|
143 |
+
return;
|
144 |
+
}
|
145 |
+
elseif ((time() - $rzpWebhookNotifiedAt) < static::WEBHOOK_NOTIFY_WAIT_TIME)
|
146 |
+
{
|
147 |
+
error_log("ORDER NUMBER $orderId:webhook conflict due to early execution for razorpay order: $razorpayOrderId ");
|
148 |
+
header('Status: ' . static::HTTP_CONFLICT_STATUS . ' Webhook conflicts due to early execution.', true, static::HTTP_CONFLICT_STATUS);// nosemgrep : php.lang.security.non-literal-header.non-literal-header
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
|
152 |
+
error_log("ORDER NUMBER $orderId:webhook conflict over for razorpay order: $razorpayOrderId");
|
153 |
+
|
154 |
rzpLogInfo("Woocommerce orderId: $orderId webhook process intitiated");
|
155 |
|
156 |
switch ($data['event']) {
|
244 |
{
|
245 |
$order = $this->checkIsObject($orderId);
|
246 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
$orderStatus = $order->get_status();
|
249 |
rzpLogInfo("Woocommerce orderId: $orderId order status: $orderStatus");
|
341 |
{
|
342 |
$order = $this->checkIsObject($orderId);
|
343 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
$orderStatus = $order->get_status();
|
346 |
rzpLogInfo("Woocommerce orderId: $orderId order status: $orderStatus");
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: razorpay
|
|
3 |
Tags: razorpay, payments, india, woocommerce, ecommerce
|
4 |
Requires at least: 3.9.2
|
5 |
Tested up to: 5.9
|
6 |
-
Stable tag: 3.9.
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
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
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
44 |
= 3.9.3 =
|
45 |
* Bug fix multiple shipping charges issue for magic checkout.
|
46 |
|
3 |
Tags: razorpay, payments, india, woocommerce, ecommerce
|
4 |
Requires at least: 3.9.2
|
5 |
Tested up to: 5.9
|
6 |
+
Stable tag: 3.9.4
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 3.9.4 =
|
45 |
+
* Added delay of 5 minutes to webhook process.
|
46 |
+
|
47 |
= 3.9.3 =
|
48 |
* Bug fix multiple shipping charges issue for magic checkout.
|
49 |
|
woo-razorpay.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
* Plugin Name: Razorpay for WooCommerce
|
4 |
* Plugin URI: https://razorpay.com
|
5 |
* Description: Razorpay Payment Gateway Integration for WooCommerce
|
6 |
-
* Version: 3.9.
|
7 |
-
* Stable tag: 3.9.
|
8 |
* Author: Team Razorpay
|
9 |
* WC tested up to: 6.4.1
|
10 |
* Author URI: https://razorpay.com
|
3 |
* Plugin Name: Razorpay for WooCommerce
|
4 |
* Plugin URI: https://razorpay.com
|
5 |
* Description: Razorpay Payment Gateway Integration for WooCommerce
|
6 |
+
* Version: 3.9.4
|
7 |
+
* Stable tag: 3.9.4
|
8 |
* Author: Team Razorpay
|
9 |
* WC tested up to: 6.4.1
|
10 |
* Author URI: https://razorpay.com
|