Razorpay for WooCommerce - Version 4.3.4

Version Description

  • Fixed, Api calls for affordability widget being made from product page.
  • Removed, checkbox to enable affordability widget.
Download this release

Release Info

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

Code changes from version 4.3.3 to 4.3.4

includes/razorpay-affordability-widget.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  function addAffordabilityWidgetHTML()
4
  {
5
  $current_user = wp_get_current_user();
@@ -360,7 +362,7 @@ function getAffordabilityWidgetSettings()
360
  ),
361
  'enable' => array(
362
  'title' => __('Affordability Widget Enable/Disable'),
363
- 'type' => 'checkbox',
364
  'desc' => __('Enable Affordability Widget?'),
365
  'default' => 'no',
366
  'id' => 'rzp_afd_enable'
@@ -516,6 +518,44 @@ function displayAffordabilityWidgetSettings()
516
  function updateAffordabilityWidgetSettings()
517
  {
518
  woocommerce_update_options(getAffordabilityWidgetSettings());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  }
520
 
521
  function isEnabled($feature)
1
  <?php
2
 
3
+ use Razorpay\Api\Api;
4
+
5
  function addAffordabilityWidgetHTML()
6
  {
7
  $current_user = wp_get_current_user();
362
  ),
363
  'enable' => array(
364
  'title' => __('Affordability Widget Enable/Disable'),
365
+ 'type' => 'hidden',
366
  'desc' => __('Enable Affordability Widget?'),
367
  'default' => 'no',
368
  'id' => 'rzp_afd_enable'
518
  function updateAffordabilityWidgetSettings()
519
  {
520
  woocommerce_update_options(getAffordabilityWidgetSettings());
521
+ try
522
+ {
523
+ if (isset($_POST['woocommerce_razorpay_key_id']) and
524
+ empty($_POST['woocommerce_razorpay_key_id']) === false and
525
+ isset($_POST['woocommerce_razorpay_key_secret']) and
526
+ empty($_POST['woocommerce_razorpay_key_secret']) === false)
527
+ {
528
+ $api = new Api($_POST['woocommerce_razorpay_key_id'], $_POST['woocommerce_razorpay_key_secret']);
529
+ }
530
+ else
531
+ {
532
+ $api = new Api(get_option('woocommerce_razorpay_settings')['key_id'],get_option('woocommerce_razorpay_settings')['key_secret']);
533
+ }
534
+
535
+ $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
536
+
537
+ if (isset($merchantPreferences) === false or
538
+ isset($merchantPreferences['assigned_features']) === false)
539
+ {
540
+ throw new Exception("Error in Api call.");
541
+ }
542
+
543
+ update_option('rzp_afd_enable', 'no');
544
+ foreach ($merchantPreferences['assigned_features'] as $preference)
545
+ {
546
+ if ($preference['name'] === 'affordability_widget')
547
+ {
548
+ update_option('rzp_afd_enable', 'yes');
549
+ break;
550
+ }
551
+ }
552
+
553
+ }
554
+ catch (\Exception $e)
555
+ {
556
+ rzpLogError($e->getMessage());
557
+ return;
558
+ }
559
  }
560
 
561
  function isEnabled($feature)
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: 6.0.1
6
- Stable tag: 4.3.3
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
  = 4.3.3 =
45
  * Added, checkbox to enable affordability widget.
46
  * Fixed, Api call being made from all pages for features.
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 6.0.1
6
+ Stable tag: 4.3.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
+ = 4.3.4 =
45
+ * Fixed, Api calls for affordability widget being made from product page.
46
+ * Removed, checkbox to enable affordability widget.
47
+
48
  = 4.3.3 =
49
  * Added, checkbox to enable affordability widget.
50
  * Fixed, Api call being made from all pages for features.
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: 4.3.3
7
- * Stable tag: 4.3.3
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.7.0
10
  * Author URI: https://razorpay.com
@@ -328,9 +328,7 @@ function woocommerce_razorpay_init()
328
  }
329
 
330
  //Affordability Widget Code
331
- global $current_section;
332
- if ($current_section === 'razorpay' or
333
- $current_section === 'affordability-widget')
334
  {
335
  try
336
  {
@@ -347,13 +345,13 @@ function woocommerce_razorpay_init()
347
  }
348
 
349
  $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
350
-
351
  if (isset($merchantPreferences) === false or
352
  isset($merchantPreferences['assigned_features']) === false)
353
  {
354
  throw new Exception("Error in Api call.");
355
  }
356
-
 
357
  foreach ($merchantPreferences['assigned_features'] as $preference)
358
  {
359
  if ($preference['name'] === 'affordability_widget')
@@ -361,8 +359,12 @@ function woocommerce_razorpay_init()
361
  add_action('woocommerce_sections_checkout', 'addSubSection');
362
  add_action('woocommerce_settings_tabs_checkout', 'displayAffordabilityWidgetSettings');
363
  add_action('woocommerce_update_options_checkout', 'updateAffordabilityWidgetSettings');
 
 
364
  }
365
  }
 
 
366
  }
