Razorpay for WooCommerce - Version 2.0.1

Version Description

= 2.0.0 = * Switches from WooCommerce side currency conversion to Razorpay's native multi currency support.

Download this release

Release Info

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

Code changes from version 1.6.5 to 2.0.1

includes/razorpay-webhook.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- require_once __DIR__.'/../razorpay-payments.php';
4
  require_once __DIR__.'/../razorpay-sdk/Razorpay.php';
5
 
6
  use Razorpay\Api\Api;
1
  <?php
2
 
3
+ require_once __DIR__.'/../woo-razorpay.php';
4
  require_once __DIR__.'/../razorpay-sdk/Razorpay.php';
5
 
6
  use Razorpay\Api\Api;
readme.txt CHANGED
@@ -2,8 +2,9 @@
2
  Contributors: razorpay
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
- Tested up to: 4.8
6
- Stable tag: 1.6.5
 
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -25,7 +26,7 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
25
  1. Wordpress v3.9.2 and later
26
  2. Woocommerce v2.4 and later
27
  3. PHP v5.6.0 and later
28
- 4. php-curl
29
 
30
  == Configuration ==
31
 
@@ -34,8 +35,18 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
34
  3. Enable the Payment Method, name it Credit Card / Debit Card / Internet Banking (this will show up on the payment page your customer sees), add in your Key id and Key Secret.
35
  4. The Payment Action should be set to "Authorize and Capture". If you want to capture payments manually from the Dashboard after manual verification, set it to "Authorize".
36
 
 
 
 
 
37
  == Changelog ==
38
 
 
 
 
 
 
 
39
  = 1.6.3 =
40
  * Allows for null values in displayAmount
41
  * Better support for international currency conversion
@@ -123,6 +134,17 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
123
  = 1.2.6 =
124
  * Adds manual capture option
125
 
 
 
 
 
 
 
 
 
 
 
 
126
  == Support ==
127
 
