Razorpay for WooCommerce - Version 2.7.1

Version Description

  • Updated the Razorpay Order notes key from woocommerce_order_id to woocommerce_order_number.
Download this release

Release Info

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

Code changes from version 2.7.0 to 2.7.1

Files changed (2) hide show
  1. readme.txt +4 -1
  2. woo-razorpay.php +35 -11
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.7.2
6
- Stable tag: 2.7.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,9 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
41
 
42
  == Changelog ==
43
 
 
 
 
44
  = 2.7.0 =
45
  * Added auto-webhook setup feature.
46
  * Updates Razorpay SDK.
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
  Tested up to: 5.7.2
6
+ Stable tag: 2.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
 
42
  == Changelog ==
43
 
44
+ = 2.7.1 =
45
+ * Updated the Razorpay Order notes key from woocommerce_order_id to woocommerce_order_number.
46
+
47
  = 2.7.0 =
48
  * Added auto-webhook setup feature.
49
  * Updates Razorpay SDK.
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: 2.7.0
7
- * Stable tag: 2.7.0
8
  * Author: Team Razorpay
9
  * WC tested up to: 5.3.0
10
  * Author URI: https://razorpay.com
@@ -45,6 +45,7 @@ function woocommerce_razorpay_init()
45
  const CAPTURE = 'capture';
46
  const AUTHORIZE = 'authorize';
47
  const WC_ORDER_ID = 'woocommerce_order_id';
 
48
 
49
  const DEFAULT_LABEL = 'Credit Card/Debit Card/NetBanking';
50
  const DEFAULT_DESCRIPTION = 'Pay securely by Credit or Debit card or Internet Banking through Razorpay.';
@@ -268,8 +269,23 @@ function woocommerce_razorpay_init()
268
  $webhookExist = false;
269
  $webhookUrl = esc_url(admin_url('admin-post.php')) . '?action=rzp_wc_webhook';
270
 
271
- $enabled = $this->getSetting('enable_webhook');
272
- $secret = $this->getSetting('webhook_secret');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
  $eventsSubscribe = $this->getSetting('webhook_events');
275
 
@@ -285,7 +301,7 @@ function woocommerce_razorpay_init()
285
 
286
  if(in_array($_SERVER['SERVER_ADDR'], ["127.0.0.1","::1"]))
287
  {
288
- error_log(json_encode('Could not enable webhook for localhost'));
289
  return;
290
  }
291
 
@@ -298,22 +314,30 @@ function woocommerce_razorpay_init()
298
  }
299
  else
300
  {
301
- if (empty($eventsSubscribe) === true)
 
302
  {
303
  ?>
304
  <div class="notice error is-dismissible" >
305
- <p><b><?php _e( 'Please select the atlease one webhook event to enable webhook.' ); ?><b></p>
306
  </div>
307
  <?php
 
 
 
308
  }
309
 
310
- if (empty($secret) === true)
 
311
  {
312
  ?>
313
  <div class="notice error is-dismissible" >
314
- <p><b><?php _e( 'Please enter the webhook secret.' ); ?><b></p>
315
  </div>
316
  <?php
 
 
 
317
  }
318
 
319
  $data = [
@@ -549,7 +573,7 @@ function woocommerce_razorpay_init()
549
  'currency' => self::INR,
550
  'description' => $productinfo,
551
  'notes' => array(
552
- 'woocommerce_order_id' => $orderId
553
  ),
554
  'order_id' => $razorpayOrderId,
555
  'callback_url' => $callbackUrl,
@@ -693,7 +717,7 @@ function woocommerce_razorpay_init()
693
  'payment_capture' => ($this->getSetting('payment_action') === self::AUTHORIZE) ? 0 : 1,
694
  'app_offer' => ($order->get_discount_total() > 0) ? 1 : 0,
695
  'notes' => array(
696
- self::WC_ORDER_ID => (string) $orderId,
697
  ),
698
  );
699
 
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
+ * Version: 2.7.1
7
+ * Stable tag: 2.7.1
8
  * Author: Team Razorpay
9
  * WC tested up to: 5.3.0
10
  * Author URI: https://razorpay.com
45
  const CAPTURE = 'capture';
46
  const AUTHORIZE = 'authorize';
47
  const WC_ORDER_ID = 'woocommerce_order_id';
48
+ const WC_ORDER_NUMBER = 'woocommerce_order_number';
49
 
50
  const DEFAULT_LABEL = 'Credit Card/Debit Card/NetBanking';
51
  const DEFAULT_DESCRIPTION = 'Pay securely by Credit or Debit card or Internet Banking through Razorpay.';
269
  $webhookExist = false;
270
  $webhookUrl = esc_url(admin_url('admin-post.php')) . '?action=rzp_wc_webhook';
271
 
272
+ $key_id = $this->getSetting('key_id');
273
+ $key_secret = $this->getSetting('key_secret');
274
+ $enabled = $this->getSetting('enable_webhook');
275
+ $secret = $this->getSetting('webhook_secret');
276
+
277
+ //validating the key id and key secret set properly or not.
278
+ if($key_id == null || $key_secret == null)
279
+ {
280
+ ?>
281
+ <div class="notice error is-dismissible" >
282
+ <p><b><?php _e( 'Key Id and Key Secret can`t be empty'); ?><b></p>
283
+ </div>
284
+ <?php
285
+
286
+ error_log('Key Id and Key Secret are required to enable the webhook.');
287
+ return;
288
+ }
289
 
290
  $eventsSubscribe = $this->getSetting('webhook_events');
291
 
301
 
302
  if(in_array($_SERVER['SERVER_ADDR'], ["127.0.0.1","::1"]))
303
  {
304
+ error_log('Could not enable webhook for localhost');
305
  return;
306
  }
307
 
314
  }
315
  else
316
  {
317
+ //validating event is not empty
318
+ if(empty($eventsSubscribe) === true)
319
  {
320
  ?>
321
  <div class="notice error is-dismissible" >
322
+ <p><b><?php _e( 'At least one webhook event needs to be subscribed to enable webhook.'); ?><b></p>
323
  </div>
324
  <?php
325
+
326
+ error_log('At least one webhook event needs to be subscribed to enable webhook.');
327
+ return;
328
  }
329
 
330
+ //validating webhook secret is not empty
331
+ if(empty($secret) === true)
332
  {
333
  ?>
334
  <div class="notice error is-dismissible" >
335
+ <p><b><?php _e( 'Webhook secret field can`t be empty.' ); ?><b></p>
336
  </div>
337
  <?php
338
+
339
+ error_log('Webhook secret field can`t be empty.');
340
+ return;
341
  }
342
 
343
  $data = [
573
  'currency' => self::INR,
574
  'description' => $productinfo,
575
  'notes' => array(
576
+ self::WC_ORDER_ID => $orderId
577
  ),
578
  'order_id' => $razorpayOrderId,
579
  'callback_url' => $callbackUrl,
717
  'payment_capture' => ($this->getSetting('payment_action') === self::AUTHORIZE) ? 0 : 1,
718
  'app_offer' => ($order->get_discount_total() > 0) ? 1 : 0,
719
  'notes' => array(
720
+ self::WC_ORDER_NUMBER => (string) $orderId,
721
  ),
722
  );
723