Razorpay for WooCommerce - Version 3.8.1

Version Description

  • Bug fix webhook
  • Added meta info to magic checkout.
Download this release

Release Info

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

Code changes from version 3.8.0 to 3.8.1

Files changed (4) hide show
  1. includes/api/api.php +0 -7
  2. includes/api/order.php +3 -1
  3. readme.txt +5 -1
  4. woo-razorpay.php +34 -23
includes/api/api.php CHANGED
@@ -165,13 +165,6 @@ function addMagicCheckoutSettingFields(&$defaultFormFields)
165
  'step' => 1,
166
  ),
167
  ),
168
- 'enable_1cc_mandatory_login' => array(
169
- 'title' => __('Activate Mandatory Login'),
170
- 'type' => 'checkbox',
171
- 'description' => "",
172
- 'label' => __('Activate Mandatory Login for Magic Checkout'),
173
- 'default' => 'no',
174
- ),
175
  '1cc_min_COD_slab_amount' => array(
176
  'title' => __('Set minimum amount (INR) for COD'),
177
  'type' => 'number',
165
  'step' => 1,
166
  ),
167
  ),
 
 
 
 
 
 
 
168
  '1cc_min_COD_slab_amount' => array(
169
  'title' => __('Set minimum amount (INR) for COD'),
170
  'type' => 'number',
includes/api/order.php CHANGED
@@ -207,9 +207,11 @@ function createWcOrder(WP_REST_Request $request)
207
  $response['prefill']['contact'] = $contact ? $contact : '';
208
  }
209
 
 
 
210
  $response['prefill']['coupon_code'] = $couponCode;
211
 
212
- $response['mandatory_login'] = get_option('woocommerce_razorpay_settings')['enable_1cc_mandatory_login'] === 'yes' ? true : false;
213
 
214
  $response['enable_ga_analytics'] = get_option('woocommerce_razorpay_settings')['enable_1cc_ga_analytics'] === 'yes' ? true : false;
215
  $response['enable_fb_analytics'] = get_option('woocommerce_razorpay_settings')['enable_1cc_fb_analytics'] === 'yes' ? true : false;
207
  $response['prefill']['contact'] = $contact ? $contact : '';
208
  }
209
 
210
+ $response["_"] = $razorpay->getVersionMetaInfo($response);
211
+
212
  $response['prefill']['coupon_code'] = $couponCode;
213
 
214
+ $response['mandatory_login'] = false; // Removed the mandatory login option from admin config so sending bydefault false.
215
 
216
  $response['enable_ga_analytics'] = get_option('woocommerce_razorpay_settings')['enable_1cc_ga_analytics'] === 'yes' ? true : false;
217
  $response['enable_fb_analytics'] = get_option('woocommerce_razorpay_settings')['enable_1cc_fb_analytics'] === 'yes' ? true : false;
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.8.0
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,10 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
41
 
42
  == Changelog ==
43
 
 
 
 
 
44
  = 3.8.0 =
45
  * Added support for Pixel your site pro plugin in magic checkout.
46
  * Bug fix to handle the transient data.
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 5.9
6
+ Stable tag: 3.8.1
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.8.1 =
45
+ * Bug fix webhook
46
+ * Added meta info to magic checkout.
47
+
48
  = 3.8.0 =
49
  * Added support for Pixel your site pro plugin in magic checkout.
50
  * Bug fix to handle the transient data.
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.8.0
7
- * Stable tag: 3.8.0
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.4.1
10
  * Author URI: https://razorpay.com
@@ -307,8 +307,7 @@ function woocommerce_razorpay_init()
307
  $key_id = $this->getSetting('key_id');
308
  $key_secret = $this->getSetting('key_secret');
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');
@@ -366,8 +365,8 @@ function woocommerce_razorpay_init()
366
  $webhookItems[] = $value;
367
  }
368
  }
369
- } while ( $webhook['count'] >= 1);
370
-
371
  $data = [
372
  'url' => $webhookUrl,
373
  'active' => $enabled,
@@ -386,10 +385,10 @@ function woocommerce_razorpay_init()
386
  if (($evntval == 1) and
387
  (in_array($evntkey, $this->supportedWebhookEvents) === true))
388
  {
389
- $this->defaultWebhookEvents[$evntkey] = true;
390
  }
391
  }
392
-
393
  $data = [
394
  'url' => $webhookUrl,
395
  'active' => $enabled,
@@ -412,6 +411,13 @@ function woocommerce_razorpay_init()
412
 
413
  }
414
 
 
 
 
 
 
 
 
415
  // showing notice : status of 1cc active / inactive message in admin dashboard
