Razorpay for WooCommerce - Version 3.7.2

Version Description

  • Bug fix for webhook.
Download this release

Release Info

Developer razorpay
Plugin Icon 128x128 Razorpay for WooCommerce
Version 3.7.2
Comparing to
See all releases

Code changes from version 3.7.1 to 3.7.2

Files changed (3) hide show
  1. includes/razorpay-webhook.php +21 -8
  2. readme.txt +4 -1
  3. woo-razorpay.php +8 -5
includes/razorpay-webhook.php CHANGED
@@ -76,22 +76,35 @@ class RZP_Webhook
76
  return;
77
  }
78
 
79
-
80
-
81
  if (empty($data['event']) === false) {
 
 
 
82
  // Skip the webhook if not the valid data and event
83
  if ($this->shouldConsumeWebhook($data) === false) {
 
 
84
  return;
85
  }
86
  if (isset($_SERVER['HTTP_X_RAZORPAY_SIGNATURE']) === true) {
87
- $razorpayWebhookSecret = get_option('rzp_webhook_secret');
88
  //
89
  // If the webhook secret isn't set on wordpress, return
90
  //
91
- if (empty($razorpayWebhookSecret) === true) {
92
- return;
93
- }
 
 
 
 
 
94
 
 
 
 
 
 
95
  try
96
  {
97
  $this->api->utility->verifyWebhookSignature($post,
@@ -104,12 +117,12 @@ class RZP_Webhook
104
  'event' => 'razorpay.wc.signature.verify_failed',
105
  );
106
 
 
 
107
  error_log(json_encode($log));
108
  return;
109
  }
110
 
111
- $orderId = $data['payload']['payment']['entity']['notes']['woocommerce_order_number'];
112
-
113
  rzpLogInfo("Woocommerce orderId: $orderId webhook process intitiated");
114
 
115
  switch ($data['event']) {
76
  return;
77
  }
78
 
 
 
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) {
85
+ rzpLogInfo("Woocommerce orderId: $orderId webhook process exited in shouldConsumeWebhook function");
86
+
87
  return;
88
  }
89
  if (isset($_SERVER['HTTP_X_RAZORPAY_SIGNATURE']) === true) {
90
+ $razorpayWebhookSecret = $this->razorpay->getSetting('webhook_secret');
91
  //
92
  // If the webhook secret isn't set on wordpress, return
93
  //
94
+ if (empty($razorpayWebhookSecret) === true ) {
95
+ $razorpayWebhookSecret = get_option('rzp_webhook_secret');
96
+ if (empty($razorpayWebhookSecret) === false){
97
+ $this->razorpay->update_option('webhook_secret', $razorpayWebhookSecret);
98
+ }
99
+ else
100
+ {
101
+ rzpLogInfo("Woocommerce orderId: $orderId webhook process exited due to secret not available");
102
 
103
+ return;
104
+ }
105
+ }
106
+
107
+
108
  try
109
  {
110
  $this->api->utility->verifyWebhookSignature($post,
117
  'event' => 'razorpay.wc.signature.verify_failed',
118
  );
119
 
120
+ rzpLogError(json_encode($log));
121
+
122
  error_log(json_encode($log));
123
  return;
124
  }
125
 
 
 
126
  rzpLogInfo("Woocommerce orderId: $orderId webhook process intitiated");
127
 
128
  switch ($data['event']) {
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.7.1
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.7.1 =
45
  * Bug fix for auto webhook.
46
  * Added supported subscription webhook events
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 5.9
6
+ Stable tag: 3.7.2
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.7.2 =
45
+ * Bug fix for webhook.
46
+
47
  = 3.7.1 =
48
  * Bug fix for auto webhook.
49
  * Added supported subscription webhook events
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.7.1
7
- * Stable tag: 3.7.1
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.4.1
10
  * Author URI: https://razorpay.com
@@ -309,7 +309,8 @@ function woocommerce_razorpay_init()
309
  $enabled = true;
310
  $alphanumericString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-=~!@#$%^&*()_+,./<>?;:[]{}|abcdefghijklmnopqrstuvwxyz';
311
  $secret = substr(str_shuffle($alphanumericString), 0, 20);
312
- update_option('rzp_webhook_secret', $secret);
 
313
  $getWebhookFlag = get_option('webhook_enable_flag');
314
  $time = time();
315
 
@@ -591,7 +592,7 @@ function woocommerce_razorpay_init()
591
  {
592
  $getWebhookFlag = get_option('webhook_enable_flag');
593
  $time = time();
594
- if (!empty($getWebhookFlag))
595
  {
596
  if ($getWebhookFlag + 86400 < time())
597
  {
@@ -1086,7 +1087,9 @@ EOT;
1086
 
1087
  $postData = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_status FROM $wpdb->posts AS P WHERE post_type=%s AND post_password = %s", $post_type, $post_password ) );
1088
 
1089
- if (count($postData[0]) > 0)
 
 
1090
  {
1091
  $orderId = $postData[0]->ID;
1092
 
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
+ * Version: 3.7.2
7
+ * Stable tag: 3.7.2
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.4.1
10
  * Author URI: https://razorpay.com
309
  $enabled = true;
310
  $alphanumericString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-=~!@#$%^&*()_+,./<>?;:[]{}|abcdefghijklmnopqrstuvwxyz';
311
  $secret = substr(str_shuffle($alphanumericString), 0, 20);
312
+
313
+ $this->update_option('webhook_secret', $secret);
314
  $getWebhookFlag = get_option('webhook_enable_flag');
315
  $time = time();
316
 
592
  {
593
  $getWebhookFlag = get_option('webhook_enable_flag');
594
  $time = time();
595
+ if (empty($getWebhookFlag) == false)
596
  {
597
  if ($getWebhookFlag + 86400 < time())
598
  {
1087
 
1088
  $postData = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_status FROM $wpdb->posts AS P WHERE post_type=%s AND post_password = %s", $post_type, $post_password ) );
1089
 
1090
+ $arrayPost = json_decode(json_encode($postData), true);
1091
+
1092
+ if (!empty($arrayPost) && count($arrayPost[0]) > 0)
1093
  {
1094
  $orderId = $postData[0]->ID;
1095