128
  Visit [razorpay.com](https://razorpay.com) for support requests or email us at <integrations@razorpay.com>.
2
  Contributors: razorpay
3
  Tags: razorpay, payments, india, woocommerce, ecommerce
4
  Requires at least: 3.9.2
5
+ Tested up to: 5.2-RC1-45273
6
+ Stable tag: 2.0.1
7
+ Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
26
  1. Wordpress v3.9.2 and later
27
  2. Woocommerce v2.4 and later
28
  3. PHP v5.6.0 and later
29
+ 4. php-curl extension
30
 
31
  == Configuration ==
32
 
35
  3. Enable the Payment Method, name it Credit Card / Debit Card / Internet Banking (this will show up on the payment page your customer sees), add in your Key id and Key Secret.
36
  4. The Payment Action should be set to "Authorize and Capture". If you want to capture payments manually from the Dashboard after manual verification, set it to "Authorize".
37
 
38
+ == Upgrade Notice ==
39
+ = 2.0.0 =
40
+ * Switches from WooCommerce side currency conversion to Razorpay's native multi currency support.
41
+
42
  == Changelog ==
43
 
44
+ = 2.0.0 =
45
+ * Removes support for WooCommerce Currency Convertor
46
+ * Switches to Razorpay's Native Multi-Currency support
47
+ * Adds support for [Price Based on Country Plugin](https://www.pricebasedcountry.com/)
48
+ * Tested upto WordPress 5.2-RC1 and WooCommerce 3.6.2
49
+
50
  = 1.6.3 =
51
  * Allows for null values in displayAmount
52
  * Better support for international currency conversion
134
  = 1.2.6 =
135
  * Adds manual capture option
136
 
137
+ == Frequently Asked Questions ==
138
+
139
+ = Does this support webhooks? =
140
+
141
+ Yes, please see https://github.com/razorpay/razorpay-woocommerce/wiki/Webhooks for more details
142
+
143
+ = How do I enable Multi-currency support =
144
+
145
+ Please get multi-currency enabled for your account. Once you have it enabled, you can install any plugin
146
+ version higher than 2.0.0, which comes with native multi-currency support.
147
+
148
  == Support ==
149
 
150
  Visit [razorpay.com](https://razorpay.com) for support requests or email us at <integrations@razorpay.com>.
razorpay-payments.php → woo-razorpay.php RENAMED
@@ -3,10 +3,10 @@
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
- * Version: 1.6.5
7
- * Stable tag: 1.6.5
8
  * Author: Team Razorpay
9
- * WC tested up to: 3.2.1
10
  * Author URI: https://razorpay.com
11
  */
12
 
@@ -16,12 +16,10 @@ if ( ! defined( 'ABSPATH' ) )
16
  }
17
 
18
  require_once __DIR__.'/includes/razorpay-webhook.php';
19
- require_once __DIR__.'/includes/Errors/ErrorCode.php';
20
  require_once __DIR__.'/razorpay-sdk/Razorpay.php';
21
 
22
  use Razorpay\Api\Api;
23
  use Razorpay\Api\Errors;
24
- use Razorpay\Woocommerce\Errors as WooErrors;
25
 
26
  add_action('plugins_loaded', 'woocommerce_razorpay_init', 0);
27
  add_action('admin_post_nopriv_rzp_wc_webhook', 'razorpay_webhook_init', 10);
@@ -48,7 +46,7 @@ function woocommerce_razorpay_init()
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.';
51
- const DEFAULT_SUCCESS_MESSAGE = 'Thank you for shopping with us. Your account has been charged and your transaction is successful. We will be processing your order soon.';
52
 
53
  protected $visibleSettings = array(
54
  'enabled',
@@ -88,6 +86,13 @@ function woocommerce_razorpay_init()
88
  */
89
  public $method_title = 'Razorpay';
90
 
 
 
 
 
 
 
 
91
  /**
92
  * Icon URL, set in constructor
93
  * @var string
@@ -433,16 +438,6 @@ function woocommerce_razorpay_init()
433
  return $order->get_order_currency();
434
  }
435
 
436
- /**
437
- * Returns display amount to use for non-INR payments
438
- * @param WC_Order $order WC Order
439
- * @return int order total to be displayed
440
- */
441
- protected function getDisplayAmount($order)
442
- {
443
- return (int) round($order->get_total());
444
- }
445
-
446
  /**
447
  * Returns array of checkout params
448
  */
@@ -452,18 +447,7 @@ function woocommerce_razorpay_init()
452
 
453
  $currency = $this->getOrderCurrency($order);
454
 
455
- if ($currency !== self::INR)
456
- {
457
- // A null is passed if displayAmount is to remain unset
458
- $displayAmount = $this->getDisplayAmount($order);
459
-
460
- if ($displayAmount)
461
- {
462
- $args['display_currency'] = $currency;
463
- $args['display_amount'] = $displayAmount;
464
- }
465
-
466
- }
467
 
468
  $args = array_merge($args, $params);
469
 
@@ -519,47 +503,6 @@ function woocommerce_razorpay_init()
519
  return $razorpayOrderId;
520
  }
521
 
522
- /**
523
- * Convert the currency to INR using rates fetched from Woocommerce Currency Switcher plugin
524
- *
525
- * @param array $data Input array to convert currency
526
- * @param string $data['currency'] Currency
527
- * @param amount $data['amount'] Input Amount
528
- * @return array, modified $data with $data['currency'] = 'INR'
529
- *
530
- **/
531
- protected function convertCurrency(& $data)
532
- {
533
- global $WOOCS;
534
-
535
- $currencies = $WOOCS->get_currencies();
536
-
537
- $currency = $data['currency'];
538
-
539
- if (array_key_exists(self::INR, $currencies) and array_key_exists($currency, $currencies))
540
- {
541
- // If the currenct currency is the same as the default currency set in WooCommerce,
542
- // Currency Switcher plugin sets the rate of currenct currency as 0, because of which
543
- // we need to set this to 1 here if it's value is 0
544
- $currencyConversionRate = ($currencies[$currency]['rate'] == 0 ? 1 : $currencies[$currency]['rate']);
545
-
546
- // Convert the currency to INR using the rates fetched from the Currency Switcher plugin
547
- $value = $data['amount'] * $currencies[self::INR]['rate'];
548
-
549
- $data['amount'] = intval(round($value / $currencyConversionRate));
550
- $data['currency'] = self::INR;
551
- }
552
- else
553
- {
554
- throw new Errors\BadRequestError(
555
- WooErrors\ErrorCode::WOOCS_CURRENCY_MISSING_ERROR_MESSAGE,
556
- WooErrors\ErrorCode::WOOCS_CURRENCY_MISSING_ERROR_CODE,
557
- 400
558
- );
559
-
560
- }
561
- }
562
-
563
  protected function verifyOrderAmount($razorpayOrderId, $orderId)
564
  {
565
  $order = new WC_Order($orderId);
@@ -605,34 +548,16 @@ function woocommerce_razorpay_init()
605
  $data = array(
606
  'receipt' => $orderId,
607
  'amount' => (int) round($order->get_total() * 100),
608
- 'currency' => get_woocommerce_currency(),
609
  'payment_capture' => ($this->getSetting('payment_action') === self::AUTHORIZE) ? 0 : 1,
610
  'notes' => array(
611
  self::WC_ORDER_ID => (string) $orderId,
612
  ),
613
  );
614
 
615
- if ($data['currency'] !== self::INR)
616
- {
617
- $this->handleCurrencyConversion($data);
618
- }
619
-
620
  return $data;
621
  }
622
 
623
- public function handleCurrencyConversion(& $data)
624
- {
625
- if (class_exists('WOOCS') === false)
626
- {
627
- throw new Errors\BadRequestError(
628
- WooErrors\ErrorCode::WOOCS_MISSING_ERROR_MESSAGE,
629
- WooErrors\ErrorCode::WOOCS_MISSING_ERROR_CODE,
630
- 400
631
- );
632
- }
633
-
634
- $this->convertCurrency($data);
635
- }
636
 
637
  private function enqueueCheckoutScripts($data)
638
  {
@@ -892,7 +817,6 @@ EOT;
892
 
893
  $order->payment_complete($razorpayPaymentId);
894
  $order->add_order_note("Razorpay payment successful <br/>Razorpay Id: $razorpayPaymentId");
895
- $order->add_order_note($this->msg['message']);
896
 
897
  if (isset($woocommerce->cart) === true)
898
  {
3
  * Plugin Name: Razorpay for WooCommerce
4
  * Plugin URI: https://razorpay.com
5
  * Description: Razorpay Payment Gateway Integration for WooCommerce
6
+ * Version: 2.0.1
7
+ * Stable tag: 2.0.1
8
  * Author: Team Razorpay
9
+ * WC tested up to: 3.6.2
10
  * Author URI: https://razorpay.com
11
  */
12
 
16
  }
17
 
18
  require_once __DIR__.'/includes/razorpay-webhook.php';
 
19
  require_once __DIR__.'/razorpay-sdk/Razorpay.php';
20
 
21
  use Razorpay\Api\Api;
22
  use Razorpay\Api\Errors;
 
23
 
24
  add_action('plugins_loaded', 'woocommerce_razorpay_init', 0);
25
  add_action('admin_post_nopriv_rzp_wc_webhook', 'razorpay_webhook_init', 10);
46
 
47
  const DEFAULT_LABEL = 'Credit Card/Debit Card/NetBanking';
48
  const DEFAULT_DESCRIPTION = 'Pay securely by Credit or Debit card or Internet Banking through Razorpay.';
49
+ const DEFAULT_SUCCESS_MESSAGE = 'Thank you for shopping with us. Your account has been charged and your transaction is successful. We will be processing your order soon.';
50
 
51
  protected $visibleSettings = array(
52
  'enabled',
86
  */
87
  public $method_title = 'Razorpay';
88
 
89
+
90
+ /**
91
+ * Description of the payment method shown on the admin page.
92
+ * @var string
93
+ */
94
+ public $method_description = 'Allow customers to securely pay via Razorpay (Credit/Debit Cards, NetBanking, UPI, Wallets)';
95
+
96
  /**
97
  * Icon URL, set in constructor
98
  * @var string
438
  return $order->get_order_currency();
439
  }
440
 
 
 
 
 
 
 
 
 
 
 
441
  /**
442
  * Returns array of checkout params
443
  */
447
 
448
  $currency = $this->getOrderCurrency($order);
449
 
450
+ // The list of valid currencies is at https://razorpay.freshdesk.com/support/solutions/articles/11000065530-what-currencies-does-razorpay-support-
 
 
 
 
 
 
 
 
 
 
 
451
 
452
  $args = array_merge($args, $params);
453
 
503
  return $razorpayOrderId;
504
  }
505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  protected function verifyOrderAmount($razorpayOrderId, $orderId)
507
  {
508
  $order = new WC_Order($orderId);
548
  $data = array(
549
  'receipt' => $orderId,
550
  'amount' => (int) round($order->get_total() * 100),
551
+ 'currency' => $this->getOrderCurrency($order),
552
  'payment_capture' => ($this->getSetting('payment_action') === self::AUTHORIZE) ? 0 : 1,
553
  'notes' => array(
554
  self::WC_ORDER_ID => (string) $orderId,
555
  ),
556
  );
557
 
 
 
 
 
 
558
  return $data;
559
  }
560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
561
 
562
  private function enqueueCheckoutScripts($data)
563
  {
817
 
818
  $order->payment_complete($razorpayPaymentId);
819
  $order->add_order_note("Razorpay payment successful <br/>Razorpay Id: $razorpayPaymentId");
 
820
 
821
  if (isset($woocommerce->cart) === true)
822
  {