Razorpay for WooCommerce - Version 3.8.0

Version Description

  • Added support for Pixel your site pro plugin in magic checkout.
  • Bug fix to handle the transient data.
Download this release

Release Info

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

Code changes from version 3.7.2 to 3.8.0

Files changed (4) hide show
  1. btn-1cc-checkout.js +19 -0
  2. includes/api/order.php +27 -2
  3. readme.txt +5 -1
  4. woo-razorpay.php +31 -5
btn-1cc-checkout.js CHANGED
@@ -156,6 +156,23 @@ window.addEventListener('DOMContentLoaded', function() {
156
  rzp1cc.setDisabled('btn-1cc', false);
157
  rzp1cc.setDisabled('btn-1cc-mini-cart', false);
158
  rzp1cc.setDisabled('btn-1cc-pdp', false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  }
160
  }
161
 
@@ -179,6 +196,8 @@ window.addEventListener('DOMContentLoaded', function() {
179
  {
180
  rzp1ccCheckoutData.token = accessToken;
181
  }
 
 
182
 
183
  var body = rzp1ccCheckoutData;
184
 
156
  rzp1cc.setDisabled('btn-1cc', false);
157
  rzp1cc.setDisabled('btn-1cc-mini-cart', false);
158
  rzp1cc.setDisabled('btn-1cc-pdp', false);
159
+ },
160
+ getBrowserTime: function() {
161
+ var dateTime = [];
162
+ var date = new Date(),
163
+ days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
164
+ months = ['January', 'February', 'March', 'April', 'May', 'June',
165
+ 'July', 'August', 'September', 'October', 'November', 'December'
166
+ ],
167
+ hours = ['00-01', '01-02', '02-03', '03-04', '04-05', '05-06', '06-07', '07-08',
168
+ '08-09', '09-10', '10-11', '11-12', '12-13', '13-14', '14-15', '15-16', '16-17',
169
+ '17-18', '18-19', '19-20', '20-21', '21-22', '22-23', '23-24'
170
+ ];
171
+ dateTime.push(hours[date.getHours()]);
172
+ dateTime.push(days[date.getDay()]);
173
+ dateTime.push(months[date.getMonth()]);
174
+
175
+ rzp1ccCheckoutData.dateTime = dateTime;
176
  }
177
  }
178
 
196
  {
197
  rzp1ccCheckoutData.token = accessToken;
198
  }
199
+
200
+ rzp1cc.getBrowserTime();
201
 
202
  var body = rzp1ccCheckoutData;
203
 
includes/api/order.php CHANGED
@@ -115,8 +115,8 @@ function createWcOrder(WP_REST_Request $request)
115
  $orderId = $woocommerce->session->get(RZP_1CC_CART_HASH . $cartHash);
116
 
117
  //To get the applied coupon details from cart object.
118
- $coupons = WC()->cart->get_coupons();
119
- $couponCode = !empty($coupons)? array_key_first($coupons): null;
120
  }
121
  }
122
 
@@ -124,6 +124,17 @@ function createWcOrder(WP_REST_Request $request)
124
 
125
  if ($order) {
126
 
 
 
 
 
 
 
 
 
 
 
 
127
  // To remove coupon added on order.
128
  $coupons = $order->get_coupon_codes();
129
  if (!empty($coupons)) {
@@ -256,3 +267,17 @@ function updateOrderStatus($orderId, $orderStatus)
256
  'post_status' => $orderStatus,
257
  ));
258
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  $orderId = $woocommerce->session->get(RZP_1CC_CART_HASH . $cartHash);
116
 
117
  //To get the applied coupon details from cart object.
118
+ $coupons = WC()->cart->get_coupons();
119
+ $couponCode = !empty($coupons) ? array_key_first($coupons) : null;
120
  }
121
  }
122
 
124
 
125
  if ($order) {
126
 
127
+ // Pixel your site PRO UTM data
128
+ if (is_plugin_active('pixelyoursite-pro/pixelyoursite-pro.php')) {
129
+
130
+ $pysData = get_option('pys_core');
131
+
132
+ // Store UTM data only if config enabled.
133
+ if ($pysData['woo_enabled_save_data_to_orders'] == true) {
134
+ wooSaveCheckoutUTMFields($orderId, $params);
135
+ }
136
+ }
137
+
138
  // To remove coupon added on order.
139
  $coupons = $order->get_coupon_codes();
140
  if (!empty($coupons)) {
267
  'post_status' => $orderStatus,
268
  ));
269
  }
270
+
271
+ function wooSaveCheckoutUTMFields($orderId, $params)
272
+ {
273
+ $pysData = [];
274
+ $cookieData = $params['cookies'];
275
+ $browserTime = $params['dateTime'];
276
+ $pysData['pys_landing'] = isset($cookieData['pys_landing_page']) ? ($cookieData['pys_landing_page']) : "";
277
+ $pysData['pys_source'] = isset($cookieData['pysTrafficSource']) ? ($cookieData['pysTrafficSource']) : "direct";
278
+
279
+ $pysData['pys_utm'] = "utm_source:" . $cookieData['pys_utm_source'] . "|utm_medium:" . $cookieData['pys_utm_medium'] . "|utm_campaign:" . $cookieData['pys_utm_campaign'] . "|utm_term:" . $cookieData['pys_utm_term'] . "|utm_content:" . $cookieData['pys_utm_content'];
280
+ $pysData['pys_browser_time'] = $browserTime[0] . "|" . $browserTime[1] . "|" . $browserTime[2];
281
+
282
+ update_post_meta($orderId, "pys_enrich_data", $pysData);
283
+ }
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.2
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.7.2 =
45
  * Bug fix for webhook.