416
  function addAdminCheckoutSettingsAlert() {
417
  $enable_1cc = $this->getSetting('enable_1cc');
@@ -590,20 +596,7 @@ function woocommerce_razorpay_init()
590
  */
591
  protected function getRazorpayPaymentParams($orderId)
592
  {
593
- $getWebhookFlag = get_option('webhook_enable_flag');
594
- $time = time();
595
- if (empty($getWebhookFlag) == false)
596
- {
597
- if ($getWebhookFlag + 86400 < time())
598
- {
599
- $this->autoEnableWebhook();
600
- }
601
- }
602
- else
603
- {
604
- update_option('webhook_enable_flag', $time);
605
- $this->autoEnableWebhook();
606
- }
607
  rzpLogInfo("getRazorpayPaymentParams $orderId");
608
  $razorpayOrderId = $this->createOrGetRazorpayOrderId($orderId);
609
 
@@ -740,6 +733,8 @@ function woocommerce_razorpay_init()
740
  protected function createRazorpayOrderId($orderId, $sessionKey)
741
  {
742
  rzpLogInfo("Called createRazorpayOrderId with params orderId $orderId and sessionKey $sessionKey");
 
 
743
  // Calls the helper function to create order data
744
  global $woocommerce;
745
 
@@ -757,6 +752,22 @@ function woocommerce_razorpay_init()
757
  return $e;
758
  }
759
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
760
  $razorpayOrderId = $razorpayOrder['id'];
761
 
762
  // Storing the razorpay order id in transient for 5 hours time.
@@ -1786,7 +1797,7 @@ EOT;
1786
  * @param $data
1787
  * @return array
1788
  */
1789
- protected function getVersionMetaInfo($data)
1790
  {
1791
  if (isset($data['subscription_id']) && isset($data['recurring'])) {
1792
  $pluginRoot = WP_PLUGIN_DIR . '/razorpay-subscriptions-for-woocommerce';
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
+ * Version: 3.8.1
7
+ * Stable tag: 3.8.1
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.4.1
10
  * Author URI: https://razorpay.com
307
  $key_id = $this->getSetting('key_id');
308
  $key_secret = $this->getSetting('key_secret');
309
  $enabled = true;
310
+ $secret = empty($this->getSetting('webhook_secret')) ? $this->generateSecret() : $this->getSetting('webhook_secret');
 
311
 
312
  $this->update_option('webhook_secret', $secret);
313
  $getWebhookFlag = get_option('webhook_enable_flag');
365
  $webhookItems[] = $value;
366
  }
367
  }
368
+ } while ( $webhook['count'] === $count);
369
+
370
  $data = [
371
  'url' => $webhookUrl,
372
  'active' => $enabled,
385
  if (($evntval == 1) and
386
  (in_array($evntkey, $this->supportedWebhookEvents) === true))
387
  {
388
+ $this->defaultWebhookEvents[$evntkey] = true;
389
  }
390
  }
391
+
392
  $data = [
393
  'url' => $webhookUrl,
394
  'active' => $enabled,
411
 
412
  }
413
 
414
+ public function generateSecret()
415
+ {
416
+ $alphanumericString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-=~!@#$%^&*()_+,./<>?;:[]{}|abcdefghijklmnopqrstuvwxyz';
417
+ $secret = substr(str_shuffle($alphanumericString), 0, 20);
418
+
419
+ return $secret;
420
+ }
421
  // showing notice : status of 1cc active / inactive message in admin dashboard
422
  function addAdminCheckoutSettingsAlert() {
423
  $enable_1cc = $this->getSetting('enable_1cc');
596
  */
597
  protected function getRazorpayPaymentParams($orderId)
598
  {
599
+
 
 
 
 
 
 
 
 
 
 
 
 
 
600
  rzpLogInfo("getRazorpayPaymentParams $orderId");
601
  $razorpayOrderId = $this->createOrGetRazorpayOrderId($orderId);
602
 
733
  protected function createRazorpayOrderId($orderId, $sessionKey)
734
  {
735
  rzpLogInfo("Called createRazorpayOrderId with params orderId $orderId and sessionKey $sessionKey");
736
+
737
+
738
  // Calls the helper function to create order data
739
  global $woocommerce;
740
 
752
  return $e;
753
  }
754
 
755
+ $getWebhookFlag = get_option('webhook_enable_flag');
756
+ $time = time();
757
+
758
+ if (empty($getWebhookFlag) == false)
759
+ {
760
+ if ($getWebhookFlag + 86400 < time())
761
+ {
762
+ $this->autoEnableWebhook();
763
+ }
764
+ }
765
+ else
766
+ {
767
+ update_option('webhook_enable_flag', $time);
768
+ $this->autoEnableWebhook();
769
+ }
770
+
771
  $razorpayOrderId = $razorpayOrder['id'];
772
 
773
  // Storing the razorpay order id in transient for 5 hours time.
1797
  * @param $data
1798
  * @return array
1799
  */
1800
+ public function getVersionMetaInfo($data)
1801
  {
1802
  if (isset($data['subscription_id']) && isset($data['recurring'])) {
1803
  $pluginRoot = WP_PLUGIN_DIR . '/razorpay-subscriptions-for-woocommerce';