367
  catch (\Exception $e)
368
  {
@@ -2242,29 +2244,42 @@ EOT;
2242
  if (empty(get_option('rzp_afd_enable')) === false and
2243
  get_option('rzp_afd_enable') === 'yes')
2244
  {
2245
- try
 
2246
  {
2247
- $api = new Api(get_option('woocommerce_razorpay_settings')['key_id'], get_option('woocommerce_razorpay_settings')['key_secret']);
2248
- $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
2249
-
2250
- if (isset($merchantPreferences) === false or
2251
- isset($merchantPreferences['assigned_features']) === false)
2252
  {
2253
- throw new Exception("Error in Api call.");
2254
- }
 
 
 
 
 
2255
 
2256
- foreach ($merchantPreferences['assigned_features'] as $preference)
2257
- {
2258
- if ($preference['name'] === 'affordability_widget')
2259
  {
2260
- add_action ('woocommerce_before_add_to_cart_form', 'addAffordabilityWidgetHTML');
 
 
 
 
2261
  }
 
 
 
 
 
 
 
2262
  }
2263
  }
2264
- catch(\Exception $e)
 
 
2265
  {
2266
- rzpLogError($e->getMessage());
2267
- return;
2268
  }
2269
  }
2270
  }
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
+ * Version: 4.3.4
7
+ * Stable tag: 4.3.4
8
  * Author: Team Razorpay
9
  * WC tested up to: 6.7.0
10
  * Author URI: https://razorpay.com
328
  }
329
 
330
  //Affordability Widget Code
331
+ if (is_admin())
 
 
332
  {
333
  try
334
  {
345
  }
346
 
347
  $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
 
348
  if (isset($merchantPreferences) === false or
349
  isset($merchantPreferences['assigned_features']) === false)
350
  {
351
  throw new Exception("Error in Api call.");
352
  }
353
+
354
+ update_option('rzp_afd_enable', 'no');
355
  foreach ($merchantPreferences['assigned_features'] as $preference)
356
  {
357
  if ($preference['name'] === 'affordability_widget')
359
  add_action('woocommerce_sections_checkout', 'addSubSection');
360
  add_action('woocommerce_settings_tabs_checkout', 'displayAffordabilityWidgetSettings');
361
  add_action('woocommerce_update_options_checkout', 'updateAffordabilityWidgetSettings');
362
+ update_option('rzp_afd_enable', 'yes');
363
+ break;
364
  }
365
  }
366
+
367
+ update_option('rzp_afd_feature_checked', 'yes');
368
  }
369
  catch (\Exception $e)
370
  {
2244
  if (empty(get_option('rzp_afd_enable')) === false and
2245
  get_option('rzp_afd_enable') === 'yes')
2246
  {
2247
+ if (empty(get_option('rzp_afd_feature_checked')) === true or
2248
+ get_option('rzp_afd_feature_checked') === 'no')
2249
  {
2250
+ try
 
 
 
 
2251
  {
2252
+ $api = new Api(get_option('woocommerce_razorpay_settings')['key_id'], get_option('woocommerce_razorpay_settings')['key_secret']);
2253
+ $merchantPreferences = $api->request->request('GET', 'accounts/me/features');
2254
+ if (isset($merchantPreferences) === false or
2255
+ isset($merchantPreferences['assigned_features']) === false)
2256
+ {
2257
+ throw new Exception("Error in Api call.");
2258
+ }
2259
 
2260
+ update_option('rzp_afd_enable', 'no');
2261
+ foreach ($merchantPreferences['assigned_features'] as $preference)
 
2262
  {
2263
+ if ($preference['name'] === 'affordability_widget')
2264
+ {
2265
+ update_option('rzp_afd_enable', 'yes');
2266
+ break;
2267
+ }
2268
  }
2269
+
2270
+ update_option('rzp_afd_feature_checked', 'yes');
2271
+ }
2272
+ catch(\Exception $e)
2273
+ {
2274
+ rzpLogError($e->getMessage());
2275
+ return;
2276
  }
2277
  }
2278
+
2279
+ if (empty(get_option('rzp_afd_enable')) === false and
2280
+ get_option('rzp_afd_enable') === 'yes')
2281
  {
2282
+ add_action ('woocommerce_before_add_to_cart_form', 'addAffordabilityWidgetHTML');
 
2283
  }
2284
  }
2285
  }