46
 
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
 
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.
47
+
48
  = 3.7.2 =
49
  * Bug fix for webhook.
50
 
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.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
@@ -759,7 +759,10 @@ function woocommerce_razorpay_init()
759
 
760
  $razorpayOrderId = $razorpayOrder['id'];
761
 
762
- set_transient($sessionKey, $razorpayOrderId, 3600);
 
 
 
763
  $woocommerce->session->set($sessionKey, $razorpayOrderId);
764
 
765
  rzpLogInfo('For order session key ' . $sessionKey);
@@ -1181,7 +1184,17 @@ EOT;
1181
  {
1182
  $api = $this->getRazorpayApiInstance();
1183
  $sessionKey = $this->getOrderSessionKey($orderId);
1184
- $razorpayOrderId = get_transient($sessionKey);
 
 
 
 
 
 
 
 
 
 
1185
  $razorpayData = $api->order->fetch($razorpayOrderId);
1186
 
1187
  $this->updateOrderAddress($razorpayData, $order);
@@ -1382,6 +1395,8 @@ EOT;
1382
 
1383
  public function update1ccOrderWC(& $order, $wcOrderId, $razorpayPaymentId)
1384
  {
 
 
1385
  $logObj = array();
1386
  rzpLogInfo("update1ccOrderWC wcOrderId: $wcOrderId, razorpayPaymentId: $razorpayPaymentId");
1387
 
@@ -1390,7 +1405,17 @@ EOT;
1390
 
1391
  $api = $this->getRazorpayApiInstance();
1392
  $sessionKey = $this->getOrderSessionKey($wcOrderId);
1393
- $razorpayOrderId = get_transient($sessionKey);
 
 
 
 
 
 
 
 
 
 
1394
  $razorpayData = $api->order->fetch($razorpayOrderId);
1395
 
1396
  $this->updateOrderAddress($razorpayData, $order);
@@ -1877,6 +1902,7 @@ function enqueueScriptsFor1cc()
1877
  'nonce' => wp_create_nonce("wp_rest"),
1878
  'siteurl' => $siteurl,
1879
  'blogname' => get_bloginfo('name'),
 
1880
  ) );
1881
  wp_enqueue_script('btn_1cc_checkout');
1882
  }
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
759
 
760
  $razorpayOrderId = $razorpayOrder['id'];
761
 
762
+ // Storing the razorpay order id in transient for 5 hours time.
763
+ set_transient($sessionKey, $razorpayOrderId, 18000);
764
+
765
+ // By default woocommerce session TTL is 48 hours.
766
  $woocommerce->session->set($sessionKey, $razorpayOrderId);
767
 
768
  rzpLogInfo('For order session key ' . $sessionKey);
1184
  {
1185
  $api = $this->getRazorpayApiInstance();
1186
  $sessionKey = $this->getOrderSessionKey($orderId);
1187
+
1188
+ //Check the transient data for razorpay order id, if it's not available then look into session data.
1189
+ if(get_transient($sessionKey))
1190
+ {
1191
+ $razorpayOrderId = get_transient($sessionKey);
1192
+ }
1193
+ else
1194
+ {
1195
+ $razorpayOrderId = $woocommerce->session->get($sessionKey);
1196
+ }
1197
+
1198
  $razorpayData = $api->order->fetch($razorpayOrderId);
1199
 
1200
  $this->updateOrderAddress($razorpayData, $order);
1395
 
1396
  public function update1ccOrderWC(& $order, $wcOrderId, $razorpayPaymentId)
1397
  {
1398
+ global $woocommerce;
1399
+
1400
  $logObj = array();
1401
  rzpLogInfo("update1ccOrderWC wcOrderId: $wcOrderId, razorpayPaymentId: $razorpayPaymentId");
1402
 
1405
 
1406
  $api = $this->getRazorpayApiInstance();
1407
  $sessionKey = $this->getOrderSessionKey($wcOrderId);
1408
+
1409
+ //Check the transient data for razorpay order id, if it's not available then look into session data.
1410
+ if(get_transient($sessionKey))
1411
+ {
1412
+ $razorpayOrderId = get_transient($sessionKey);
1413
+ }
1414
+ else
1415
+ {
1416
+ $razorpayOrderId = $woocommerce->session->get($sessionKey);
1417
+ }
1418
+
1419
  $razorpayData = $api->order->fetch($razorpayOrderId);
1420
 
1421
  $this->updateOrderAddress($razorpayData, $order);
1902
  'nonce' => wp_create_nonce("wp_rest"),
1903
  'siteurl' => $siteurl,
1904
  'blogname' => get_bloginfo('name'),
1905
+ 'cookies' => $_COOKIE,
1906
  ) );
1907
  wp_enqueue_script('btn_1cc_checkout');
1908
  }