Payment Plugins for Stripe WooCommerce - Version 3.2.11

Version Description

  • Added - WC tested up to: 4.9.0
  • Added - Compatibility for Cartflows redirect to global checkout when local payment method used.
  • Added - Refund webhook: if refunded total equals order total, re-stock product(s)
  • Fixed - Apple Pay and Payment Request button disabled on product page when variable product has multiple variations
  • Fixed - 3DS issue on order pay page if credit card gateway not pre-selected
  • Fixed - Setup intent not created if 100% coupon entered on checkout page for subscription
  • Updated - If any required fields missing on product or cart page checkout, redirect to checkout page where customer can enter required fields then click Place Order
Download this release

Release Info

Developer mr.clayton
Plugin Icon wp plugin Payment Plugins for Stripe WooCommerce
Version 3.2.11
Comparing to
See all releases

Code changes from version 3.2.10 to 3.2.11

assets/js/frontend/applepay-product.js CHANGED
@@ -64,16 +64,18 @@
64
  this.disable_payment_button();
65
  this.old_qty = this.get_quantity();
66
  var variation = this.get_product_data().variation;
67
- this.cart_calculation(variation.variation_id).then(function () {
68
- if (this.is_variable_product()) {
69
- this.createPaymentRequest();
70
- wc_stripe.ApplePay.prototype.canMakePayment.apply(this, arguments).then(function () {
 
 
 
 
71
  this.enable_payment_button();
72
- }.bind(this));
73
- } else {
74
- this.enable_payment_button();
75
- }
76
- }.bind(this));
77
  }
78
 
79
  new ApplePay();
64
  this.disable_payment_button();
65
  this.old_qty = this.get_quantity();
66
  var variation = this.get_product_data().variation;
67
+ if (!this.is_variable_product() || this.variable_product_selected()) {
68
+ this.cart_calculation(variation.variation_id).then(function () {
69
+ if (this.is_variable_product()) {
70
+ this.createPaymentRequest();
71
+ wc_stripe.ApplePay.prototype.canMakePayment.apply(this, arguments).then(function () {
72
+ this.enable_payment_button();
73
+ }.bind(this));
74
+ } else {
75
  this.enable_payment_button();
76
+ }
77
+ }.bind(this));
78
+ }
 
 
79
  }
80
 
81
  new ApplePay();
assets/js/frontend/credit-card.js CHANGED
@@ -36,13 +36,7 @@
36
  this.create_card_element();
37
 
38
  if (this.can_create_setup_intent()) {
39
- this.create_setup_intent().then(function (response) {
40
- if (response.code) {
41
- this.submit_error(response.message);
42
- } else {
43
- this.client_secret = response.intent.client_secret;
44
- }
45
- }.bind(this))
46
  }
47
  }
48
 
@@ -251,11 +245,13 @@
251
  beforeSend: this.ajax_before_send.bind(this)
252
  })).done(function (response) {
253
  if (response.code) {
254
- reject(response);
 
255
  } else {
 
256
  resolve(response);
257
  }
258
- }).fail(function (xhr, textStatus, errorThrown) {
259
  this.submit_error(errorThrown);
260
  }.bind(this));
261
  }.bind(this))
@@ -284,6 +280,9 @@
284
  */
285
  CC.prototype.updated_checkout = function () {
286
  this.create_card_element();
 
 
 
287
  }
288
 
289
  /**
36
  this.create_card_element();
37
 
38
  if (this.can_create_setup_intent()) {
39
+ this.create_setup_intent();
 
 
 
 
 
 
40
  }
41
  }
42
 
245
  beforeSend: this.ajax_before_send.bind(this)
246
  })).done(function (response) {
247
  if (response.code) {
248
+ this.submit_error(response.message);
249
+ resolve(response);
250
  } else {
251
+ this.client_secret = response.intent.client_secret;
252
  resolve(response);
253
  }
254
+ }.bind(this)).fail(function (xhr, textStatus, errorThrown) {
255
  this.submit_error(errorThrown);
256
  }.bind(this));
257
  }.bind(this))
280
  */
281
  CC.prototype.updated_checkout = function () {
282
  this.create_card_element();
283
+ if (this.can_create_setup_intent() && !this.client_secret) {
284
+ this.create_setup_intent();
285
+ }
286
  }
287
 
288
  /**
assets/js/frontend/googlepay-product.js CHANGED
@@ -37,7 +37,7 @@
37
  $('#wc-stripe-googlepay-container').append(this.$button);
38
 
39
  // check for variations
40
- if (this.is_variable_product()) {
41
  this.disable_payment_button();
42
  }
43
  }
37
  $('#wc-stripe-googlepay-container').append(this.$button);
38
 
39
  // check for variations
40
+ if (this.is_variable_product() && !this.variable_product_selected()) {
41
  this.disable_payment_button();
42
  }
43
  }
assets/js/frontend/payment-request.js CHANGED
@@ -51,18 +51,20 @@
51
  this.disable_payment_button();
52
  this.old_qty = this.get_quantity();
53
  var variation = this.get_product_data().variation;
54
- this.cart_calculation(variation.variation_id).then(function () {
55
- if (this.is_variable_product() && $(this.container).is('.processingFoundVariation')) {
56
- this.createPaymentRequest();
57
- this.createPaymentRequestButton();
58
- wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function () {
 
 
 
 
 
59
  this.enable_payment_button();
60
- $(this.container).removeClass('processingFoundVariation');
61
- }.bind(this));
62
- } else {
63
- this.enable_payment_button();
64
- }
65
- }.bind(this));
66
  }
67
 
68
  PaymentRequest.prototype.cart_calculation = function () {
51
  this.disable_payment_button();
52
  this.old_qty = this.get_quantity();
53
  var variation = this.get_product_data().variation;
54
+ if (!this.is_variable_product() || this.variable_product_selected()) {
55
+ this.cart_calculation(variation.variation_id).then(function () {
56
+ if (this.is_variable_product() && $(this.container).is('.processingFoundVariation')) {
57
+ this.createPaymentRequest();
58
+ this.createPaymentRequestButton();
59
+ wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function () {
60
+ this.enable_payment_button();
61
+ $(this.container).removeClass('processingFoundVariation');
62
+ }.bind(this));
63
+ } else {
64
  this.enable_payment_button();
65
+ }
66
+ }.bind(this));
67
+ }
 
 
 
68
  }
69
 
70
  PaymentRequest.prototype.cart_calculation = function () {
assets/js/frontend/wc-stripe.js CHANGED
@@ -661,16 +661,20 @@
661
  }.bind(this));
662
  };
663
 
664
- wc_stripe.BaseGateway.prototype.process_payment = function () {
665
  $.ajax({
666
  method: 'POST',
667
  url: this.params.routes.checkout_payment,
668
  dataType: 'json',
669
- data: $.extend({}, this.fields.toJson(), {'_wpnonce': this.params.rest_nonce})
 
670
  }).done(function (result) {
671
  if (result.result && result.result === 'success') {
672
  window.location = result.redirect;
673
  } else {
 
 
 
674
  if (result.messages) {
675
  this.submit_error(result.messages);
676
  } else {
@@ -696,7 +700,7 @@
696
  if (this.is_current_page('order_pay')) {
697
  this.get_form().submit();
698
  } else {
699
- this.process_payment();
700
  }
701
  }.bind(this)).catch(function (error) {
702
  this.submit_error(error.message);
@@ -892,7 +896,7 @@
892
 
893
  this.container_styles();
894
 
895
- this.order_review();
896
  };
897
 
898
  wc_stripe.CheckoutGateway.prototype.container_styles = function () {
@@ -904,34 +908,47 @@
904
  }
905
  }
906
 
907
- wc_stripe.CheckoutGateway.prototype.order_review = function () {
908
- var url = window.location.href;
909
- var matches = url.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);
910
-
911
- if (matches && matches.length > 1) {
912
- var payment_method = matches[1],
913
- nonce = matches[2];
914
 
915
- if (this.gateway_id === payment_method) {
916
- this.payment_token_received = true;
917
- this.set_nonce(nonce);
918
- this.set_use_new_option(true);
 
 
 
 
 
 
919
  }
920
  }
921
  };
922
 
923
  wc_stripe.CheckoutGateway.prototype.has3DSecureParams = function () {
924
- if (this.is_gateway_selected() && (this.is_current_page('order_pay') || this.is_change_payment_method())) {
925
  if (window.location.hash && typeof window.location.hash === 'string') {
926
  var match = window.location.hash.match(/response=(.*)/);
927
- try {
928
- var obj = JSON.parse(window.atob(match[1]));
929
- if (obj && obj.hasOwnProperty('client_secret')) {
930
- $('[name="terms"]').prop('checked', true);
931
- this.handle_card_action(obj);
932
- }
933
- } catch (err) {
 
 
 
 
 
 
 
 
 
 
934
 
 
935
  }
936
  }
937
  }
@@ -1180,6 +1197,10 @@
1180
  return typeof wc_stripe_cart_contains_subscription !== 'undefined' && wc_stripe_cart_contains_subscription === true;
1181
  }
1182
 
 
 
 
 
1183
  /************** Product Gateway ***************/
1184
 
1185
  wc_stripe.ProductGateway = function () {
@@ -1196,29 +1217,14 @@
1196
 
1197
  $(this.container).css('max-width', this.buttonWidth + 'px');
1198
  };
1199
- /**
1200
- * @return {[@int]}
1201
- */
1202
-
1203
 
1204
  wc_stripe.ProductGateway.prototype.get_quantity = function () {
1205
  return parseInt($('[name="quantity"]').val());
1206
  };
1207
- /**
1208
- * @param {[type]}
1209
- * @param {[type]}
1210
- */
1211
-
1212
 
1213
  wc_stripe.ProductGateway.prototype.set_rest_nonce = function (e, nonce) {
1214
  this.params.rest_nonce = nonce;
1215
  };
1216
- /**
1217
- * @param {[type]}
1218
- * @param {[type]}
1219
- * @return {[type]}
1220
- */
1221
-
1222
 
1223
  wc_stripe.ProductGateway.prototype.found_variation = function (e, variation) {
1224
  var data = this.get_gateway_data();
@@ -1227,10 +1233,6 @@
1227
  data.product.variation = variation;
1228
  this.set_gateway_data(data);
1229
  };
1230
- /**
1231
- * @return {[type]}
1232
- */
1233
-
1234
 
1235
  wc_stripe.ProductGateway.prototype.reset_variation_data = function () {
1236
  var data = this.get_product_data();
@@ -1238,38 +1240,22 @@
1238
  this.set_product_data(data);
1239
  this.disable_payment_button();
1240
  };
1241
- /**
1242
- * @return {[type]}
1243
- */
1244
-
1245
 
1246
  wc_stripe.ProductGateway.prototype.disable_payment_button = function () {
1247
  if (this.$button) {
1248
  this.get_button().prop('disabled', true).addClass('disabled');
1249
  }
1250
  };
1251
- /**
1252
- * @return {[type]}
1253
- */
1254
-
1255
 
1256
  wc_stripe.ProductGateway.prototype.enable_payment_button = function () {
1257
  if (this.$button) {
1258
  this.get_button().prop('disabled', false).removeClass('disabled');
1259
  }
1260
  };
1261
- /**
1262
- * @return {[type]}
1263
- */
1264
-
1265
 
1266
  wc_stripe.ProductGateway.prototype.get_button = function () {
1267
  return this.$button;
1268
  };
1269
- /**
1270
- * @return {Boolean}
1271
- */
1272
-
1273
 
1274
  wc_stripe.ProductGateway.prototype.is_variable_product = function () {
1275
  return $('[name="variation_id"]').length > 0;
@@ -1278,28 +1264,16 @@
1278
  wc_stripe.ProductGateway.prototype.variable_product_selected = function () {
1279
  return this.get_product_data().variation !== false;
1280
  };
1281
- /**
1282
- * @return {[type]}
1283
- */
1284
-
1285
 
1286
  wc_stripe.ProductGateway.prototype.get_product_data = function () {
1287
  return this.get_gateway_data().product;
1288
  };
1289
- /**
1290
- * @return {[type]}
1291
- */
1292
-
1293
 
1294
  wc_stripe.ProductGateway.prototype.set_product_data = function (product) {
1295
  var data = this.get_gateway_data();
1296
  data.product = product;
1297
  this.set_gateway_data(data);
1298
  };
1299
- /**
1300
- * Add a product to the WC shopping cart
1301
- */
1302
-
1303
 
1304
  wc_stripe.ProductGateway.prototype.add_to_cart = function () {
1305
  return new Promise(function (resolve, reject) {
@@ -1308,14 +1282,14 @@
1308
  url: this.params.routes.add_to_cart,
1309
  method: 'POST',
1310
  dataType: 'json',
1311
- data: {
1312
  product_id: this.get_product_data().id,
1313
  variation_id: this.is_variable_product() ? $('[name="variation_id"]').val() : 0,
1314
  qty: $('[name="quantity"]').val(),
1315
  payment_method: this.gateway_id,
1316
  currency: this.get_currency(),
1317
  page_id: this.get_page()
1318
- },
1319
  beforeSend: this.ajax_before_send.bind(this)
1320
  }).done(function (response) {
1321
  this.unblock();
@@ -1342,13 +1316,13 @@
1342
  url: this.params.routes.cart_calculation,
1343
  method: 'POST',
1344
  dataType: 'json',
1345
- data: {
1346
  product_id: this.get_product_data().id,
1347
  variation_id: this.is_variable_product() && variation_id ? variation_id : 0,
1348
  qty: $('[name="quantity"]').val(),
1349
  currency: this.get_currency(),
1350
  payment_method: this.gateway_id
1351
- },
1352
  beforeSend: this.ajax_before_send.bind(this)
1353
  }).done(function (response) {
1354
  if (response.code) {
@@ -1365,6 +1339,18 @@
1365
  }.bind(this));
1366
  };
1367
 
 
 
 
 
 
 
 
 
 
 
 
 
1368
  /************* Cart Gateway *************/
1369
 
1370
  wc_stripe.CartGateway = function () {
661
  }.bind(this));
662
  };
663
 
664
+ wc_stripe.BaseGateway.prototype.process_payment = function (order_id, order_key) {
665
  $.ajax({
666
  method: 'POST',
667
  url: this.params.routes.checkout_payment,
668
  dataType: 'json',
669
+ data: $.extend({}, this.fields.toJson(), {order_id: order_id, order_key: order_key}),
670
+ beforeSend: this.ajax_before_send.bind(this)
671
  }).done(function (result) {
672
  if (result.result && result.result === 'success') {
673
  window.location = result.redirect;
674
  } else {
675
+ if (result.reload) {
676
+ return window.location.reload();
677
+ }
678
  if (result.messages) {
679
  this.submit_error(result.messages);
680
  } else {
700
  if (this.is_current_page('order_pay')) {
701
  this.get_form().submit();
702
  } else {
703
+ this.process_payment(obj.order_id, obj.order_key);
704
  }
705
  }.bind(this)).catch(function (error) {
706
  this.submit_error(error.message);
896
 
897
  this.container_styles();
898
 
899
+ this.hasOrderReviewParams();
900
  };
901
 
902
  wc_stripe.CheckoutGateway.prototype.container_styles = function () {
908
  }
909
  }
910
 
911
+ wc_stripe.CheckoutGateway.prototype.hasOrderReviewParams = function () {
912
+ var params = window.location.search;
913
+ var match = params.match(/_stripe_order_review=(.+)/);
 
 
 
 
914
 
915
+ if (match && match.length > 1) {
916
+ try {
917
+ var obj = JSON.parse(window.atob(match[1]));
918
+ if (this.gateway_id === obj.payment_method) {
919
+ this.payment_token_received = true;
920
+ this.set_nonce(obj.payment_nonce);
921
+ this.set_use_new_option(true);
922
+ history.pushState({}, '', window.location.pathname);
923
+ }
924
+ } catch (err) {
925
  }
926
  }
927
  };
928
 
929
  wc_stripe.CheckoutGateway.prototype.has3DSecureParams = function () {
930
+ if (this.is_current_page('order_pay') || this.is_change_payment_method()) {
931
  if (window.location.hash && typeof window.location.hash === 'string') {
932
  var match = window.location.hash.match(/response=(.*)/);
933
+ if (match) {
934
+ try {
935
+ var obj = JSON.parse(window.atob(match[1]));
936
+ if (obj && obj.hasOwnProperty('client_secret') && obj.gateway_id === this.gateway_id) {
937
+ $(function () {
938
+ this.set_payment_method(this.gateway_id);
939
+ this.set_use_new_option(true);
940
+ this.set_nonce(obj.pm);
941
+ if (obj.save_method === true) {
942
+ this.set_save_payment_method(true);
943
+ }
944
+ $('[name="terms"]').prop('checked', true);
945
+ }.bind(this));
946
+ history.pushState({}, '', window.location.pathname + window.location.search);
947
+ this.handle_card_action(obj);
948
+ }
949
+ } catch (err) {
950
 
951
+ }
952
  }
953
  }
954
  }
1197
  return typeof wc_stripe_cart_contains_subscription !== 'undefined' && wc_stripe_cart_contains_subscription === true;
1198
  }
1199
 
1200
+ wc_stripe.CheckoutGateway.prototype.set_save_payment_method = function (bool) {
1201
+ $('[name="' + this.gateway_id + '_save_source_key' + '"]').prop('checked', bool);
1202
+ }
1203
+
1204
  /************** Product Gateway ***************/
1205
 
1206
  wc_stripe.ProductGateway = function () {
1217
 
1218
  $(this.container).css('max-width', this.buttonWidth + 'px');
1219
  };
 
 
 
 
1220
 
1221
  wc_stripe.ProductGateway.prototype.get_quantity = function () {
1222
  return parseInt($('[name="quantity"]').val());
1223
  };
 
 
 
 
 
1224
 
1225
  wc_stripe.ProductGateway.prototype.set_rest_nonce = function (e, nonce) {
1226
  this.params.rest_nonce = nonce;
1227
  };
 
 
 
 
 
 
1228
 
1229
  wc_stripe.ProductGateway.prototype.found_variation = function (e, variation) {
1230
  var data = this.get_gateway_data();
1233
  data.product.variation = variation;
1234
  this.set_gateway_data(data);
1235
  };
 
 
 
 
1236
 
1237
  wc_stripe.ProductGateway.prototype.reset_variation_data = function () {
1238
  var data = this.get_product_data();
1240
  this.set_product_data(data);
1241
  this.disable_payment_button();
1242
  };
 
 
 
 
1243
 
1244
  wc_stripe.ProductGateway.prototype.disable_payment_button = function () {
1245
  if (this.$button) {
1246
  this.get_button().prop('disabled', true).addClass('disabled');
1247
  }
1248
  };
 
 
 
 
1249
 
1250
  wc_stripe.ProductGateway.prototype.enable_payment_button = function () {
1251
  if (this.$button) {
1252
  this.get_button().prop('disabled', false).removeClass('disabled');
1253
  }
1254
  };
 
 
 
 
1255
 
1256
  wc_stripe.ProductGateway.prototype.get_button = function () {
1257
  return this.$button;
1258
  };
 
 
 
 
1259
 
1260
  wc_stripe.ProductGateway.prototype.is_variable_product = function () {
1261
  return $('[name="variation_id"]').length > 0;
1264
  wc_stripe.ProductGateway.prototype.variable_product_selected = function () {
1265
  return this.get_product_data().variation !== false;
1266
  };
 
 
 
 
1267
 
1268
  wc_stripe.ProductGateway.prototype.get_product_data = function () {
1269
  return this.get_gateway_data().product;
1270
  };
 
 
 
 
1271
 
1272
  wc_stripe.ProductGateway.prototype.set_product_data = function (product) {
1273
  var data = this.get_gateway_data();
1274
  data.product = product;
1275
  this.set_gateway_data(data);
1276
  };
 
 
 
 
1277
 
1278
  wc_stripe.ProductGateway.prototype.add_to_cart = function () {
1279
  return new Promise(function (resolve, reject) {
1282
  url: this.params.routes.add_to_cart,
1283
  method: 'POST',
1284
  dataType: 'json',
1285
+ data: $.extend({}, {
1286
  product_id: this.get_product_data().id,
1287
  variation_id: this.is_variable_product() ? $('[name="variation_id"]').val() : 0,
1288
  qty: $('[name="quantity"]').val(),
1289
  payment_method: this.gateway_id,
1290
  currency: this.get_currency(),
1291
  page_id: this.get_page()
1292
+ }, this.get_product_variations()),
1293
  beforeSend: this.ajax_before_send.bind(this)
1294
  }).done(function (response) {
1295
  this.unblock();
1316
  url: this.params.routes.cart_calculation,
1317
  method: 'POST',
1318
  dataType: 'json',
1319
+ data: $.extend({}, {
1320
  product_id: this.get_product_data().id,
1321
  variation_id: this.is_variable_product() && variation_id ? variation_id : 0,
1322
  qty: $('[name="quantity"]').val(),
1323
  currency: this.get_currency(),
1324
  payment_method: this.gateway_id
1325
+ }, this.get_product_variations()),
1326
  beforeSend: this.ajax_before_send.bind(this)
1327
  }).done(function (response) {
1328
  if (response.code) {
1339
  }.bind(this));
1340
  };
1341
 
1342
+ wc_stripe.ProductGateway.prototype.get_product_variations = function () {
1343
+ var variations = {};
1344
+ if (this.is_variable_product()) {
1345
+ $('.variations [name^="attribute_"]').each(function (index, el) {
1346
+ var $el = $(el);
1347
+ var name = $el.data('attribute_name') || $el.attr('name');
1348
+ variations[name] = $el.val();
1349
+ });
1350
+ }
1351
+ return variations;
1352
+ }
1353
+
1354
  /************* Cart Gateway *************/
1355
 
1356
  wc_stripe.CartGateway = function () {
assets/js/frontend/wc-stripe.min.js CHANGED
@@ -1 +1 @@
1
- !function(a,o){a.wc_stripe={};var i=null;"undefined"==typeof wc_stripe_checkout_fields&&(a.wc_stripe_checkout_fields=[]),wc_stripe.BaseGateway=function(t,e){this.params=t,this.gateway_id=this.params.gateway_id,this.container=void 0===e?"li.payment_method_".concat(this.gateway_id):e,o(this.container).length||(this.container=".payment_method_".concat(this.gateway_id)),this.token_selector=this.params.token_selector,this.saved_method_selector=this.params.saved_method_selector,this.payment_token_received=!1,this.stripe=i,this.elements=i.elements(o.extend({},{locale:"auto"},this.get_element_options())),this.fields=r,this.initialize()},wc_stripe.BaseGateway.prototype.get_page=function(){var t=wc_stripe_params_v3.page;return"cart"===t&&o(document.body).is(".woocommerce-checkout")&&(t="checkout"),t},wc_stripe.BaseGateway.prototype.set_nonce=function(t){this.fields.set(this.gateway_id+"_token_key",t),o(this.token_selector).val(t)},wc_stripe.BaseGateway.prototype.get_element_options=function(){return{}},wc_stripe.BaseGateway.prototype.initialize=function(){},wc_stripe.BaseGateway.prototype.create_button=function(){},wc_stripe.BaseGateway.prototype.is_gateway_selected=function(){return o('[name="payment_method"]:checked').val()===this.gateway_id},wc_stripe.BaseGateway.prototype.is_saved_method_selected=function(){return this.is_gateway_selected()&&"saved"===o('[name="'+this.gateway_id+'_payment_type_key"]:checked').val()},wc_stripe.BaseGateway.prototype.has_checkout_error=function(){return 0<o("#wc_stripe_checkout_error").length&&this.is_gateway_selected()},wc_stripe.BaseGateway.prototype.submit_error=function(t){var e=this.get_error_message(t);e.indexOf("</ul>")<0&&(e='<div class="'+function(){var t="woocommerce-NoticeGroup";return this.is_current_page("checkout")&&(t+=" woocommerce-NoticeGroup-checkout"),t}.bind(this)()+'"><ul class="woocommerce-error"><li>'+e+"</li></ul></div>");t=o(document.body).triggerHandler("wc_stripe_submit_error",[e,t,this]);e=void 0===t?e:t,this.submit_message(e)},wc_stripe.BaseGateway.prototype.submit_error_code=function(t){console.log(t)},wc_stripe.BaseGateway.prototype.get_error_message=function(t){return"object"==typeof t&&t.code&&(t=wc_stripe_messages[t.code]||t.message),t},wc_stripe.BaseGateway.prototype.submit_message=function(t){o(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove();var e=o(this.message_container);e.closest("form").length&&(e=e.closest("form")),e.prepend(t),e.removeClass("processing").unblock(),e.find(".input-text, select, input:checkbox").blur(),o.scroll_to_notices?o.scroll_to_notices(e):o("html, body").animate({scrollTop:e.offset().top-100},1e3)},wc_stripe.BaseGateway.prototype.get_billing_details=function(){var t={name:this.get_customer_name("billing"),address:{city:this.fields.get("billing_city",null),country:this.fields.get("billing_country",null),line1:this.fields.get("billing_address_1",null),line2:this.fields.get("billing_address_2",null),postal_code:this.fields.get("billing_postcode",null),state:this.fields.get("billing_state",null)}};return t.name&&" "!==t.name||delete t.name,""!=this.fields.get("billing_email")&&(t.email=this.fields.get("billing_email")),""!=this.fields.get("billing_phone")&&(t.phone=this.fields.get("billing_phone")),t},wc_stripe.BaseGateway.prototype.get_first_name=function(t){return o("#"+t+"_first_name").val()},wc_stripe.BaseGateway.prototype.get_last_name=function(t){return o("#"+t+"_last_name").val()},wc_stripe.BaseGateway.prototype.get_shipping_prefix=function(){return this.needs_shipping()&&0<o('[name="ship_to_different_address"]').length&&o('[name="ship_to_different_address"]').is(":checked")?"shipping":"billing"},wc_stripe.BaseGateway.prototype.should_save_method=function(){return o("#"+this.gateway_id+"_save_source_key").is(":checked")},wc_stripe.BaseGateway.prototype.is_add_payment_method_page=function(){return"add_payment_method"===this.get_page()||o(document.body).hasClass("woocommerce-add-payment-method")},wc_stripe.BaseGateway.prototype.is_change_payment_method=function(){return"change_payment_method"===this.get_page()},wc_stripe.BaseGateway.prototype.get_selected_payment_method=function(){return o(this.saved_method_selector).val()},wc_stripe.BaseGateway.prototype.needs_shipping=function(){return this.get_gateway_data().needs_shipping},wc_stripe.BaseGateway.prototype.get_currency=function(){return this.get_gateway_data().currency},wc_stripe.BaseGateway.prototype.get_gateway_data=function(){var t=o(this.container).find(".woocommerce_".concat(this.gateway_id,"_gateway_data")).data("gateway");return void 0===t&&this.is_current_page("checkout")&&void 0===(t=o("form.checkout").find(".woocommerce_".concat(this.gateway_id,"_gateway_data")).data("gateway"))&&(t=o(".woocommerce_"+this.gateway_id+"_gateway_data").data("gateway")),t},wc_stripe.BaseGateway.prototype.set_gateway_data=function(t){o(this.container).find(".woocommerce_".concat(this.gateway_id,"_gateway_data")).data("gateway",t)},wc_stripe.BaseGateway.prototype.get_customer_name=function(t){return this.fields.get(t+"_first_name")+" "+this.fields.get(t+"_last_name")},wc_stripe.BaseGateway.prototype.get_customer_email=function(){return this.fields.get("billing_email")},wc_stripe.BaseGateway.prototype.get_address_field_hash=function(t){for(var e=["_first_name","_last_name","_address_1","_address_2","_postcode","_city","_state","_country"],i="",s=0;s<e.length;s++)i+=this.fields.get(t+e[s])+"_";return i},wc_stripe.BaseGateway.prototype.block=function(){o().block&&o.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.BaseGateway.prototype.unblock=function(){o().block&&o.unblockUI()},wc_stripe.BaseGateway.prototype.get_form=function(){return o(this.token_selector).closest("form")},wc_stripe.BaseGateway.prototype.get_total_price=function(){return this.get_gateway_data().total},wc_stripe.BaseGateway.prototype.get_total_price_cents=function(){return this.get_gateway_data().total_cents},wc_stripe.BaseGateway.prototype.set_total_price=function(t){var e=this.get_gateway_data();e.total=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.set_total_price_cents=function(t){var e=this.get_gateway_data();e.total_cents=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.set_payment_method=function(t){o('[name="payment_method"][value="'+t+'"]').prop("checked",!0).trigger("click")},wc_stripe.BaseGateway.prototype.set_selected_shipping_methods=function(t){if(this.fields.set("shipping_method",t),t&&o('[name^="shipping_method"]').length)for(var e in t){var i=t[e];o('[name="shipping_method['+e+']"][value="'+i+'"]').prop("checked",!0).trigger("change")}},wc_stripe.BaseGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,this.set_nonce(t.id),this.process_checkout()},wc_stripe.BaseGateway.prototype.createPaymentRequest=function(){try{this.payment_request_options=this.get_payment_request_options(),this.paymentRequest=i.paymentRequest(this.payment_request_options),this.payment_request_options.requestShipping&&(this.paymentRequest.on("shippingaddresschange",this.update_shipping_address.bind(this)),this.paymentRequest.on("shippingoptionchange",this.update_shipping_method.bind(this))),this.paymentRequest.on("paymentmethod",this.on_payment_method_received.bind(this))}catch(t){return void this.submit_error(t.message)}},wc_stripe.BaseGateway.prototype.get_payment_request_options=function(){var t={country:this.params.country_code,currency:this.get_currency().toLowerCase(),total:{amount:this.get_total_price_cents(),label:this.params.total_label,pending:!0},requestPayerName:function(){return!this.is_current_page("checkout")||!this.is_valid_address(this.get_address_object("billing"),"billing",["email","phone"])}.bind(this)(),requestPayerEmail:this.fields.requestFieldInWallet("billing_email"),requestPayerPhone:this.fields.requestFieldInWallet("billing_phone"),requestShipping:function(){if(this.needs_shipping()){var t=this.get_shipping_prefix();if(this.is_current_page("checkout")&&!this.is_valid_address(this.get_address_object(t),t,["email","phone"])||!this.is_current_page("checkout"))return!0}return!1}.bind(this)()},e=this.get_display_items(),i=this.get_shipping_options();return e&&(t.displayItems=e),t.requestShipping&&i&&(t.shippingOptions=i),t},wc_stripe.BaseGateway.prototype.get_payment_request_update=function(t){var e={currency:this.get_currency().toLowerCase(),total:{amount:parseInt(this.get_total_price_cents()),label:this.params.total_label,pending:!0}},i=this.get_display_items(),s=this.get_shipping_options();return i&&(e.displayItems=i),this.payment_request_options.requestShipping&&s&&(e.shippingOptions=s),t&&(e=o.extend(!0,{},e,t)),e},wc_stripe.BaseGateway.prototype.get_display_items=function(){return this.get_gateway_data().items},wc_stripe.BaseGateway.prototype.set_display_items=function(t){var e=this.get_gateway_data();e.items=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.get_shipping_options=function(){return this.get_gateway_data().shipping_options},wc_stripe.BaseGateway.prototype.set_shipping_options=function(t){var e=this.get_gateway_data();e.shipping_options=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.map_address=function(t){return{city:t.city,postcode:t.postalCode,state:t.region,country:t.country}},wc_stripe.BaseGateway.prototype.on_payment_method_received=function(t){try{this.payment_response=t,this.populate_checkout_fields(t),t.complete("success"),this.on_token_received(t.paymentMethod)}catch(e){a.alert(e)}},wc_stripe.BaseGateway.prototype.populate_checkout_fields=function(t){this.set_nonce(t.paymentMethod.id),this.update_addresses(t)},wc_stripe.BaseGateway.prototype.update_addresses=function(t){t.payerName&&this.fields.set("name",t.payerName,"billing"),t.payerEmail&&this.fields.set("email",t.payerEmail,"billing"),t.payerPhone&&this.fields.set("phone",t.payerPhone,"billing"),t.shippingAddress&&this.populate_shipping_fields(t.shippingAddress),t.paymentMethod.billing_details.address&&this.populate_billing_fields(t.paymentMethod.billing_details.address)},wc_stripe.BaseGateway.prototype.populate_address_fields=function(t,e){for(var i in t)null!==t[i]&&this.fields.set(i,t[i],e)},wc_stripe.BaseGateway.prototype.populate_billing_fields=function(t){this.populate_address_fields(t,"billing")},wc_stripe.BaseGateway.prototype.populate_shipping_fields=function(t){this.populate_address_fields(t,"shipping")},wc_stripe.BaseGateway.prototype.get_address_fields=function(){return["first_name","last_name","country","address_1","address_2","city","state","postcode","phone","email"]},wc_stripe.BaseGateway.prototype.get_address_object=function(e){var i={};return this.get_address_fields().forEach(function(t){i[t]=this.fields.get(t,e)}.bind(this)),i},wc_stripe.BaseGateway.prototype.is_current_page=function(t){return this.get_page()===t},wc_stripe.BaseGateway.prototype.is_valid_address=function(t,e,i){if(o.isEmptyObject(t))return!1;var s=this.get_address_fields();void 0!==i&&i.forEach(function(t){-1<s.indexOf(t)&&s.splice(s.indexOf(t),1)});for(var a=0;a<s.length;a++){var n=s[a];if(this.fields.required(e+"_"+n)&&(!t[n]||"undefined"==typeof t[n]||!this.fields.isValid(n,t[n],t)))return!1}return!0},wc_stripe.BaseGateway.prototype.ajax_before_send=function(t){0<this.params.user_id&&t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)},wc_stripe.BaseGateway.prototype.process_checkout=function(){return new Promise(function(){this.block(),o.ajax({url:this.params.routes.checkout,method:"POST",dataType:"json",data:o.extend({},this.serialize_fields(),{payment_method:this.gateway_id,page_id:this.get_page(),currency:this.get_currency()}),beforeSend:this.ajax_before_send.bind(this)}).done(function(t){t.reload?a.location.reload():"success"===t.result?a.location=t.redirect:(t.messages&&this.submit_error(t.messages),this.unblock())}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.process_payment=function(){o.ajax({method:"POST",url:this.params.routes.checkout_payment,dataType:"json",data:o.extend({},this.fields.toJson(),{_wpnonce:this.params.rest_nonce})}).done(function(t){t.result&&"success"===t.result?a.location=t.redirect:t.messages?this.submit_error(t.messages):this.submit_error(wc_checkout_params.i18n_checkout_error)}.bind(this)).fail(function(){}.bind(this))},wc_stripe.BaseGateway.prototype.handle_card_action=function(e){try{return this.stripe.handleCardAction(e.client_secret).then(function(t){if(t.error)return this.payment_token_received=!1,this.submit_error(t.error),void this.sync_payment_intent(e.order_id,e.client_secret)["catch"](function(t){this.submit_error(t.message)}.bind(this));this.is_current_page("order_pay")?this.get_form().submit():this.process_payment()}.bind(this))["catch"](function(t){this.submit_error(t.message)}.bind(this)),!1}catch(t){}},wc_stripe.BaseGateway.prototype.hashchange=function(t){var e=t.newURL.match(/response=(.*)/);if(e)try{var i=JSON.parse(a.atob(e[1]));i&&i.hasOwnProperty("client_secret")&&i.gateway_id===this.gateway_id&&(history.pushState({},"",a.location.pathname),this.handle_card_action(i))}catch(s){}return!0},wc_stripe.BaseGateway.prototype.sync_payment_intent=function(t,s){return new Promise(function(e,i){o.when(o.ajax({method:"POST",dataType:"json",url:this.params.routes.sync_intent,data:{order_id:t,client_secret:s},beforeSend:this.ajax_before_send.bind(this)})).done(function(t){(t.code?i:e)(t)}).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.serialize_form=function(t){var e,i=t.find("input").filter(function(t,e){return!o(e).is('[name^="add-to-cart"]')}.bind(this)).serializeArray(),s={};for(e in i){var a=i[e];s[a.name]=a.value}return s.payment_method=this.gateway_id,s},wc_stripe.BaseGateway.prototype.serialize_fields=function(){return o.extend({},this.fields.toJson(),o(document.body).triggerHandler("wc_stripe_process_checkout_data",[this,this.fields]))},wc_stripe.BaseGateway.prototype.map_shipping_methods=function(t){var e={};return"default"===t||1<(t=t.match(/^([\w+]):(.+)$/)).length&&(e[t[1]]=t[2]),e},wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different=function(){o('[name="ship_to_different_address"]').length&&o('[name="ship_to_different_address"]').prop("checked",this.get_address_field_hash("billing")!==this.get_address_field_hash("shipping")).trigger("change")},wc_stripe.BaseGateway.prototype.update_shipping_address=function(s){return new Promise(function(e,i){o.ajax({url:this.params.routes.shipping_address,method:"POST",dataType:"json",data:{address:this.map_address(s.shippingAddress),payment_method:this.gateway_id,page_id:this.get_page(),currency:this.get_currency()},beforeSend:this.ajax_before_send.bind(this)}).done(function(t){t.code?(s.updateWith(t.data.newData),i(t.data)):(s.updateWith(t.data.newData),this.fields.set("shipping_method",t.data.shipping_method),e(t.data))}.bind(this)).fail(function(){}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.update_shipping_method=function(s){return new Promise(function(e,i){o.ajax({url:this.params.routes.shipping_method,method:"POST",dataType:"json",data:{shipping_method:s.shippingOption.id,payment_method:this.gateway_id,currency:this.get_currency(),page_id:this.get_page()},beforeSend:this.ajax_before_send.bind(this)}).done(function(t){t.code?(s.updateWith(t.data.newData),i(t.data)):(this.set_selected_shipping_methods(t.data.shipping_methods),s.updateWith(t.data.newData),e(t.data))}.bind(this)).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CheckoutGateway=function(){this.message_container="li.payment_method_"+this.gateway_id,this.banner_container="li.banner_payment_method_"+this.gateway_id,o(document.body).on("update_checkout",this.update_checkout.bind(this)),o(document.body).on("updated_checkout",this.updated_checkout.bind(this)),o(document.body).on("updated_checkout",this.container_styles.bind(this)),o(document.body).on("cfw_updated_checkout",this.updated_checkout.bind(this)),o(document.body).on("checkout_error",this.checkout_error.bind(this)),o(this.token_selector).closest("form").on("checkout_place_order_"+this.gateway_id,this.checkout_place_order.bind(this)),o(document.body).on("wc_stripe_new_method_"+this.gateway_id,this.on_show_new_methods.bind(this)),o(document.body).on("wc_stripe_saved_method_"+this.gateway_id,this.on_show_saved_methods.bind(this)),o(document.body).on("wc_stripe_payment_method_selected",this.on_payment_method_selected.bind(this)),this.banner_enabled()&&o(".woocommerce-billing-fields").length&&o(".wc-stripe-banner-checkout").css("max-width",o(".woocommerce-billing-fields").outerWidth(!0)),this.container_styles(),this.order_review()},wc_stripe.CheckoutGateway.prototype.container_styles=function(){this.params.description||o(this.container).addClass("wc-stripe-no-desc"),o(this.container).find(".wc-stripe-saved-methods").length||o(this.container).find(".payment_box").addClass("wc-stripe-no-methods")},wc_stripe.CheckoutGateway.prototype.order_review=function(){var t,e=a.location.href.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);e&&1<e.length&&(t=e[1],e=e[2],this.gateway_id===t&&(this.payment_token_received=!0,this.set_nonce(e),this.set_use_new_option(!0)))},wc_stripe.CheckoutGateway.prototype.has3DSecureParams=function(){if(this.is_gateway_selected()&&(this.is_current_page("order_pay")||this.is_change_payment_method())&&a.location.hash&&"string"==typeof a.location.hash){var t=a.location.hash.match(/response=(.*)/);try{var e=JSON.parse(a.atob(t[1]));e&&e.hasOwnProperty("client_secret")&&(o('[name="terms"]').prop("checked",!0),this.handle_card_action(e))}catch(i){}}},wc_stripe.CheckoutGateway.prototype.update_shipping_address=function(){return wc_stripe.BaseGateway.prototype.update_shipping_address.apply(this,arguments).then(function(t){this.populate_address_fields(t.address,this.get_shipping_prefix()),this.fields.toFormFields({update_shipping_method:!1})}.bind(this))},wc_stripe.CheckoutGateway.prototype.updated_checkout=function(){},wc_stripe.CheckoutGateway.prototype.update_checkout=function(){},wc_stripe.CheckoutGateway.prototype.checkout_error=function(){this.has_checkout_error()&&(this.payment_token_received=!1,this.payment_response=null,this.show_payment_button(),this.hide_place_order())},wc_stripe.CheckoutGateway.prototype.is_valid_checkout=function(){return!(o('[name="terms"]').length&&!o('[name="terms"]').is(":checked"))},wc_stripe.CheckoutGateway.prototype.get_payment_method=function(){return o('[name="payment_method"]:checked').val()},wc_stripe.CheckoutGateway.prototype.set_use_new_option=function(t){o("#"+this.gateway_id+"_use_new").prop("checked",t).trigger("change")},wc_stripe.CheckoutGateway.prototype.checkout_place_order=function(){return this.is_valid_checkout()?!!this.is_saved_method_selected()||this.payment_token_received:(this.submit_error(this.params.messages.terms),!1)},wc_stripe.CheckoutGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,this.set_nonce(t.id),this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.block=function(){o().block&&o("form.checkout").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.CheckoutGateway.prototype.unblock=function(){o().block&&o("form.checkout").unblock()},wc_stripe.CheckoutGateway.prototype.hide_place_order=function(){o("#place_order").addClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.show_place_order=function(){o("#place_order").removeClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.on_show_new_methods=function(){this.payment_token_received?(this.show_place_order(),this.hide_payment_button()):(this.hide_place_order(),this.show_payment_button())},wc_stripe.CheckoutGateway.prototype.on_show_saved_methods=function(){this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.show_payment_button=function(){this.$button&&this.$button.show()},wc_stripe.CheckoutGateway.prototype.hide_payment_button=function(){this.$button&&this.$button.hide()},wc_stripe.CheckoutGateway.prototype.trigger_payment_method_selected=function(){this.on_payment_method_selected(null,o('[name="payment_method"]:checked').val())},wc_stripe.CheckoutGateway.prototype.on_payment_method_selected=function(t,e){e===this.gateway_id?this.payment_token_received||this.is_saved_method_selected()?(this.hide_payment_button(),this.show_place_order()):(this.show_payment_button(),this.hide_place_order()):(this.hide_payment_button(),e.indexOf("stripe_")<0&&this.show_place_order())},wc_stripe.CheckoutGateway.prototype.banner_enabled=function(){return"1"===this.params.banner_enabled},wc_stripe.CheckoutGateway.prototype.checkout_fields_valid=function(){if(["checkout","order_pay"].indexOf(this.get_page())<0)return!0;var t=!0;return(t=this.fields.validateFields("billing"))?this.needs_shipping()&&o("#ship-to-different-address-checkbox").is(":checked")?(t=this.fields.validateFields("shipping"))||this.submit_error(this.params.messages.required_field):(t=this.is_valid_checkout())||this.submit_error(this.params.messages.terms):this.submit_error(this.params.messages.required_field),t},wc_stripe.CheckoutGateway.prototype.cart_contains_subscription=function(){return"undefined"!=typeof wc_stripe_cart_contains_subscription&&!0===wc_stripe_cart_contains_subscription},wc_stripe.ProductGateway=function(){this.message_container="div.product",o("form.cart").on("found_variation",this.found_variation.bind(this)),o("form.cart").on("reset_data",this.reset_variation_data.bind(this)),this.buttonWidth=o("form.cart div.quantity").outerWidth(!0)+o(".single_add_to_cart_button").outerWidth();var t=o(".single_add_to_cart_button").css("marginLeft");t&&(this.buttonWidth+=parseInt(t.replace("px",""))),o(this.container).css("max-width",this.buttonWidth+"px")},wc_stripe.ProductGateway.prototype.get_quantity=function(){return parseInt(o('[name="quantity"]').val())},wc_stripe.ProductGateway.prototype.set_rest_nonce=function(t,e){this.params.rest_nonce=e},wc_stripe.ProductGateway.prototype.found_variation=function(t,e){var i=this.get_gateway_data();i.product.price=e.display_price,i.needs_shipping=!e.is_virtual,i.product.variation=e,this.set_gateway_data(i)},wc_stripe.ProductGateway.prototype.reset_variation_data=function(){var t=this.get_product_data();t.variation=!1,this.set_product_data(t),this.disable_payment_button()},wc_stripe.ProductGateway.prototype.disable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!0).addClass("disabled")},wc_stripe.ProductGateway.prototype.enable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!1).removeClass("disabled")},wc_stripe.ProductGateway.prototype.get_button=function(){return this.$button},wc_stripe.ProductGateway.prototype.is_variable_product=function(){return 0<o('[name="variation_id"]').length},wc_stripe.ProductGateway.prototype.variable_product_selected=function(){return!1!==this.get_product_data().variation},wc_stripe.ProductGateway.prototype.get_product_data=function(){return this.get_gateway_data().product},wc_stripe.ProductGateway.prototype.set_product_data=function(t){var e=this.get_gateway_data();e.product=t,this.set_gateway_data(e)},wc_stripe.ProductGateway.prototype.add_to_cart=function(){return new Promise(function(e,i){this.block(),o.ajax({url:this.params.routes.add_to_cart,method:"POST",dataType:"json",data:{product_id:this.get_product_data().id,variation_id:this.is_variable_product()?o('[name="variation_id"]').val():0,qty:o('[name="quantity"]').val(),payment_method:this.gateway_id,currency:this.get_currency(),page_id:this.get_page()},beforeSend:this.ajax_before_send.bind(this)}).done(function(t){this.unblock(),t.code?(this.submit_error(t.message),i(t)):(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),e(t.data))}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.ProductGateway.prototype.cart_calculation=function(t){return new Promise(function(e,i){o.ajax({url:this.params.routes.cart_calculation,method:"POST",dataType:"json",data:{product_id:this.get_product_data().id,variation_id:this.is_variable_product()&&t?t:0,qty:o('[name="quantity"]').val(),currency:this.get_currency(),payment_method:this.gateway_id},beforeSend:this.ajax_before_send.bind(this)}).done(function(t){t.code?(this.cart_calculation_error=!0,i(t)):(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),e(t.data))}.bind(this)).fail(function(){}.bind(this))}.bind(this))},wc_stripe.CartGateway=function(){this.message_container="div.woocommerce",o(document.body).on("updated_wc_div",this.updated_html.bind(this)),o(document.body).on("updated_cart_totals",this.updated_html.bind(this)),o(document.body).on("wc_cart_emptied",this.cart_emptied.bind(this))},wc_stripe.CartGateway.prototype.submit_error=function(t){this.submit_message(this.get_error_message(t))},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.CartGateway.prototype.cart_emptied=function(t){},wc_stripe.CartGateway.prototype.add_cart_totals_class=function(){o(".cart_totals").addClass("stripe_cart_gateway_active")},wc_stripe.GooglePay=function(){};var s={apiVersion:2,apiVersionMinor:0},n={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],assuranceDetailsRequired:!0}};wc_stripe.GooglePay.prototype.update_addresses=function(t){var e;t.paymentMethodData.info.billingAddress&&(e=t.paymentMethodData.info.billingAddress,this.is_current_page("checkout")&&this.is_valid_address(this.billing_address_object,"billing",["phone","email"])&&(e={phoneNumber:e.phoneNumber}),this.populate_billing_fields(e)),t.shippingAddress&&this.populate_shipping_fields(t.shippingAddress),t.email&&this.fields.set("email",t.email,"billing")},wc_stripe.GooglePay.prototype.map_address=function(t){return{city:t.locality,postcode:t.postalCode,state:t.administrativeArea,country:t.countryCode}},wc_stripe.GooglePay.prototype.update_payment_data=function(s){return new Promise(function(e,i){var t="default"==s.shippingOptionData.id?null:s.shippingOptionData.id;o.when(o.ajax({url:this.params.routes.payment_data,dataType:"json",method:"POST",data:{address:this.map_address(s.shippingAddress),shipping_method:t,page_id:this.get_page(),currency:this.get_currency()},beforeSend:this.ajax_before_send.bind(this)})).done(function(t){t.code?i(t.data.data):e(t.data)}.bind(this)).fail(function(){i()}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.on_payment_data_changed=function(i){return new Promise(function(e){this.update_payment_data(i).then(function(t){e(t.paymentRequestUpdate),this.set_selected_shipping_methods(t.shipping_methods),this.payment_data_updated(t,i)}.bind(this))["catch"](function(t){e(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.payment_data_updated=function(t){},wc_stripe.GooglePay.prototype.get_merchant_info=function(){var t={merchantId:this.params.merchant_id,merchantName:this.params.merchant_name};return"TEST"===this.params.environment&&delete t.merchantId,t},wc_stripe.GooglePay.prototype.get_payment_options=function(){var t,e={environment:this.params.environment,merchantInfo:this.get_merchant_info(),paymentDataCallbacks:{onPaymentAuthorized:function(){return new Promise(function(t){t({transactionState:"SUCCESS"})}.bind(this))}}};return this.needs_shipping()&&(t=this.get_shipping_prefix(),(!this.is_current_page("checkout")||this.is_valid_address(this.get_address_object(t),t,["email","phone"]))&&this.is_current_page("checkout")||(e.paymentDataCallbacks.onPaymentDataChanged=this.on_payment_data_changed.bind(this))),e},wc_stripe.GooglePay.prototype.build_payment_request=function(){var t=o.extend({},s,{emailRequired:this.fields.requestFieldInWallet("billing_email"),merchantInfo:this.get_merchant_info(),allowedPaymentMethods:[o.extend({type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":this.params.api_key}}},n)],shippingAddressRequired:function(){if(this.needs_shipping()){var t=this.get_shipping_prefix();if(this.is_current_page("checkout")&&!this.is_valid_address(this.get_address_object(t),t,["email","phone"])||!this.is_current_page("checkout"))return!0}return!1}.bind(this)(),transactionInfo:{countryCode:this.params.processing_country,currencyCode:this.get_currency(),totalPriceStatus:"ESTIMATED",totalPrice:this.get_total_price().toString(),displayItems:this.get_display_items(),totalPriceLabel:this.params.total_price_label}});return t.allowedPaymentMethods[0].parameters.billingAddressRequired=function(){if(this.is_current_page("checkout")){var t=this.billing_address_object=this.get_address_object("billing");return this.fields.requestFieldInWallet("billing_phone")||!this.is_valid_address(t,"billing",["email"])?!0:!1}return!0}.bind(this)(),t.allowedPaymentMethods[0].parameters.billingAddressRequired&&(t.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:this.fields.requestFieldInWallet("billing_phone")}),t.shippingAddressRequired?(t.shippingAddressParameters={},t.shippingOptionRequired=!0,t.shippingOptionParameters={shippingOptions:this.get_shipping_options()},t.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]):t.callbackIntents=["PAYMENT_AUTHORIZATION"],this.payment_request_options=t},wc_stripe.GooglePay.prototype.createPaymentsClient=function(){this.paymentsClient=new google.payments.api.PaymentsClient(this.get_payment_options())},wc_stripe.GooglePay.prototype.isReadyToPay=function(){return new Promise(function(t){var e=o.extend({},s);e.allowedPaymentMethods=[n],this.paymentsClient.isReadyToPay(e).then(function(){this.can_pay=!0,this.create_button(),t()}.bind(this))["catch"](function(t){this.submit_error(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=o(this.paymentsClient.createButton({onClick:this.start.bind(this),buttonColor:this.params.button_color,buttonType:this.params.button_style})),this.$button.addClass("gpay-button-container")},wc_stripe.GooglePay.prototype.start=function(){this.createPaymentsClient(),this.paymentsClient.loadPaymentData(this.build_payment_request()).then(function(t){var e=JSON.parse(t.paymentMethodData.tokenizationData.token);this.update_addresses(t),this.stripe.createPaymentMethod({type:"card",card:{token:e.id},billing_details:this.get_billing_details()}).then(function(t){if(t.error)return this.submit_error(t.error);this.on_token_received(t.paymentMethod)}.bind(this))}.bind(this))["catch"](function(t){"CANCELED"!==t.statusCode&&(t.statusMessage&&-1<t.statusMessage.indexOf("paymentDataRequest.callbackIntent")?this.submit_error_code("DEVELOPER_ERROR_WHITELIST"):this.submit_error(t.statusMessage))}.bind(this))},wc_stripe.ApplePay=function(){},wc_stripe.ApplePay.prototype.initialize=function(){this.createPaymentRequest(),this.canMakePayment()},wc_stripe.ApplePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=o(this.params.button),this.$button.on("click",this.start.bind(this)),this.append_button()},wc_stripe.ApplePay.prototype.canMakePayment=function(){return new Promise(function(e){this.paymentRequest.canMakePayment().then(function(t){t&&t.applePay&&(this.can_pay=!0,this.create_button(),o(this.container).show(),e(t))}.bind(this))}.bind(this))},wc_stripe.ApplePay.prototype.start=function(t){t.preventDefault(),this.paymentRequest.update(this.get_payment_request_update({total:{pending:!1}})),this.paymentRequest.show()},wc_stripe.PaymentRequest=function(){},wc_stripe.PaymentRequest.prototype.initialize=function(){this.createPaymentRequest(),this.createPaymentRequestButton(),this.canMakePayment(),this.paymentRequestButton.on("click",this.button_click.bind(this))},wc_stripe.PaymentRequest.prototype.button_click=function(t){},wc_stripe.PaymentRequest.prototype.createPaymentRequestButton=function(){this.paymentRequestButton&&this.paymentRequestButton.destroy(),this.paymentRequestButton=this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest,style:{paymentRequestButton:{type:this.params.button.type,theme:this.params.button.theme,height:this.params.button.height}}})},wc_stripe.PaymentRequest.prototype.canMakePayment=function(){return new Promise(function(e){this.paymentRequest.canMakePayment().then(function(t){t&&!t.applePay&&(this.can_pay=!0,this.create_button(),o(this.container).show(),e(t))}.bind(this))}.bind(this))},wc_stripe.PaymentRequest.prototype.create_button=function(){this.paymentRequestButton.mount("#wc-stripe-payment-request-container")},wc_stripe.CheckoutFields=function(t,e){this.params=t,this.page=e,this.session_values=this.supportsSessionStorage()&&sessionStorage.getItem("wc_stripe_checkout_fields")?JSON.parse(sessionStorage.getItem("wc_stripe_checkout_fields")):{},this.fields=new Map(Object.keys(this.params).map(function(t){return null===this.params[t].value&&(t in this.session_values&&null!==this.session_values[t]?this.params[t].value=this.session_values[t]:this.params[t].value=""),[t,this.params[t].value]}.bind(this))),("checkout"===e||"cart"===e&&o(document.body).is(".woocommerce-checkout"))&&(o("form.checkout").on("change",".input-text, select",this.onChange.bind(this)),o("form.checkout").on("change",'[name="ship_to_different_address"]',this.on_ship_to_address_change.bind(this)),this.init_i18n(),o('[name="ship_to_different_address"]').is(":checked")?this.update_required_fields(o("#shipping_country").val(),"shipping_country"):this.update_required_fields(o("#billing_country").val(),"billing_country"))},wc_stripe.CheckoutFields.prototype.supportsSessionStorage=function(){return"sessionStorage"in a&&null!==a.sessionStorage&&["getItem","setItem"].reduce(function(t,e){return t&&e in sessionStorage}.bind(this),!0)},wc_stripe.CheckoutFields.prototype.init_i18n=function(){"undefined"!=typeof wc_address_i18n_params?this.locales=JSON.parse(wc_address_i18n_params.locale.replace(/&quot;/g,'"')):this.locales=null},wc_stripe.CheckoutFields.prototype.onChange=function(t){try{var e=t.currentTarget.name,i=t.currentTarget.value;this.fields.set(e,i),"billing_country"!==e&&"shipping_country"!==e||this.update_required_fields(i,e),this.supportsSessionStorage()&&sessionStorage.setItem("wc_stripe_checkout_fields",JSON.stringify(this.toJson()))}catch(s){console.log(s)}},wc_stripe.CheckoutFields.prototype.update_required_fields=function(t,e){if(this.locales){var i,s=-1<e.indexOf("billing_")?"billing_":"shipping_",t="undefined"!=typeof this.locales[t]?this.locales[t]:this.locales["default"],a=o.extend(!0,{},this.locales["default"],t);for(i in a){var n=s+i;this.params[n]&&(this.params[n]=o.extend(!0,{},this.params[n],a[i]))}}},wc_stripe.CheckoutFields.prototype.on_ship_to_address_change=function(t){o(t.currentTarget).is(":checked")&&this.update_required_fields(o("#shipping_country").val(),"shipping_country")},wc_stripe.CheckoutFields.prototype.requestFieldInWallet=function(t){return"checkout"===this.page?this.required(t)&&this.isEmpty(t):"order_pay"!==this.page&&this.required(t)},wc_stripe.CheckoutFields.prototype.set=function(t,e,i){this[t]&&"function"==typeof this[t]?this[t]().set.call(this,e,i):this.fields.set(t,e)},wc_stripe.CheckoutFields.prototype.get=function(t,e){var i;return this[t]&&"function"==typeof this[t]?i=this[t]().get.call(this,e):null!=(i=this.fields.get(t))&&""!==i||void 0!==e&&(i=e),void 0===i?"":i},wc_stripe.CheckoutFields.prototype.required=function(t){return!(!this.params[t]||"undefined"==typeof this.params[t].required)&&this.params[t].required},wc_stripe.CheckoutFields.prototype.isEmpty=function(t){if(this.fields.has(t)){t=this.fields.get(t);return null==t||"string"==typeof t&&0===t.trim().length}return!0},wc_stripe.CheckoutFields.prototype.isValid=function(t){if(this[t]&&"function"==typeof this[t])return this[t]().isValid.apply(this,Array.prototype.slice.call(arguments,1))},wc_stripe.CheckoutFields.prototype.first_name=function(){return{set:function(t,e){this.fields.set(e+"_first_name",t)},get:function(t){return this.fields.get(t+"_first_name")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.last_name=function(){return{set:function(t,e){this.fields.set(e+"_last_name",t)},get:function(t){return this.fields.get(t+"_last_name")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.address_1=function(){return{set:function(t,e){this.fields.set(e+"_address_1",t)},get:function(t){return this.fields.get(t+"_address_1")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.address_2=function(){return{set:function(t,e){this.fields.set(e+"_address_2",t)},get:function(t){return this.fields.get(t+"_address_2")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.name=function(){return{set:function(t,e){t=t.split(" ");0<t.length&&this.fields.set(e+"_first_name",t[0]),1<t.length&&this.fields.set(e+"_last_name",t[1])},get:function(t){return this.fields.get(t+"_first_name")+" "+this.fields.get(t+"_last_name")}}},wc_stripe.CheckoutFields.prototype.email=function(){return{set:function(t,e){this.fields.set(e+"_email",t)},get:function(t){return this.fields.get(t+"_email")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.phone=function(){return{set:function(t,e){this.fields.set(e+"_phone",t)},get:function(t){return this.fields.get(t+"_phone")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.country=function(){return{set:function(t,e){this.fields.set(e+"_country",t)},get:function(t){return this.fields.get(t+"_country")},isValid:function(t){return"string"==typeof t&&2===t.length}}},wc_stripe.CheckoutFields.prototype.state=function(){return{set:function(i,t){2<(i=i.toUpperCase()).length&&"checkout"===this.page&&o("#"+t+"_state option").each(function(){var t=o(this),e=t.text().toUpperCase();i===e&&(i=t.val())}),this.fields.set(t+"_state",i)},get:function(t){return this.fields.get(t+"_state")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.city=function(){return{set:function(t,e){this.fields.set(e+"_city",t)},get:function(t){return this.fields.get(t+"_city")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.postcode=function(){return{set:function(t,e){this.fields.set(e+"_postcode",t)},get:function(t){return this.fields.get(t+"_postcode")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.recipient=function(){return wc_stripe.CheckoutFields.prototype.name.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.payerName=function(){return wc_stripe.CheckoutFields.prototype.name.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.payerEmail=function(){return wc_stripe.CheckoutFields.prototype.email.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.payerPhone=function(){return wc_stripe.CheckoutFields.prototype.phone.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.phoneNumber=function(){return wc_stripe.CheckoutFields.prototype.phone.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.countryCode=function(){return wc_stripe.CheckoutFields.prototype.country.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.address1=function(){return wc_stripe.CheckoutFields.prototype.address_1.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.address2=function(){return wc_stripe.CheckoutFields.prototype.address_2.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.line1=function(){return wc_stripe.CheckoutFields.prototype.address_1.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.line2=function(){return wc_stripe.CheckoutFields.prototype.address_2.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.addressLine=function(){return{set:function(t,e){0<t.length&&this.fields.set(e+"_address_1",t[0]),1<t.length&&this.fields.set(e+"_address_2",t[1])},get:function(t){return[this.fields.get(t+"_address_1"),this.fields.get(t+"_address_2")]},isValid:function(t){return 0<t.length&&("string"==typeof t[0]&&0<t[0].length)}}},wc_stripe.CheckoutFields.prototype.region=function(){return wc_stripe.CheckoutFields.prototype.state.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.administrativeArea=function(){return wc_stripe.CheckoutFields.prototype.state.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.locality=function(){return wc_stripe.CheckoutFields.prototype.city.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.postal_code=function(){return wc_stripe.CheckoutFields.prototype.postcode.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.postalCode=function(){return wc_stripe.CheckoutFields.prototype.postcode.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.toJson=function(){var i={};return this.fields.forEach(function(t,e){i[e]=t}),i},wc_stripe.CheckoutFields.prototype.toFormFields=function(t){var i=[];this.fields.forEach(function(t,e){e='[name="'+e+'"]';o(e).length&&""!==t&&(o(e).val()!==t&&o(e).is("select")&&i.push(e),o(e).val(t))}),0<i.length&&o(i.join(",")).trigger("change"),void 0!==t&&o(document.body).trigger("update_checkout",t)},wc_stripe.CheckoutFields.prototype.validateFields=function(t){for(var e in this.params){var i=this.params[e];if(-1<e.indexOf(t)&&i.required&&o("#"+e).length&&o("#"+e).is(":visible")){i=o("#"+e).val();if(null==i||0===i.length)return!1}}return!0};try{i=Stripe(wc_stripe_params_v3.api_key,"test"===wc_stripe_params_v3.mode&&""===wc_stripe_params_v3.account?{}:{stripeAccount:wc_stripe_params_v3.account})}catch(t){return a.alert(t),console.log(t)}var r=new wc_stripe.CheckoutFields(wc_stripe_checkout_fields,wc_stripe_params_v3.page)}(window,jQuery);
1
+ !function(a,o){a.wc_stripe={};var i=null;"undefined"==typeof wc_stripe_checkout_fields&&(a.wc_stripe_checkout_fields=[]),wc_stripe.BaseGateway=function(t,e){this.params=t,this.gateway_id=this.params.gateway_id,this.container=void 0===e?"li.payment_method_".concat(this.gateway_id):e,o(this.container).length||(this.container=".payment_method_".concat(this.gateway_id)),this.token_selector=this.params.token_selector,this.saved_method_selector=this.params.saved_method_selector,this.payment_token_received=!1,this.stripe=i,this.elements=i.elements(o.extend({},{locale:"auto"},this.get_element_options())),this.fields=r,this.initialize()},wc_stripe.BaseGateway.prototype.get_page=function(){var t=wc_stripe_params_v3.page;return"cart"===t&&o(document.body).is(".woocommerce-checkout")&&(t="checkout"),t},wc_stripe.BaseGateway.prototype.set_nonce=function(t){this.fields.set(this.gateway_id+"_token_key",t),o(this.token_selector).val(t)},wc_stripe.BaseGateway.prototype.get_element_options=function(){return{}},wc_stripe.BaseGateway.prototype.initialize=function(){},wc_stripe.BaseGateway.prototype.create_button=function(){},wc_stripe.BaseGateway.prototype.is_gateway_selected=function(){return o('[name="payment_method"]:checked').val()===this.gateway_id},wc_stripe.BaseGateway.prototype.is_saved_method_selected=function(){return this.is_gateway_selected()&&"saved"===o('[name="'+this.gateway_id+'_payment_type_key"]:checked').val()},wc_stripe.BaseGateway.prototype.has_checkout_error=function(){return 0<o("#wc_stripe_checkout_error").length&&this.is_gateway_selected()},wc_stripe.BaseGateway.prototype.submit_error=function(t){var e=this.get_error_message(t);e.indexOf("</ul>")<0&&(e='<div class="'+function(){var t="woocommerce-NoticeGroup";return this.is_current_page("checkout")&&(t+=" woocommerce-NoticeGroup-checkout"),t}.bind(this)()+'"><ul class="woocommerce-error"><li>'+e+"</li></ul></div>");t=o(document.body).triggerHandler("wc_stripe_submit_error",[e,t,this]);e=void 0===t?e:t,this.submit_message(e)},wc_stripe.BaseGateway.prototype.submit_error_code=function(t){console.log(t)},wc_stripe.BaseGateway.prototype.get_error_message=function(t){return"object"==typeof t&&t.code&&(t=wc_stripe_messages[t.code]||t.message),t},wc_stripe.BaseGateway.prototype.submit_message=function(t){o(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove();var e=o(this.message_container);e.closest("form").length&&(e=e.closest("form")),e.prepend(t),e.removeClass("processing").unblock(),e.find(".input-text, select, input:checkbox").blur(),o.scroll_to_notices?o.scroll_to_notices(e):o("html, body").animate({scrollTop:e.offset().top-100},1e3)},wc_stripe.BaseGateway.prototype.get_billing_details=function(){var t={name:this.get_customer_name("billing"),address:{city:this.fields.get("billing_city",null),country:this.fields.get("billing_country",null),line1:this.fields.get("billing_address_1",null),line2:this.fields.get("billing_address_2",null),postal_code:this.fields.get("billing_postcode",null),state:this.fields.get("billing_state",null)}};return t.name&&" "!==t.name||delete t.name,""!=this.fields.get("billing_email")&&(t.email=this.fields.get("billing_email")),""!=this.fields.get("billing_phone")&&(t.phone=this.fields.get("billing_phone")),t},wc_stripe.BaseGateway.prototype.get_first_name=function(t){return o("#"+t+"_first_name").val()},wc_stripe.BaseGateway.prototype.get_last_name=function(t){return o("#"+t+"_last_name").val()},wc_stripe.BaseGateway.prototype.get_shipping_prefix=function(){return this.needs_shipping()&&0<o('[name="ship_to_different_address"]').length&&o('[name="ship_to_different_address"]').is(":checked")?"shipping":"billing"},wc_stripe.BaseGateway.prototype.should_save_method=function(){return o("#"+this.gateway_id+"_save_source_key").is(":checked")},wc_stripe.BaseGateway.prototype.is_add_payment_method_page=function(){return"add_payment_method"===this.get_page()||o(document.body).hasClass("woocommerce-add-payment-method")},wc_stripe.BaseGateway.prototype.is_change_payment_method=function(){return"change_payment_method"===this.get_page()},wc_stripe.BaseGateway.prototype.get_selected_payment_method=function(){return o(this.saved_method_selector).val()},wc_stripe.BaseGateway.prototype.needs_shipping=function(){return this.get_gateway_data().needs_shipping},wc_stripe.BaseGateway.prototype.get_currency=function(){return this.get_gateway_data().currency},wc_stripe.BaseGateway.prototype.get_gateway_data=function(){var t=o(this.container).find(".woocommerce_".concat(this.gateway_id,"_gateway_data")).data("gateway");return void 0===t&&this.is_current_page("checkout")&&void 0===(t=o("form.checkout").find(".woocommerce_".concat(this.gateway_id,"_gateway_data")).data("gateway"))&&(t=o(".woocommerce_"+this.gateway_id+"_gateway_data").data("gateway")),t},wc_stripe.BaseGateway.prototype.set_gateway_data=function(t){o(this.container).find(".woocommerce_".concat(this.gateway_id,"_gateway_data")).data("gateway",t)},wc_stripe.BaseGateway.prototype.get_customer_name=function(t){return this.fields.get(t+"_first_name")+" "+this.fields.get(t+"_last_name")},wc_stripe.BaseGateway.prototype.get_customer_email=function(){return this.fields.get("billing_email")},wc_stripe.BaseGateway.prototype.get_address_field_hash=function(t){for(var e=["_first_name","_last_name","_address_1","_address_2","_postcode","_city","_state","_country"],i="",s=0;s<e.length;s++)i+=this.fields.get(t+e[s])+"_";return i},wc_stripe.BaseGateway.prototype.block=function(){o().block&&o.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.BaseGateway.prototype.unblock=function(){o().block&&o.unblockUI()},wc_stripe.BaseGateway.prototype.get_form=function(){return o(this.token_selector).closest("form")},wc_stripe.BaseGateway.prototype.get_total_price=function(){return this.get_gateway_data().total},wc_stripe.BaseGateway.prototype.get_total_price_cents=function(){return this.get_gateway_data().total_cents},wc_stripe.BaseGateway.prototype.set_total_price=function(t){var e=this.get_gateway_data();e.total=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.set_total_price_cents=function(t){var e=this.get_gateway_data();e.total_cents=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.set_payment_method=function(t){o('[name="payment_method"][value="'+t+'"]').prop("checked",!0).trigger("click")},wc_stripe.BaseGateway.prototype.set_selected_shipping_methods=function(t){if(this.fields.set("shipping_method",t),t&&o('[name^="shipping_method"]').length)for(var e in t){var i=t[e];o('[name="shipping_method['+e+']"][value="'+i+'"]').prop("checked",!0).trigger("change")}},wc_stripe.BaseGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,this.set_nonce(t.id),this.process_checkout()},wc_stripe.BaseGateway.prototype.createPaymentRequest=function(){try{this.payment_request_options=this.get_payment_request_options(),this.paymentRequest=i.paymentRequest(this.payment_request_options),this.payment_request_options.requestShipping&&(this.paymentRequest.on("shippingaddresschange",this.update_shipping_address.bind(this)),this.paymentRequest.on("shippingoptionchange",this.update_shipping_method.bind(this))),this.paymentRequest.on("paymentmethod",this.on_payment_method_received.bind(this))}catch(t){return void this.submit_error(t.message)}},wc_stripe.BaseGateway.prototype.get_payment_request_options=function(){var t={country:this.params.country_code,currency:this.get_currency().toLowerCase(),total:{amount:this.get_total_price_cents(),label:this.params.total_label,pending:!0},requestPayerName:function(){return!this.is_current_page("checkout")||!this.is_valid_address(this.get_address_object("billing"),"billing",["email","phone"])}.bind(this)(),requestPayerEmail:this.fields.requestFieldInWallet("billing_email"),requestPayerPhone:this.fields.requestFieldInWallet("billing_phone"),requestShipping:function(){if(this.needs_shipping()){var t=this.get_shipping_prefix();if(this.is_current_page("checkout")&&!this.is_valid_address(this.get_address_object(t),t,["email","phone"])||!this.is_current_page("checkout"))return!0}return!1}.bind(this)()},e=this.get_display_items(),i=this.get_shipping_options();return e&&(t.displayItems=e),t.requestShipping&&i&&(t.shippingOptions=i),t},wc_stripe.BaseGateway.prototype.get_payment_request_update=function(t){var e={currency:this.get_currency().toLowerCase(),total:{amount:parseInt(this.get_total_price_cents()),label:this.params.total_label,pending:!0}},i=this.get_display_items(),s=this.get_shipping_options();return i&&(e.displayItems=i),this.payment_request_options.requestShipping&&s&&(e.shippingOptions=s),t&&(e=o.extend(!0,{},e,t)),e},wc_stripe.BaseGateway.prototype.get_display_items=function(){return this.get_gateway_data().items},wc_stripe.BaseGateway.prototype.set_display_items=function(t){var e=this.get_gateway_data();e.items=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.get_shipping_options=function(){return this.get_gateway_data().shipping_options},wc_stripe.BaseGateway.prototype.set_shipping_options=function(t){var e=this.get_gateway_data();e.shipping_options=t,this.set_gateway_data(e)},wc_stripe.BaseGateway.prototype.map_address=function(t){return{city:t.city,postcode:t.postalCode,state:t.region,country:t.country}},wc_stripe.BaseGateway.prototype.on_payment_method_received=function(t){try{this.payment_response=t,this.populate_checkout_fields(t),t.complete("success"),this.on_token_received(t.paymentMethod)}catch(e){a.alert(e)}},wc_stripe.BaseGateway.prototype.populate_checkout_fields=function(t){this.set_nonce(t.paymentMethod.id),this.update_addresses(t)},wc_stripe.BaseGateway.prototype.update_addresses=function(t){t.payerName&&this.fields.set("name",t.payerName,"billing"),t.payerEmail&&this.fields.set("email",t.payerEmail,"billing"),t.payerPhone&&this.fields.set("phone",t.payerPhone,"billing"),t.shippingAddress&&this.populate_shipping_fields(t.shippingAddress),t.paymentMethod.billing_details.address&&this.populate_billing_fields(t.paymentMethod.billing_details.address)},wc_stripe.BaseGateway.prototype.populate_address_fields=function(t,e){for(var i in t)null!==t[i]&&this.fields.set(i,t[i],e)},wc_stripe.BaseGateway.prototype.populate_billing_fields=function(t){this.populate_address_fields(t,"billing")},wc_stripe.BaseGateway.prototype.populate_shipping_fields=function(t){this.populate_address_fields(t,"shipping")},wc_stripe.BaseGateway.prototype.get_address_fields=function(){return["first_name","last_name","country","address_1","address_2","city","state","postcode","phone","email"]},wc_stripe.BaseGateway.prototype.get_address_object=function(e){var i={};return this.get_address_fields().forEach(function(t){i[t]=this.fields.get(t,e)}.bind(this)),i},wc_stripe.BaseGateway.prototype.is_current_page=function(t){return this.get_page()===t},wc_stripe.BaseGateway.prototype.is_valid_address=function(t,e,i){if(o.isEmptyObject(t))return!1;var s=this.get_address_fields();void 0!==i&&i.forEach(function(t){-1<s.indexOf(t)&&s.splice(s.indexOf(t),1)});for(var a=0;a<s.length;a++){var n=s[a];if(this.fields.required(e+"_"+n)&&(!t[n]||"undefined"==typeof t[n]||!this.fields.isValid(n,t[n],t)))return!1}return!0},wc_stripe.BaseGateway.prototype.ajax_before_send=function(t){0<this.params.user_id&&t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)},wc_stripe.BaseGateway.prototype.process_checkout=function(){return new Promise(function(){this.block(),o.ajax({url:this.params.routes.checkout,method:"POST",dataType:"json",data:o.extend({},this.serialize_fields(),{payment_method:this.gateway_id,page_id:this.get_page(),currency:this.get_currency()}),beforeSend:this.ajax_before_send.bind(this)}).done(function(t){t.reload?a.location.reload():"success"===t.result?a.location=t.redirect:(t.messages&&this.submit_error(t.messages),this.unblock())}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.process_payment=function(t,e){o.ajax({method:"POST",url:this.params.routes.checkout_payment,dataType:"json",data:o.extend({},this.fields.toJson(),{order_id:t,order_key:e}),beforeSend:this.ajax_before_send.bind(this)}).done(function(t){if(t.result&&"success"===t.result)a.location=t.redirect;else{if(t.reload)return a.location.reload();t.messages?this.submit_error(t.messages):this.submit_error(wc_checkout_params.i18n_checkout_error)}}.bind(this)).fail(function(){}.bind(this))},wc_stripe.BaseGateway.prototype.handle_card_action=function(e){try{return this.stripe.handleCardAction(e.client_secret).then(function(t){if(t.error)return this.payment_token_received=!1,this.submit_error(t.error),void this.sync_payment_intent(e.order_id,e.client_secret)["catch"](function(t){this.submit_error(t.message)}.bind(this));this.is_current_page("order_pay")?this.get_form().submit():this.process_payment(e.order_id,e.order_key)}.bind(this))["catch"](function(t){this.submit_error(t.message)}.bind(this)),!1}catch(t){}},wc_stripe.BaseGateway.prototype.hashchange=function(t){var e=t.newURL.match(/response=(.*)/);if(e)try{var i=JSON.parse(a.atob(e[1]));i&&i.hasOwnProperty("client_secret")&&i.gateway_id===this.gateway_id&&(history.pushState({},"",a.location.pathname),this.handle_card_action(i))}catch(s){}return!0},wc_stripe.BaseGateway.prototype.sync_payment_intent=function(t,s){return new Promise(function(e,i){o.when(o.ajax({method:"POST",dataType:"json",url:this.params.routes.sync_intent,data:{order_id:t,client_secret:s},beforeSend:this.ajax_before_send.bind(this)})).done(function(t){(t.code?i:e)(t)}).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.serialize_form=function(t){var e,i=t.find("input").filter(function(t,e){return!o(e).is('[name^="add-to-cart"]')}.bind(this)).serializeArray(),s={};for(e in i){var a=i[e];s[a.name]=a.value}return s.payment_method=this.gateway_id,s},wc_stripe.BaseGateway.prototype.serialize_fields=function(){return o.extend({},this.fields.toJson(),o(document.body).triggerHandler("wc_stripe_process_checkout_data",[this,this.fields]))},wc_stripe.BaseGateway.prototype.map_shipping_methods=function(t){var e={};return"default"===t||1<(t=t.match(/^([\w+]):(.+)$/)).length&&(e[t[1]]=t[2]),e},wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different=function(){o('[name="ship_to_different_address"]').length&&o('[name="ship_to_different_address"]').prop("checked",this.get_address_field_hash("billing")!==this.get_address_field_hash("shipping")).trigger("change")},wc_stripe.BaseGateway.prototype.update_shipping_address=function(s){return new Promise(function(e,i){o.ajax({url:this.params.routes.shipping_address,method:"POST",dataType:"json",data:{address:this.map_address(s.shippingAddress),payment_method:this.gateway_id,page_id:this.get_page(),currency:this.get_currency()},beforeSend:this.ajax_before_send.bind(this)}).done(function(t){t.code?(s.updateWith(t.data.newData),i(t.data)):(s.updateWith(t.data.newData),this.fields.set("shipping_method",t.data.shipping_method),e(t.data))}.bind(this)).fail(function(){}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.update_shipping_method=function(s){return new Promise(function(e,i){o.ajax({url:this.params.routes.shipping_method,method:"POST",dataType:"json",data:{shipping_method:s.shippingOption.id,payment_method:this.gateway_id,currency:this.get_currency(),page_id:this.get_page()},beforeSend:this.ajax_before_send.bind(this)}).done(function(t){t.code?(s.updateWith(t.data.newData),i(t.data)):(this.set_selected_shipping_methods(t.data.shipping_methods),s.updateWith(t.data.newData),e(t.data))}.bind(this)).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CheckoutGateway=function(){this.message_container="li.payment_method_"+this.gateway_id,this.banner_container="li.banner_payment_method_"+this.gateway_id,o(document.body).on("update_checkout",this.update_checkout.bind(this)),o(document.body).on("updated_checkout",this.updated_checkout.bind(this)),o(document.body).on("updated_checkout",this.container_styles.bind(this)),o(document.body).on("cfw_updated_checkout",this.updated_checkout.bind(this)),o(document.body).on("checkout_error",this.checkout_error.bind(this)),o(this.token_selector).closest("form").on("checkout_place_order_"+this.gateway_id,this.checkout_place_order.bind(this)),o(document.body).on("wc_stripe_new_method_"+this.gateway_id,this.on_show_new_methods.bind(this)),o(document.body).on("wc_stripe_saved_method_"+this.gateway_id,this.on_show_saved_methods.bind(this)),o(document.body).on("wc_stripe_payment_method_selected",this.on_payment_method_selected.bind(this)),this.banner_enabled()&&o(".woocommerce-billing-fields").length&&o(".wc-stripe-banner-checkout").css("max-width",o(".woocommerce-billing-fields").outerWidth(!0)),this.container_styles(),this.hasOrderReviewParams()},wc_stripe.CheckoutGateway.prototype.container_styles=function(){this.params.description||o(this.container).addClass("wc-stripe-no-desc"),o(this.container).find(".wc-stripe-saved-methods").length||o(this.container).find(".payment_box").addClass("wc-stripe-no-methods")},wc_stripe.CheckoutGateway.prototype.hasOrderReviewParams=function(){var t=a.location.search.match(/_stripe_order_review=(.+)/);if(t&&1<t.length)try{var e=JSON.parse(a.atob(t[1]));this.gateway_id===e.payment_method&&(this.payment_token_received=!0,this.set_nonce(e.payment_nonce),this.set_use_new_option(!0),history.pushState({},"",a.location.pathname))}catch(i){}},wc_stripe.CheckoutGateway.prototype.has3DSecureParams=function(){if((this.is_current_page("order_pay")||this.is_change_payment_method())&&a.location.hash&&"string"==typeof a.location.hash){var t=a.location.hash.match(/response=(.*)/);if(t)try{var e=JSON.parse(a.atob(t[1]));e&&e.hasOwnProperty("client_secret")&&e.gateway_id===this.gateway_id&&(o(function(){this.set_payment_method(this.gateway_id),this.set_use_new_option(!0),this.set_nonce(e.pm),!0===e.save_method&&this.set_save_payment_method(!0),o('[name="terms"]').prop("checked",!0)}.bind(this)),history.pushState({},"",a.location.pathname+a.location.search),this.handle_card_action(e))}catch(i){}}},wc_stripe.CheckoutGateway.prototype.update_shipping_address=function(){return wc_stripe.BaseGateway.prototype.update_shipping_address.apply(this,arguments).then(function(t){this.populate_address_fields(t.address,this.get_shipping_prefix()),this.fields.toFormFields({update_shipping_method:!1})}.bind(this))},wc_stripe.CheckoutGateway.prototype.updated_checkout=function(){},wc_stripe.CheckoutGateway.prototype.update_checkout=function(){},wc_stripe.CheckoutGateway.prototype.checkout_error=function(){this.has_checkout_error()&&(this.payment_token_received=!1,this.payment_response=null,this.show_payment_button(),this.hide_place_order())},wc_stripe.CheckoutGateway.prototype.is_valid_checkout=function(){return!(o('[name="terms"]').length&&!o('[name="terms"]').is(":checked"))},wc_stripe.CheckoutGateway.prototype.get_payment_method=function(){return o('[name="payment_method"]:checked').val()},wc_stripe.CheckoutGateway.prototype.set_use_new_option=function(t){o("#"+this.gateway_id+"_use_new").prop("checked",t).trigger("change")},wc_stripe.CheckoutGateway.prototype.checkout_place_order=function(){return this.is_valid_checkout()?!!this.is_saved_method_selected()||this.payment_token_received:(this.submit_error(this.params.messages.terms),!1)},wc_stripe.CheckoutGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,this.set_nonce(t.id),this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.block=function(){o().block&&o("form.checkout").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.CheckoutGateway.prototype.unblock=function(){o().block&&o("form.checkout").unblock()},wc_stripe.CheckoutGateway.prototype.hide_place_order=function(){o("#place_order").addClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.show_place_order=function(){o("#place_order").removeClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.on_show_new_methods=function(){this.payment_token_received?(this.show_place_order(),this.hide_payment_button()):(this.hide_place_order(),this.show_payment_button())},wc_stripe.CheckoutGateway.prototype.on_show_saved_methods=function(){this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.show_payment_button=function(){this.$button&&this.$button.show()},wc_stripe.CheckoutGateway.prototype.hide_payment_button=function(){this.$button&&this.$button.hide()},wc_stripe.CheckoutGateway.prototype.trigger_payment_method_selected=function(){this.on_payment_method_selected(null,o('[name="payment_method"]:checked').val())},wc_stripe.CheckoutGateway.prototype.on_payment_method_selected=function(t,e){e===this.gateway_id?this.payment_token_received||this.is_saved_method_selected()?(this.hide_payment_button(),this.show_place_order()):(this.show_payment_button(),this.hide_place_order()):(this.hide_payment_button(),e.indexOf("stripe_")<0&&this.show_place_order())},wc_stripe.CheckoutGateway.prototype.banner_enabled=function(){return"1"===this.params.banner_enabled},wc_stripe.CheckoutGateway.prototype.checkout_fields_valid=function(){if(["checkout","order_pay"].indexOf(this.get_page())<0)return!0;var t=!0;return(t=this.fields.validateFields("billing"))?this.needs_shipping()&&o("#ship-to-different-address-checkbox").is(":checked")?(t=this.fields.validateFields("shipping"))||this.submit_error(this.params.messages.required_field):(t=this.is_valid_checkout())||this.submit_error(this.params.messages.terms):this.submit_error(this.params.messages.required_field),t},wc_stripe.CheckoutGateway.prototype.cart_contains_subscription=function(){return"undefined"!=typeof wc_stripe_cart_contains_subscription&&!0===wc_stripe_cart_contains_subscription},wc_stripe.CheckoutGateway.prototype.set_save_payment_method=function(t){o('[name="'+this.gateway_id+'_save_source_key"]').prop("checked",t)},wc_stripe.ProductGateway=function(){this.message_container="div.product",o("form.cart").on("found_variation",this.found_variation.bind(this)),o("form.cart").on("reset_data",this.reset_variation_data.bind(this)),this.buttonWidth=o("form.cart div.quantity").outerWidth(!0)+o(".single_add_to_cart_button").outerWidth();var t=o(".single_add_to_cart_button").css("marginLeft");t&&(this.buttonWidth+=parseInt(t.replace("px",""))),o(this.container).css("max-width",this.buttonWidth+"px")},wc_stripe.ProductGateway.prototype.get_quantity=function(){return parseInt(o('[name="quantity"]').val())},wc_stripe.ProductGateway.prototype.set_rest_nonce=function(t,e){this.params.rest_nonce=e},wc_stripe.ProductGateway.prototype.found_variation=function(t,e){var i=this.get_gateway_data();i.product.price=e.display_price,i.needs_shipping=!e.is_virtual,i.product.variation=e,this.set_gateway_data(i)},wc_stripe.ProductGateway.prototype.reset_variation_data=function(){var t=this.get_product_data();t.variation=!1,this.set_product_data(t),this.disable_payment_button()},wc_stripe.ProductGateway.prototype.disable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!0).addClass("disabled")},wc_stripe.ProductGateway.prototype.enable_payment_button=function(){this.$button&&this.get_button().prop("disabled",!1).removeClass("disabled")},wc_stripe.ProductGateway.prototype.get_button=function(){return this.$button},wc_stripe.ProductGateway.prototype.is_variable_product=function(){return 0<o('[name="variation_id"]').length},wc_stripe.ProductGateway.prototype.variable_product_selected=function(){return!1!==this.get_product_data().variation},wc_stripe.ProductGateway.prototype.get_product_data=function(){return this.get_gateway_data().product},wc_stripe.ProductGateway.prototype.set_product_data=function(t){var e=this.get_gateway_data();e.product=t,this.set_gateway_data(e)},wc_stripe.ProductGateway.prototype.add_to_cart=function(){return new Promise(function(e,i){this.block(),o.ajax({url:this.params.routes.add_to_cart,method:"POST",dataType:"json",data:o.extend({},{product_id:this.get_product_data().id,variation_id:this.is_variable_product()?o('[name="variation_id"]').val():0,qty:o('[name="quantity"]').val(),payment_method:this.gateway_id,currency:this.get_currency(),page_id:this.get_page()},this.get_product_variations()),beforeSend:this.ajax_before_send.bind(this)}).done(function(t){this.unblock(),t.code?(this.submit_error(t.message),i(t)):(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),e(t.data))}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.ProductGateway.prototype.cart_calculation=function(t){return new Promise(function(e,i){o.ajax({url:this.params.routes.cart_calculation,method:"POST",dataType:"json",data:o.extend({},{product_id:this.get_product_data().id,variation_id:this.is_variable_product()&&t?t:0,qty:o('[name="quantity"]').val(),currency:this.get_currency(),payment_method:this.gateway_id},this.get_product_variations()),beforeSend:this.ajax_before_send.bind(this)}).done(function(t){t.code?(this.cart_calculation_error=!0,i(t)):(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),e(t.data))}.bind(this)).fail(function(){}.bind(this))}.bind(this))},wc_stripe.ProductGateway.prototype.get_product_variations=function(){var s={};return this.is_variable_product()&&o('.variations [name^="attribute_"]').each(function(t,e){var i=o(e),e=i.data("attribute_name")||i.attr("name");s[e]=i.val()}),s},wc_stripe.CartGateway=function(){this.message_container="div.woocommerce",o(document.body).on("updated_wc_div",this.updated_html.bind(this)),o(document.body).on("updated_cart_totals",this.updated_html.bind(this)),o(document.body).on("wc_cart_emptied",this.cart_emptied.bind(this))},wc_stripe.CartGateway.prototype.submit_error=function(t){this.submit_message(this.get_error_message(t))},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.CartGateway.prototype.cart_emptied=function(t){},wc_stripe.CartGateway.prototype.add_cart_totals_class=function(){o(".cart_totals").addClass("stripe_cart_gateway_active")},wc_stripe.GooglePay=function(){};var s={apiVersion:2,apiVersionMinor:0},n={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],assuranceDetailsRequired:!0}};wc_stripe.GooglePay.prototype.update_addresses=function(t){var e;t.paymentMethodData.info.billingAddress&&(e=t.paymentMethodData.info.billingAddress,this.is_current_page("checkout")&&this.is_valid_address(this.billing_address_object,"billing",["phone","email"])&&(e={phoneNumber:e.phoneNumber}),this.populate_billing_fields(e)),t.shippingAddress&&this.populate_shipping_fields(t.shippingAddress),t.email&&this.fields.set("email",t.email,"billing")},wc_stripe.GooglePay.prototype.map_address=function(t){return{city:t.locality,postcode:t.postalCode,state:t.administrativeArea,country:t.countryCode}},wc_stripe.GooglePay.prototype.update_payment_data=function(s){return new Promise(function(e,i){var t="default"==s.shippingOptionData.id?null:s.shippingOptionData.id;o.when(o.ajax({url:this.params.routes.payment_data,dataType:"json",method:"POST",data:{address:this.map_address(s.shippingAddress),shipping_method:t,page_id:this.get_page(),currency:this.get_currency()},beforeSend:this.ajax_before_send.bind(this)})).done(function(t){t.code?i(t.data.data):e(t.data)}.bind(this)).fail(function(){i()}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.on_payment_data_changed=function(i){return new Promise(function(e){this.update_payment_data(i).then(function(t){e(t.paymentRequestUpdate),this.set_selected_shipping_methods(t.shipping_methods),this.payment_data_updated(t,i)}.bind(this))["catch"](function(t){e(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.payment_data_updated=function(t){},wc_stripe.GooglePay.prototype.get_merchant_info=function(){var t={merchantId:this.params.merchant_id,merchantName:this.params.merchant_name};return"TEST"===this.params.environment&&delete t.merchantId,t},wc_stripe.GooglePay.prototype.get_payment_options=function(){var t,e={environment:this.params.environment,merchantInfo:this.get_merchant_info(),paymentDataCallbacks:{onPaymentAuthorized:function(){return new Promise(function(t){t({transactionState:"SUCCESS"})}.bind(this))}}};return this.needs_shipping()&&(t=this.get_shipping_prefix(),(!this.is_current_page("checkout")||this.is_valid_address(this.get_address_object(t),t,["email","phone"]))&&this.is_current_page("checkout")||(e.paymentDataCallbacks.onPaymentDataChanged=this.on_payment_data_changed.bind(this))),e},wc_stripe.GooglePay.prototype.build_payment_request=function(){var t=o.extend({},s,{emailRequired:this.fields.requestFieldInWallet("billing_email"),merchantInfo:this.get_merchant_info(),allowedPaymentMethods:[o.extend({type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":this.params.api_key}}},n)],shippingAddressRequired:function(){if(this.needs_shipping()){var t=this.get_shipping_prefix();if(this.is_current_page("checkout")&&!this.is_valid_address(this.get_address_object(t),t,["email","phone"])||!this.is_current_page("checkout"))return!0}return!1}.bind(this)(),transactionInfo:{countryCode:this.params.processing_country,currencyCode:this.get_currency(),totalPriceStatus:"ESTIMATED",totalPrice:this.get_total_price().toString(),displayItems:this.get_display_items(),totalPriceLabel:this.params.total_price_label}});return t.allowedPaymentMethods[0].parameters.billingAddressRequired=function(){if(this.is_current_page("checkout")){var t=this.billing_address_object=this.get_address_object("billing");return this.fields.requestFieldInWallet("billing_phone")||!this.is_valid_address(t,"billing",["email"])?!0:!1}return!0}.bind(this)(),t.allowedPaymentMethods[0].parameters.billingAddressRequired&&(t.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:this.fields.requestFieldInWallet("billing_phone")}),t.shippingAddressRequired?(t.shippingAddressParameters={},t.shippingOptionRequired=!0,t.shippingOptionParameters={shippingOptions:this.get_shipping_options()},t.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]):t.callbackIntents=["PAYMENT_AUTHORIZATION"],this.payment_request_options=t},wc_stripe.GooglePay.prototype.createPaymentsClient=function(){this.paymentsClient=new google.payments.api.PaymentsClient(this.get_payment_options())},wc_stripe.GooglePay.prototype.isReadyToPay=function(){return new Promise(function(t){var e=o.extend({},s);e.allowedPaymentMethods=[n],this.paymentsClient.isReadyToPay(e).then(function(){this.can_pay=!0,this.create_button(),t()}.bind(this))["catch"](function(t){this.submit_error(t)}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=o(this.paymentsClient.createButton({onClick:this.start.bind(this),buttonColor:this.params.button_color,buttonType:this.params.button_style})),this.$button.addClass("gpay-button-container")},wc_stripe.GooglePay.prototype.start=function(){this.createPaymentsClient(),this.paymentsClient.loadPaymentData(this.build_payment_request()).then(function(t){var e=JSON.parse(t.paymentMethodData.tokenizationData.token);this.update_addresses(t),this.stripe.createPaymentMethod({type:"card",card:{token:e.id},billing_details:this.get_billing_details()}).then(function(t){if(t.error)return this.submit_error(t.error);this.on_token_received(t.paymentMethod)}.bind(this))}.bind(this))["catch"](function(t){"CANCELED"!==t.statusCode&&(t.statusMessage&&-1<t.statusMessage.indexOf("paymentDataRequest.callbackIntent")?this.submit_error_code("DEVELOPER_ERROR_WHITELIST"):this.submit_error(t.statusMessage))}.bind(this))},wc_stripe.ApplePay=function(){},wc_stripe.ApplePay.prototype.initialize=function(){this.createPaymentRequest(),this.canMakePayment()},wc_stripe.ApplePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=o(this.params.button),this.$button.on("click",this.start.bind(this)),this.append_button()},wc_stripe.ApplePay.prototype.canMakePayment=function(){return new Promise(function(e){this.paymentRequest.canMakePayment().then(function(t){t&&t.applePay&&(this.can_pay=!0,this.create_button(),o(this.container).show(),e(t))}.bind(this))}.bind(this))},wc_stripe.ApplePay.prototype.start=function(t){t.preventDefault(),this.paymentRequest.update(this.get_payment_request_update({total:{pending:!1}})),this.paymentRequest.show()},wc_stripe.PaymentRequest=function(){},wc_stripe.PaymentRequest.prototype.initialize=function(){this.createPaymentRequest(),this.createPaymentRequestButton(),this.canMakePayment(),this.paymentRequestButton.on("click",this.button_click.bind(this))},wc_stripe.PaymentRequest.prototype.button_click=function(t){},wc_stripe.PaymentRequest.prototype.createPaymentRequestButton=function(){this.paymentRequestButton&&this.paymentRequestButton.destroy(),this.paymentRequestButton=this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest,style:{paymentRequestButton:{type:this.params.button.type,theme:this.params.button.theme,height:this.params.button.height}}})},wc_stripe.PaymentRequest.prototype.canMakePayment=function(){return new Promise(function(e){this.paymentRequest.canMakePayment().then(function(t){t&&!t.applePay&&(this.can_pay=!0,this.create_button(),o(this.container).show(),e(t))}.bind(this))}.bind(this))},wc_stripe.PaymentRequest.prototype.create_button=function(){this.paymentRequestButton.mount("#wc-stripe-payment-request-container")},wc_stripe.CheckoutFields=function(t,e){this.params=t,this.page=e,this.session_values=this.supportsSessionStorage()&&sessionStorage.getItem("wc_stripe_checkout_fields")?JSON.parse(sessionStorage.getItem("wc_stripe_checkout_fields")):{},this.fields=new Map(Object.keys(this.params).map(function(t){return null===this.params[t].value&&(t in this.session_values&&null!==this.session_values[t]?this.params[t].value=this.session_values[t]:this.params[t].value=""),[t,this.params[t].value]}.bind(this))),("checkout"===e||"cart"===e&&o(document.body).is(".woocommerce-checkout"))&&(o("form.checkout").on("change",".input-text, select",this.onChange.bind(this)),o("form.checkout").on("change",'[name="ship_to_different_address"]',this.on_ship_to_address_change.bind(this)),this.init_i18n(),o('[name="ship_to_different_address"]').is(":checked")?this.update_required_fields(o("#shipping_country").val(),"shipping_country"):this.update_required_fields(o("#billing_country").val(),"billing_country"))},wc_stripe.CheckoutFields.prototype.supportsSessionStorage=function(){return"sessionStorage"in a&&null!==a.sessionStorage&&["getItem","setItem"].reduce(function(t,e){return t&&e in sessionStorage}.bind(this),!0)},wc_stripe.CheckoutFields.prototype.init_i18n=function(){"undefined"!=typeof wc_address_i18n_params?this.locales=JSON.parse(wc_address_i18n_params.locale.replace(/&quot;/g,'"')):this.locales=null},wc_stripe.CheckoutFields.prototype.onChange=function(t){try{var e=t.currentTarget.name,i=t.currentTarget.value;this.fields.set(e,i),"billing_country"!==e&&"shipping_country"!==e||this.update_required_fields(i,e),this.supportsSessionStorage()&&sessionStorage.setItem("wc_stripe_checkout_fields",JSON.stringify(this.toJson()))}catch(s){console.log(s)}},wc_stripe.CheckoutFields.prototype.update_required_fields=function(t,e){if(this.locales){var i,s=-1<e.indexOf("billing_")?"billing_":"shipping_",t="undefined"!=typeof this.locales[t]?this.locales[t]:this.locales["default"],a=o.extend(!0,{},this.locales["default"],t);for(i in a){var n=s+i;this.params[n]&&(this.params[n]=o.extend(!0,{},this.params[n],a[i]))}}},wc_stripe.CheckoutFields.prototype.on_ship_to_address_change=function(t){o(t.currentTarget).is(":checked")&&this.update_required_fields(o("#shipping_country").val(),"shipping_country")},wc_stripe.CheckoutFields.prototype.requestFieldInWallet=function(t){return"checkout"===this.page?this.required(t)&&this.isEmpty(t):"order_pay"!==this.page&&this.required(t)},wc_stripe.CheckoutFields.prototype.set=function(t,e,i){this[t]&&"function"==typeof this[t]?this[t]().set.call(this,e,i):this.fields.set(t,e)},wc_stripe.CheckoutFields.prototype.get=function(t,e){var i;return this[t]&&"function"==typeof this[t]?i=this[t]().get.call(this,e):null!=(i=this.fields.get(t))&&""!==i||void 0!==e&&(i=e),void 0===i?"":i},wc_stripe.CheckoutFields.prototype.required=function(t){return!(!this.params[t]||"undefined"==typeof this.params[t].required)&&this.params[t].required},wc_stripe.CheckoutFields.prototype.isEmpty=function(t){if(this.fields.has(t)){t=this.fields.get(t);return null==t||"string"==typeof t&&0===t.trim().length}return!0},wc_stripe.CheckoutFields.prototype.isValid=function(t){if(this[t]&&"function"==typeof this[t])return this[t]().isValid.apply(this,Array.prototype.slice.call(arguments,1))},wc_stripe.CheckoutFields.prototype.first_name=function(){return{set:function(t,e){this.fields.set(e+"_first_name",t)},get:function(t){return this.fields.get(t+"_first_name")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.last_name=function(){return{set:function(t,e){this.fields.set(e+"_last_name",t)},get:function(t){return this.fields.get(t+"_last_name")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.address_1=function(){return{set:function(t,e){this.fields.set(e+"_address_1",t)},get:function(t){return this.fields.get(t+"_address_1")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.address_2=function(){return{set:function(t,e){this.fields.set(e+"_address_2",t)},get:function(t){return this.fields.get(t+"_address_2")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.name=function(){return{set:function(t,e){t=t.split(" ");0<t.length&&this.fields.set(e+"_first_name",t[0]),1<t.length&&this.fields.set(e+"_last_name",t[1])},get:function(t){return this.fields.get(t+"_first_name")+" "+this.fields.get(t+"_last_name")}}},wc_stripe.CheckoutFields.prototype.email=function(){return{set:function(t,e){this.fields.set(e+"_email",t)},get:function(t){return this.fields.get(t+"_email")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.phone=function(){return{set:function(t,e){this.fields.set(e+"_phone",t)},get:function(t){return this.fields.get(t+"_phone")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.country=function(){return{set:function(t,e){this.fields.set(e+"_country",t)},get:function(t){return this.fields.get(t+"_country")},isValid:function(t){return"string"==typeof t&&2===t.length}}},wc_stripe.CheckoutFields.prototype.state=function(){return{set:function(i,t){2<(i=i.toUpperCase()).length&&"checkout"===this.page&&o("#"+t+"_state option").each(function(){var t=o(this),e=t.text().toUpperCase();i===e&&(i=t.val())}),this.fields.set(t+"_state",i)},get:function(t){return this.fields.get(t+"_state")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.city=function(){return{set:function(t,e){this.fields.set(e+"_city",t)},get:function(t){return this.fields.get(t+"_city")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.postcode=function(){return{set:function(t,e){this.fields.set(e+"_postcode",t)},get:function(t){return this.fields.get(t+"_postcode")},isValid:function(t){return"string"==typeof t&&0<t.length}}},wc_stripe.CheckoutFields.prototype.recipient=function(){return wc_stripe.CheckoutFields.prototype.name.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.payerName=function(){return wc_stripe.CheckoutFields.prototype.name.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.payerEmail=function(){return wc_stripe.CheckoutFields.prototype.email.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.payerPhone=function(){return wc_stripe.CheckoutFields.prototype.phone.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.phoneNumber=function(){return wc_stripe.CheckoutFields.prototype.phone.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.countryCode=function(){return wc_stripe.CheckoutFields.prototype.country.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.address1=function(){return wc_stripe.CheckoutFields.prototype.address_1.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.address2=function(){return wc_stripe.CheckoutFields.prototype.address_2.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.line1=function(){return wc_stripe.CheckoutFields.prototype.address_1.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.line2=function(){return wc_stripe.CheckoutFields.prototype.address_2.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.addressLine=function(){return{set:function(t,e){0<t.length&&this.fields.set(e+"_address_1",t[0]),1<t.length&&this.fields.set(e+"_address_2",t[1])},get:function(t){return[this.fields.get(t+"_address_1"),this.fields.get(t+"_address_2")]},isValid:function(t){return 0<t.length&&("string"==typeof t[0]&&0<t[0].length)}}},wc_stripe.CheckoutFields.prototype.region=function(){return wc_stripe.CheckoutFields.prototype.state.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.administrativeArea=function(){return wc_stripe.CheckoutFields.prototype.state.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.locality=function(){return wc_stripe.CheckoutFields.prototype.city.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.postal_code=function(){return wc_stripe.CheckoutFields.prototype.postcode.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.postalCode=function(){return wc_stripe.CheckoutFields.prototype.postcode.apply(this,arguments)},wc_stripe.CheckoutFields.prototype.toJson=function(){var i={};return this.fields.forEach(function(t,e){i[e]=t}),i},wc_stripe.CheckoutFields.prototype.toFormFields=function(t){var i=[];this.fields.forEach(function(t,e){e='[name="'+e+'"]';o(e).length&&""!==t&&(o(e).val()!==t&&o(e).is("select")&&i.push(e),o(e).val(t))}),0<i.length&&o(i.join(",")).trigger("change"),void 0!==t&&o(document.body).trigger("update_checkout",t)},wc_stripe.CheckoutFields.prototype.validateFields=function(t){for(var e in this.params){var i=this.params[e];if(-1<e.indexOf(t)&&i.required&&o("#"+e).length&&o("#"+e).is(":visible")){i=o("#"+e).val();if(null==i||0===i.length)return!1}}return!0};try{i=Stripe(wc_stripe_params_v3.api_key,"test"===wc_stripe_params_v3.mode&&""===wc_stripe_params_v3.account?{}:{stripeAccount:wc_stripe_params_v3.account})}catch(t){return a.alert(t),console.log(t)}var r=new wc_stripe.CheckoutFields(wc_stripe_checkout_fields,wc_stripe_params_v3.page)}(window,jQuery);
i18n/languages/woo-stripe-payment.pot CHANGED
@@ -2,14 +2,14 @@
2
  # This file is distributed under the same license as the Stripe For WooCommerce plugin.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Stripe For WooCommerce 3.2.10\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2021-01-03T01:20:06+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: woo-stripe-payment\n"
@@ -103,16 +103,16 @@ msgstr ""
103
  msgid "Order %s"
104
  msgstr ""
105
 
106
- #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:361
107
  msgid "Gateway will appear when store currency is <strong>%s</strong>"
108
  msgstr ""
109
 
110
- #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:364
111
  msgid " & billing country is not <strong>%s</strong>"
112
  msgstr ""
113
 
114
- #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:366
115
- #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:369
116
  msgid " & billing country is <strong>%s</strong>"
117
  msgstr ""
118
 
@@ -141,7 +141,7 @@ msgid "Error saving payment method. Reason: %s"
141
  msgstr ""
142
 
143
  #: includes/abstract/abstract-wc-payment-gateway-stripe.php:538
144
- #: includes/wc-stripe-webhook-functions.php:203
145
  msgid "Order refunded in Stripe. Amount: %s"
146
  msgstr ""
147
 
@@ -213,7 +213,7 @@ msgid "Error saving payment method for subscription. Reason: %s"
213
  msgstr ""
214
 
215
  #: includes/abstract/abstract-wc-payment-gateway-stripe.php:1191
216
- #: includes/abstract/abstract-wc-stripe-payment.php:227
217
  msgid "Order %1$s from %2$s"
218
  msgstr ""
219
 
@@ -284,7 +284,7 @@ msgstr ""
284
  msgid "Transaction Id cannot be empty."
285
  msgstr ""
286
 
287
- #: includes/abstract/abstract-wc-stripe-payment.php:294
288
  #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:123
289
  msgid "Error processing payment. Reason: %s"
290
  msgstr ""
@@ -752,11 +752,16 @@ msgstr ""
752
  msgid "Quantity must be greater than zero."
753
  msgstr ""
754
 
755
- #: includes/controllers/class-wc-stripe-controller-checkout.php:236
756
- msgid "Some required fields were missing. Please click %1$shere%2$s to complete your payment."
757
  msgstr ""
758
 
759
- #: includes/controllers/class-wc-stripe-controller-checkout.php:285
 
 
 
 
 
760
  msgid "Please review your order details then click Place Order."
761
  msgstr ""
762
 
2
  # This file is distributed under the same license as the Stripe For WooCommerce plugin.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Stripe For WooCommerce 3.2.11\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2021-01-14T17:31:35+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: woo-stripe-payment\n"
103
  msgid "Order %s"
104
  msgstr ""
105
 
106
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:362
107
  msgid "Gateway will appear when store currency is <strong>%s</strong>"
108
  msgstr ""
109
 
110
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:365
111
  msgid " & billing country is not <strong>%s</strong>"
112
  msgstr ""
113
 
114
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:367
115
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:370
116
  msgid " & billing country is <strong>%s</strong>"
117
  msgstr ""
118
 
141
  msgstr ""
142
 
143
  #: includes/abstract/abstract-wc-payment-gateway-stripe.php:538
144
+ #: includes/wc-stripe-webhook-functions.php:217
145
  msgid "Order refunded in Stripe. Amount: %s"
146
  msgstr ""
147
 
213
  msgstr ""
214
 
215
  #: includes/abstract/abstract-wc-payment-gateway-stripe.php:1191
216
+ #: includes/abstract/abstract-wc-stripe-payment.php:228
217
  msgid "Order %1$s from %2$s"
218
  msgstr ""
219
 
284
  msgid "Transaction Id cannot be empty."
285
  msgstr ""
286
 
287
+ #: includes/abstract/abstract-wc-stripe-payment.php:295
288
  #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:123
289
  msgid "Error processing payment. Reason: %s"
290
  msgstr ""
752
  msgid "Quantity must be greater than zero."
753
  msgstr ""
754
 
755
+ #: includes/controllers/class-wc-stripe-controller-checkout.php:123
756
+ msgid "Invalid order ID."
757
  msgstr ""
758
 
759
+ #: includes/controllers/class-wc-stripe-controller-checkout.php:126
760
+ msgid "Invalid order key."
761
+ msgstr ""
762
+
763
+ #: includes/controllers/class-wc-stripe-controller-checkout.php:245
764
+ #: includes/controllers/class-wc-stripe-controller-checkout.php:291
765
  msgid "Please review your order details then click Place Order."
766
  msgstr ""
767
 
includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php CHANGED
@@ -192,7 +192,7 @@ abstract class WC_Payment_Gateway_Stripe_Local_Payment extends WC_Payment_Gatewa
192
  'local_payment_type' => $this->local_payment_type,
193
  'return_url' => add_query_arg(
194
  array(
195
- '_payment_nonce' => wp_create_nonce( 'local-payment' ),
196
  'wc-stripe-local-gateway' => $this->id,
197
  ),
198
  wc_get_checkout_url()
@@ -294,7 +294,8 @@ abstract class WC_Payment_Gateway_Stripe_Local_Payment extends WC_Payment_Gatewa
294
 
295
  return add_query_arg(
296
  array(
297
- 'order_key' => $order->get_order_key(),
 
298
  'wc-stripe-local-gateway' => $this->id,
299
  ),
300
  $url
192
  'local_payment_type' => $this->local_payment_type,
193
  'return_url' => add_query_arg(
194
  array(
195
+ 'key' => wp_create_nonce( 'local-payment' ),
196
  'wc-stripe-local-gateway' => $this->id,
197
  ),
198
  wc_get_checkout_url()
294
 
295
  return add_query_arg(
296
  array(
297
+ 'key' => $order->get_order_key(),
298
+ 'order_id' => $order->get_id(),
299
  'wc-stripe-local-gateway' => $this->id,
300
  ),
301
  $url
includes/abstract/abstract-wc-stripe-payment.php CHANGED
@@ -130,7 +130,8 @@ abstract class WC_Stripe_Payment {
130
  /**
131
  * @param array
132
  * @param WC_Stripe_Payment
133
- * @param WC_Order
 
134
  *
135
  * @since 3.2.10
136
  */
@@ -141,7 +142,7 @@ abstract class WC_Stripe_Payment {
141
  'order_id' => $order->get_id(),
142
  'created_via' => 'woocommerce'
143
  )
144
- ), $this, $order );
145
  $result = $this->gateway->refunds->mode( wc_stripe_order_mode( $order ) )->create( $args );
146
  if ( ! is_wp_error( $result ) ) {
147
  return true;
130
  /**
131
  * @param array
132
  * @param WC_Stripe_Payment
133
+ * @param WC_Order $order
134
+ * @param float $amount
135
  *
136
  * @since 3.2.10
137
  */
142
  'order_id' => $order->get_id(),
143
  'created_via' => 'woocommerce'
144
  )
145
+ ), $this, $order, $amount );
146
  $result = $this->gateway->refunds->mode( wc_stripe_order_mode( $order ) )->create( $args );
147
  if ( ! is_wp_error( $result ) ) {
148
  return true;
includes/class-stripe.php CHANGED
@@ -25,7 +25,7 @@ class WC_Stripe_Manager {
25
  *
26
  * @var string
27
  */
28
- public $version = '3.2.10';
29
 
30
  /**
31
  *
25
  *
26
  * @var string
27
  */
28
+ public $version = '3.2.11';
29
 
30
  /**
31
  *
includes/class-wc-stripe-constants.php CHANGED
@@ -1,46 +1,51 @@
1
- <?php
2
- defined( 'ABSPATH' ) || exit();
3
-
4
- /**
5
- *
6
- * @since 3.1.0
7
- * @author Payment Plugins
8
- *
9
- */
10
- class WC_Stripe_Constants {
11
-
12
- const CUSTOMER_ID = '_wc_stripe_customer';
13
-
14
- const PAYMENT_METHOD_TOKEN = '_payment_method_token';
15
-
16
- const PAYMENT_INTENT_ID = '_payment_intent_id';
17
-
18
- const PAYMENT_INTENT = '_payment_intent';
19
-
20
- const MODE = '_wc_stripe_mode';
21
-
22
- const CHARGE_STATUS = '_wc_stripe_charge_status';
23
-
24
- const SOURCE_ID = '_stripe_source_id';
25
-
26
- const STRIPE_INTENT_ID = '_stripe_intent_id';
27
-
28
- const STRIPE_CUSTOMER_ID = '_stripe_customer_id';
29
-
30
- const SUCCESS = 'success';
31
-
32
- const FAILURE = 'failure';
33
-
34
- const WOOCOMMERCE_STRIPE_ORDER_PAY = 'WOOCOMMERCE_STRIPE_ORDER_PAY';
35
-
36
- const PRODUCT_GATEWAY_ORDER = '_stripe_gateway_order';
37
-
38
- const BUTTON_POSITION = '_stripe_button_position';
39
-
40
- /**
41
- *
42
- * @since 3.1.3
43
- * @var unknown
44
- */
45
- const REDIRECT_HANDLER = 'redirect_handler';
46
- }
 
 
 
 
 
1
+ <?php
2
+ defined( 'ABSPATH' ) || exit();
3
+
4
+ /**
5
+ *
6
+ * @since 3.1.0
7
+ * @author Payment Plugins
8
+ *
9
+ */
10
+ class WC_Stripe_Constants {
11
+
12
+ const CUSTOMER_ID = '_wc_stripe_customer';
13
+
14
+ const PAYMENT_METHOD_TOKEN = '_payment_method_token';
15
+
16
+ const PAYMENT_INTENT_ID = '_payment_intent_id';
17
+
18
+ const PAYMENT_INTENT = '_payment_intent';
19
+
20
+ const MODE = '_wc_stripe_mode';
21
+
22
+ const CHARGE_STATUS = '_wc_stripe_charge_status';
23
+
24
+ const SOURCE_ID = '_stripe_source_id';
25
+
26
+ const STRIPE_INTENT_ID = '_stripe_intent_id';
27
+
28
+ const STRIPE_CUSTOMER_ID = '_stripe_customer_id';
29
+
30
+ const SUCCESS = 'success';
31
+
32
+ const FAILURE = 'failure';
33
+
34
+ const WOOCOMMERCE_STRIPE_ORDER_PAY = 'WOOCOMMERCE_STRIPE_ORDER_PAY';
35
+
36
+ const PRODUCT_GATEWAY_ORDER = '_stripe_gateway_order';
37
+
38
+ const BUTTON_POSITION = '_stripe_button_position';
39
+
40
+ /**
41
+ *
42
+ * @since 3.1.3
43
+ * @var unknown
44
+ */
45
+ const REDIRECT_HANDLER = 'redirect_handler';
46
+
47
+ /**
48
+ * @since 3.2.11
49
+ */
50
+ const PROCESSING_PAYMENT = 'processing_payment';
51
+ }
includes/class-wc-stripe-payment-intent.php CHANGED
@@ -76,13 +76,7 @@ class WC_Stripe_Payment_Intent extends WC_Stripe_Payment {
76
  );
77
  }
78
  }
79
- if ( $intent->status === 'requires_source_action' || $intent->status === 'requires_action' ) {
80
- return (object) array(
81
- 'complete_payment' => false,
82
- 'redirect' => $this->payment_method->get_payment_intent_checkout_url( $intent, $order ),
83
- );
84
- }
85
- if ( $intent->status === 'requires_source' || $intent->status === 'requires_payment_method' ) {
86
  return (object) array(
87
  'complete_payment' => false,
88
  'redirect' => $this->payment_method->get_payment_intent_checkout_url( $intent, $order ),
@@ -173,7 +167,7 @@ class WC_Stripe_Payment_Intent extends WC_Stripe_Payment {
173
  * @param WC_Order $order
174
  */
175
  public function can_update_payment_intent( $order ) {
176
- if ( ! is_checkout() || defined( WC_Stripe_Constants::REDIRECT_HANDLER ) ) {
177
  return false;
178
  }
179
  $intent = $order->get_meta( WC_Stripe_Constants::PAYMENT_INTENT );
76
  );
77
  }
78
  }
79
+ if ( in_array( $intent->status, array( 'requires_action', 'requires_payment_method', 'requires_source_action', 'requires_source' ), true ) ) {
 
 
 
 
 
 
80
  return (object) array(
81
  'complete_payment' => false,
82
  'redirect' => $this->payment_method->get_payment_intent_checkout_url( $intent, $order ),
167
  * @param WC_Order $order
168
  */
169
  public function can_update_payment_intent( $order ) {
170
+ if ( ! is_checkout() || defined( WC_Stripe_Constants::REDIRECT_HANDLER ) || defined( WC_Stripe_Constants::PROCESSING_PAYMENT ) ) {
171
  return false;
172
  }
173
  $intent = $order->get_meta( WC_Stripe_Constants::PAYMENT_INTENT );
includes/class-wc-stripe-redirect-handler.php CHANGED
@@ -1,98 +1,98 @@
1
- <?php
2
- defined( 'ABSPATH' ) || exit();
3
-
4
- /**
5
- *
6
- * @author PaymentPlugins
7
- * @package Stripe/Classes
8
- *
9
- */
10
- class WC_Stripe_Redirect_Handler {
11
-
12
- public static function init() {
13
- add_action( 'template_redirect', array( __CLASS__, 'local_payment_redirect' ) );
14
- add_action( 'get_header', array( __CLASS__, 'maybe_restore_cart' ), 100 );
15
- }
16
-
17
- /**
18
- * Check if this request is for a local payment redirect.
19
- */
20
- public static function local_payment_redirect() {
21
- if ( isset( $_GET['wc-stripe-local-gateway'], $_GET['order_key'] ) ) {
22
- self::process_redirect();
23
- }
24
- }
25
-
26
- /**
27
- */
28
- public static function process_redirect() {
29
- if ( isset( $_GET['source'] ) ) {
30
- $result = WC_Stripe_Gateway::load()->sources->retrieve( wc_clean( $_GET['source'] ) );
31
- $client_secret = $_GET['client_secret'];
32
- } else {
33
- $result = WC_Stripe_Gateway::load()->paymentIntents->retrieve( wc_clean( $_GET['payment_intent'] ) );
34
- $client_secret = $_GET['payment_intent_client_secret'];
35
- }
36
- if ( is_wp_error( $result ) ) {
37
- wc_add_notice( sprintf( __( 'Error retrieving payment source. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ), 'error' );
38
- } elseif ( ! hash_equals( $client_secret, $result->client_secret ) ) {
39
- wc_add_notice( __( 'This request is invalid. Please try again.', 'woo-stripe-payment' ), 'error' );
40
- } else {
41
- define( WC_Stripe_Constants::REDIRECT_HANDLER, true );
42
- $order_id = $result->metadata['order_id'];
43
- $order = wc_get_order( wc_stripe_filter_order_id( $order_id, $result ) );
44
-
45
- /**
46
- *
47
- * @var WC_Payment_Gateway_Stripe_Local_Payment $payment_method
48
- */
49
- $payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
50
- $redirect = $order->get_checkout_order_received_url();
51
-
52
- if ( in_array( $result->status, array( 'requires_action', 'pending' ) ) ) {
53
- wc_add_notice( __( 'Payment for order was not completed.', 'woo-stripe-payment' ), 'error' );
54
-
55
- return;
56
- } elseif ( in_array( $result->status, array( 'requires_payment_method', 'failed' ) ) ) {
57
- wc_add_notice( __( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
58
- if ( $result instanceof \Stripe\PaymentIntent ) {
59
- $order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, $result->jsonSerialize() );
60
- } else {
61
- $order->delete_meta_data( WC_Stripe_Constants::SOURCE_ID );
62
- }
63
- $order->update_status( 'failed', __( 'Payment authorization failed.', 'woo-stripe-payment' ) );
64
-
65
- return;
66
- } elseif ( 'chargeable' === $result->status ) {
67
- if ( ! $payment_method->has_order_lock( $order ) && ! $order->get_transaction_id() ) {
68
- $payment_method->set_order_lock( $order );
69
- $payment_method->set_new_source_token( $result->id );
70
- $result = $payment_method->process_payment( $order_id );
71
- // we don't release the order lock so there aren't conflicts with the source.chargeable webhook
72
- if ( $result['result'] === 'success' ) {
73
- $redirect = $result['redirect'];
74
- }
75
- }
76
- } elseif ( 'succeeded' == $result->status ) {
77
- if ( ! $payment_method->has_order_lock( $order ) ) {
78
- $payment_method->set_order_lock( $order );
79
- $result = $payment_method->process_payment( $order_id );
80
- if ( $result['result'] === 'success' ) {
81
- $redirect = $result['redirect'];
82
- }
83
- }
84
- }
85
- wp_safe_redirect( $redirect );
86
- exit();
87
- }
88
- }
89
-
90
- public static function maybe_restore_cart() {
91
- global $wp;
92
- if ( isset( $wp->query_vars['order-received'] ) && isset( $_GET['wc_stripe_product_checkout'] ) ) {
93
- add_action( 'woocommerce_cart_emptied', 'wc_stripe_restore_cart_after_product_checkout' );
94
- }
95
- }
96
- }
97
-
98
- WC_Stripe_Redirect_Handler::init();
1
+ <?php
2
+ defined( 'ABSPATH' ) || exit();
3
+
4
+ /**
5
+ *
6
+ * @author PaymentPlugins
7
+ * @package Stripe/Classes
8
+ *
9
+ */
10
+ class WC_Stripe_Redirect_Handler {
11
+
12
+ public static function init() {
13
+ add_action( 'template_redirect', array( __CLASS__, 'local_payment_redirect' ) );
14
+ add_action( 'get_header', array( __CLASS__, 'maybe_restore_cart' ), 100 );
15
+ }
16
+
17
+ /**
18
+ * Check if this request is for a local payment redirect.
19
+ */
20
+ public static function local_payment_redirect() {
21
+ if ( isset( $_GET['wc-stripe-local-gateway'], $_GET['key'] ) ) {
22
+ self::process_redirect();
23
+ }
24
+ }
25
+
26
+ /**
27
+ */
28
+ public static function process_redirect() {
29
+ if ( isset( $_GET['source'] ) ) {
30
+ $result = WC_Stripe_Gateway::load()->sources->retrieve( wc_clean( $_GET['source'] ) );
31
+ $client_secret = $_GET['client_secret'];
32
+ } else {
33
+ $result = WC_Stripe_Gateway::load()->paymentIntents->retrieve( wc_clean( $_GET['payment_intent'] ) );
34
+ $client_secret = $_GET['payment_intent_client_secret'];
35
+ }
36
+ if ( is_wp_error( $result ) ) {
37
+ wc_add_notice( sprintf( __( 'Error retrieving payment source. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message() ), 'error' );
38
+ } elseif ( ! hash_equals( $client_secret, $result->client_secret ) ) {
39
+ wc_add_notice( __( 'This request is invalid. Please try again.', 'woo-stripe-payment' ), 'error' );
40
+ } else {
41
+ define( WC_Stripe_Constants::REDIRECT_HANDLER, true );
42
+ $order_id = $result->metadata['order_id'];
43
+ $order = wc_get_order( wc_stripe_filter_order_id( $order_id, $result ) );
44
+
45
+ /**
46
+ *
47
+ * @var WC_Payment_Gateway_Stripe_Local_Payment $payment_method
48
+ */
49
+ $payment_method = WC()->payment_gateways()->payment_gateways()[ $order->get_payment_method() ];
50
+ $redirect = $order->get_checkout_order_received_url();
51
+
52
+ if ( in_array( $result->status, array( 'requires_action', 'pending' ) ) ) {
53
+ wc_add_notice( __( 'Payment for order was not completed.', 'woo-stripe-payment' ), 'error' );
54
+
55
+ return;
56
+ } elseif ( in_array( $result->status, array( 'requires_payment_method', 'failed' ) ) ) {
57
+ wc_add_notice( __( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
58
+ if ( $result instanceof \Stripe\PaymentIntent ) {
59
+ $order->update_meta_data( WC_Stripe_Constants::PAYMENT_INTENT, $result->jsonSerialize() );
60
+ } else {
61
+ $order->delete_meta_data( WC_Stripe_Constants::SOURCE_ID );
62
+ }
63
+ $order->update_status( 'failed', __( 'Payment authorization failed.', 'woo-stripe-payment' ) );
64
+
65
+ return;
66
+ } elseif ( 'chargeable' === $result->status ) {
67
+ if ( ! $payment_method->has_order_lock( $order ) && ! $order->get_transaction_id() ) {
68
+ $payment_method->set_order_lock( $order );
69
+ $payment_method->set_new_source_token( $result->id );
70
+ $result = $payment_method->process_payment( $order_id );
71
+ // we don't release the order lock so there aren't conflicts with the source.chargeable webhook
72
+ if ( $result['result'] === 'success' ) {
73
+ $redirect = $result['redirect'];
74
+ }
75
+ }
76
+ } elseif ( 'succeeded' == $result->status ) {
77
+ if ( ! $payment_method->has_order_lock( $order ) ) {
78
+ $payment_method->set_order_lock( $order );
79
+ $result = $payment_method->process_payment( $order_id );
80
+ if ( $result['result'] === 'success' ) {
81
+ $redirect = $result['redirect'];
82
+ }
83
+ }
84
+ }
85
+ wp_safe_redirect( $redirect );
86
+ exit();
87
+ }
88
+ }
89
+
90
+ public static function maybe_restore_cart() {
91
+ global $wp;
92
+ if ( isset( $wp->query_vars['order-received'] ) && isset( $_GET['wc_stripe_product_checkout'] ) ) {
93
+ add_action( 'woocommerce_cart_emptied', 'wc_stripe_restore_cart_after_product_checkout' );
94
+ }
95
+ }
96
+ }
97
+
98
+ WC_Stripe_Redirect_Handler::init();
includes/controllers/class-wc-stripe-controller-cart.php CHANGED
@@ -235,14 +235,12 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
235
  */
236
  $gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
237
 
238
- $product_id = $request->get_param( 'product_id' );
239
- $qty = $request->get_param( 'qty' );
240
- $variation_id = $request->get_param( 'variation_id' );
241
 
242
  // stash cart so clean calculation can be performed.
243
  wc_stripe_stash_cart( WC()->cart, false );
244
 
245
- if ( WC()->cart->add_to_cart( $product_id, $qty, $variation_id ) == false ) {
246
  return new WP_Error( 'cart-error', $this->get_error_messages(), array( 'status' => 200 ) );
247
  } else {
248
  $response = rest_ensure_response(
@@ -280,13 +278,11 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
280
  public function cart_calculation( $request ) {
281
  wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
282
 
283
- $product_id = $request->get_param( 'product_id' );
284
- $qty = $request->get_param( 'qty' );
285
- $variation_id = $request->get_param( 'variation_id' ) == null ? 0 : $request->get_param( 'variation_id' );
286
 
287
  wc_stripe_stash_cart( WC()->cart, false );
288
 
289
- if ( WC()->cart->add_to_cart( $product_id, $qty, $variation_id ) ) {
290
  $payment_method = $request->get_param( 'payment_method' );
291
  /**
292
  *
@@ -363,4 +359,31 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
363
 
364
  return false;
365
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  }
235
  */
236
  $gateway = WC()->payment_gateways()->payment_gateways()[ $payment_method ];
237
 
238
+ list( $product_id, $qty, $variation_id, $variation ) = $this->get_add_to_cart_args( $request );
 
 
239
 
240
  // stash cart so clean calculation can be performed.
241
  wc_stripe_stash_cart( WC()->cart, false );
242
 
243
+ if ( WC()->cart->add_to_cart( $product_id, $qty, $variation_id, $variation ) == false ) {
244
  return new WP_Error( 'cart-error', $this->get_error_messages(), array( 'status' => 200 ) );
245
  } else {
246
  $response = rest_ensure_response(
278
  public function cart_calculation( $request ) {
279
  wc_maybe_define_constant( 'WOOCOMMERCE_CART', true );
280
 
281
+ list( $product_id, $qty, $variation_id, $variation ) = $this->get_add_to_cart_args( $request );
 
 
282
 
283
  wc_stripe_stash_cart( WC()->cart, false );
284
 
285
+ if ( WC()->cart->add_to_cart( $product_id, $qty, $variation_id, $variation ) ) {
286
  $payment_method = $request->get_param( 'payment_method' );
287
  /**
288
  *
359
 
360
  return false;
361
  }
362
+
363
+ /**
364
+ * Return an array of arguments used to add a product to the cart.
365
+ *
366
+ * @param WP_REST_Request $request
367
+ *
368
+ * @return array
369
+ * @since 3.2.11
370
+ */
371
+ private function get_add_to_cart_args( $request ) {
372
+ $args = array(
373
+ $request->get_param( 'product_id' ),
374
+ $request->get_param( 'qty' ),
375
+ $request->get_param( 'variation_id' )
376
+ );
377
+ $variation = array();
378
+ if ( $request->get_param( 'variation_id' ) ) {
379
+ foreach ( $request->get_params() as $key => $value ) {
380
+ if ( 'attribute_' === substr( $key, 0, 10 ) ) {
381
+ $variation[ sanitize_title( wp_unslash( $key ) ) ] = wp_unslash( $value );
382
+ }
383
+ }
384
+ }
385
+ $args[] = $variation;
386
+
387
+ return $args;
388
+ }
389
  }
includes/controllers/class-wc-stripe-controller-checkout.php CHANGED
@@ -42,6 +42,10 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
42
  'methods' => WP_REST_Server::CREATABLE,
43
  'callback' => array( $this, 'process_payment' ),
44
  'permission_callback' => '__return_true',
 
 
 
 
45
  )
46
  );
47
  register_rest_route(
@@ -109,10 +113,18 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
109
  */
110
  public function process_payment( $request ) {
111
  wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true );
 
 
 
112
  try {
113
- $order_id = absint( WC()->session->get( 'order_awaiting_payment' ) );
114
  $order = wc_get_order( $order_id );
115
-
 
 
 
 
 
116
  /**
117
  * @var WC_Payment_Gateway_Stripe $payment_method
118
  */
@@ -209,7 +221,6 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
209
 
210
  private function actions() {
211
  add_action( 'woocommerce_after_checkout_validation', array( $this, 'after_checkout_validation' ), 10, 2 );
212
- add_action( 'woocommerce_checkout_order_processed', array( $this, 'checkout_order_processed' ), 10, 3 );
213
  add_action( 'woocommerce_checkout_posted_data', array( $this, 'filter_posted_data' ) );
214
  }
215
 
@@ -228,16 +239,10 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
228
  * @param WP_Error $errors
229
  */
230
  public function after_checkout_validation( $data, $errors ) {
231
- if ( $errors->get_error_message( 'required-field' ) ) {
232
  wc_add_notice(
233
  apply_filters(
234
- 'wc_stripe_after_checkout_validation_notice',
235
- sprintf(
236
- __( 'Some required fields were missing. Please click %1$shere%2$s to complete your payment.', 'woo-stripe-payment' ),
237
- '<a href="' .
238
- $this->get_order_review_url() . '">',
239
- '</a>'
240
- ),
241
  $data,
242
  $errors
243
  ),
@@ -245,8 +250,8 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
245
  );
246
  wp_send_json(
247
  array(
248
- 'result' => 'failure',
249
- 'messages' => $this->get_messages( 'notice' ),
250
  'reload' => false,
251
  ),
252
  200
@@ -266,9 +271,10 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
266
  private function get_order_review_url() {
267
  return add_query_arg(
268
  array(
269
- 'order_review' => 'true',
270
- 'payment_method' => $this->gateway->id,
271
- 'payment_nonce' => $this->gateway->get_payment_source(),
 
272
  ),
273
  wc_get_checkout_url()
274
  );
42
  'methods' => WP_REST_Server::CREATABLE,
43
  'callback' => array( $this, 'process_payment' ),
44
  'permission_callback' => '__return_true',
45
+ 'args' => array(
46
+ 'order_id' => array( 'required' => true ),
47
+ 'order_key' => array( 'required' => true )
48
+ )
49
  )
50
  );
51
  register_rest_route(
113
  */
114
  public function process_payment( $request ) {
115
  wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true );
116
+
117
+ // Indicator so we know payment is being processed after a 3DS authentication.
118
+ wc_maybe_define_constant( WC_Stripe_Constants::PROCESSING_PAYMENT, true );
119
  try {
120
+ $order_id = absint( $request->get_param( 'order_id' ) );
121
  $order = wc_get_order( $order_id );
122
+ if ( ! $order ) {
123
+ throw new Exception( __( 'Invalid order ID.', 'woo-stripe-payment' ) );
124
+ }
125
+ if ( ! $order->key_is_valid( $request->get_param( 'order_key' ) ) ) {
126
+ throw new Exception( __( 'Invalid order key.', 'woo-stripe-payment' ) );
127
+ }
128
  /**
129
  * @var WC_Payment_Gateway_Stripe $payment_method
130
  */
221
 
222
  private function actions() {
223
  add_action( 'woocommerce_after_checkout_validation', array( $this, 'after_checkout_validation' ), 10, 2 );
 
224
  add_action( 'woocommerce_checkout_posted_data', array( $this, 'filter_posted_data' ) );
225
  }
226
 
239
  * @param WP_Error $errors
240
  */
241
  public function after_checkout_validation( $data, $errors ) {
242
+ if ( preg_grep( '/[\w_]+_required/', $errors->get_error_codes() ) ) {
243
  wc_add_notice(
244
  apply_filters(
245
+ 'wc_stripe_after_checkout_validation_notice', __( 'Please review your order details then click Place Order.', 'woo-stripe-payment' ),
 
 
 
 
 
 
246
  $data,
247
  $errors
248
  ),
250
  );
251
  wp_send_json(
252
  array(
253
+ 'result' => 'success',
254
+ 'redirect' => $this->get_order_review_url(),
255
  'reload' => false,
256
  ),
257
  200
271
  private function get_order_review_url() {
272
  return add_query_arg(
273
  array(
274
+ '_stripe_order_review' => base64_encode( wp_json_encode( array(
275
+ 'payment_method' => $this->gateway->id,
276
+ 'payment_nonce' => $this->gateway->get_payment_source(),
277
+ ) ) ),
278
  ),
279
  wc_get_checkout_url()
280
  );
includes/traits/wc-stripe-payment-traits.php CHANGED
@@ -27,25 +27,30 @@ trait WC_Stripe_Payment_Intent_Trait {
27
 
28
  /**
29
  *
30
- * @param \Stripe\PaymentIntent $secret
31
  * @param WC_Order $order
32
  */
33
  public function get_payment_intent_checkout_url( $intent, $order ) {
 
 
34
  // rand is used to generate some random entropy so that window hash events are triggered.
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  return sprintf(
36
  '#response=%s',
37
  base64_encode(
38
- wp_json_encode(
39
- array(
40
- 'client_secret' => $intent->client_secret,
41
- 'order_id' => $order->get_id(),
42
- 'gateway_id' => $this->id,
43
- 'time' => rand(
44
- 0,
45
- 999999
46
- ),
47
- )
48
- )
49
  )
50
  );
51
  }
@@ -103,7 +108,7 @@ trait WC_Stripe_Local_Payment_Intent_Trait {
103
  'client_secret' => $intent->client_secret,
104
  'gateway_id' => $this->id,
105
  'return_url' => $this->get_local_payment_return_url( $order ),
106
- 'time' => rand(
107
  0,
108
  999999
109
  ),
27
 
28
  /**
29
  *
30
+ * @param \Stripe\PaymentIntent $intent
31
  * @param WC_Order $order
32
  */
33
  public function get_payment_intent_checkout_url( $intent, $order ) {
34
+ global $wp;
35
+
36
  // rand is used to generate some random entropy so that window hash events are triggered.
37
+ $args = array(
38
+ 'client_secret' => $intent->client_secret,
39
+ 'order_id' => $order->get_id(),
40
+ 'order_key' => $order->get_order_key(),
41
+ 'gateway_id' => $this->id,
42
+ 'status' => $intent->status,
43
+ 'pm' => $intent->payment_method,
44
+ 'entropy' => rand( 0, 999999 )
45
+ );
46
+ if ( ! empty( $wp->query_vars['order-pay'] ) ) {
47
+ $args['save_method'] = ! empty( $_POST[ $this->save_source_key ] );
48
+ }
49
+
50
  return sprintf(
51
  '#response=%s',
52
  base64_encode(
53
+ wp_json_encode( $args )
 
 
 
 
 
 
 
 
 
 
54
  )
55
  );
56
  }
108
  'client_secret' => $intent->client_secret,
109
  'gateway_id' => $this->id,
110
  'return_url' => $this->get_local_payment_return_url( $order ),
111
+ 'entropy' => rand(
112
  0,
113
  999999
114
  ),
includes/wc-stripe-functions.php CHANGED
@@ -1044,7 +1044,7 @@ function wc_stripe_stash_cart( $cart, $product_cart = true ) {
1044
  $cart->empty_cart( false );
1045
  if ( $product_cart && isset( $data['product_cart'] ) ) {
1046
  foreach ( $data['product_cart'] as $cart_item ) {
1047
- $cart->add_to_cart( $cart_item['product_id'], $cart_item['quantity'], $cart_item['variation_id'] );
1048
  }
1049
  }
1050
  }
1044
  $cart->empty_cart( false );
1045
  if ( $product_cart && isset( $data['product_cart'] ) ) {
1046
  foreach ( $data['product_cart'] as $cart_item ) {
1047
+ $cart->add_to_cart( $cart_item['product_id'], $cart_item['quantity'], $cart_item['variation_id'], $cart_item['variation'] );
1048
  }
1049
  }
1050
  }
includes/wc-stripe-webhook-functions.php CHANGED
@@ -192,13 +192,27 @@ function wc_stripe_process_create_refund( $charge ) {
192
  */
193
  // refund was not created via WC
194
  if ( ! isset( $refund->metadata['order_id'], $refund->metadata['created_via'] ) ) {
195
- // create the refund then update it in Stripe
196
- $result = wc_create_refund( array(
197
  'amount' => wc_stripe_remove_number_precision( $refund->amount, $order->get_currency() ),
198
  'order_id' => $order->get_id(),
199
  'reason' => $refund->reason,
200
  'refund_payment' => false
201
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  if ( ! is_wp_error( $result ) ) {
203
  $order->add_order_note( sprintf( __( 'Order refunded in Stripe. Amount: %s', 'woo-stripe-payment' ), $result->get_formatted_refund_amount() ) );
204
  WC_Stripe_Gateway::load( $mode )->refunds->update( $refund->id, array(
192
  */
193
  // refund was not created via WC
194
  if ( ! isset( $refund->metadata['order_id'], $refund->metadata['created_via'] ) ) {
195
+ $args = array(
 
196
  'amount' => wc_stripe_remove_number_precision( $refund->amount, $order->get_currency() ),
197
  'order_id' => $order->get_id(),
198
  'reason' => $refund->reason,
199
  'refund_payment' => false
200
+ );
201
+ // if the order has been fully refunded, items should be re-stocked
202
+ if ( $order->get_total() == ( $args['amount'] + $order->get_total_refunded() ) ) {
203
+ $args['restock_items'] = true;
204
+ $line_items = array();
205
+ foreach ( $order->get_items() as $item_id => $item ) {
206
+ $line_items[ $item_id ] = array(
207
+ 'qty' => $item->get_quantity()
208
+ );
209
+ }
210
+ $args['line_items'] = $line_items;
211
+ }
212
+ // create the refund
213
+ $result = wc_create_refund( $args );
214
+
215
+ // Update the refund in Stripe with metadata
216
  if ( ! is_wp_error( $result ) ) {
217
  $order->add_order_note( sprintf( __( 'Order refunded in Stripe. Amount: %s', 'woo-stripe-payment' ), $result->get_formatted_refund_amount() ) );
218
  WC_Stripe_Gateway::load( $mode )->refunds->update( $refund->id, array(
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: stripe, ach, klarna, credit card, apple pay, google pay, ideal, sepa, sofo
4
  Requires at least: 3.0.1
5
  Tested up to: 5.6
6
  Requires PHP: 5.6
7
- Stable tag: 3.2.10
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -58,6 +58,14 @@ If you're site is not loading over https, then Stripe won't render the Payment R
58
  8. Edit payment gateways on the product page
59
 
60
  == Changelog ==
 
 
 
 
 
 
 
 
61
  = 3.2.10 =
62
  * Added - Refund webhook support so refunds created in Stripe dashboard sync with WooCommerce store
63
  * Added - Option to control when local payment methods are visible on checkout page based on billing country
4
  Requires at least: 3.0.1
5
  Tested up to: 5.6
6
  Requires PHP: 5.6
7
+ Stable tag: 3.2.11
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
58
  8. Edit payment gateways on the product page
59
 
60
  == Changelog ==
61
+ = 3.2.11 =
62
+ * Added - WC tested up to: 4.9.0
63
+ * Added - Compatibility for Cartflows redirect to global checkout when local payment method used.
64
+ * Added - Refund webhook: if refunded total equals order total, re-stock product(s)
65
+ * Fixed - Apple Pay and Payment Request button disabled on product page when variable product has multiple variations
66
+ * Fixed - 3DS issue on order pay page if credit card gateway not pre-selected
67
+ * Fixed - Setup intent not created if 100% coupon entered on checkout page for subscription
68
+ * Updated - If any required fields missing on product or cart page checkout, redirect to checkout page where customer can enter required fields then click Place Order
69
  = 3.2.10 =
70
  * Added - Refund webhook support so refunds created in Stripe dashboard sync with WooCommerce store
71
  * Added - Option to control when local payment methods are visible on checkout page based on billing country
stripe-payments.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: Stripe For WooCommerce
4
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
5
  * Description: Accept credit cards, Google Pay, Apple Pay, ACH, Klarna and more using Stripe.
6
- * Version: 3.2.10
7
  * Author: Payment Plugins, support@paymentplugins.com
8
  * Text Domain: woo-stripe-payment
9
  * Domain Path: /i18n/languages/
10
  * Tested up to: 5.6
11
  * WC requires at least: 3.0.0
12
- * WC tested up to: 4.8.0
13
  */
14
  defined( 'ABSPATH' ) || exit ();
15
 
3
  * Plugin Name: Stripe For WooCommerce
4
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
5
  * Description: Accept credit cards, Google Pay, Apple Pay, ACH, Klarna and more using Stripe.
6
+ * Version: 3.2.11
7
  * Author: Payment Plugins, support@paymentplugins.com
8
  * Text Domain: woo-stripe-payment
9
  * Domain Path: /i18n/languages/
10
  * Tested up to: 5.6
11
  * WC requires at least: 3.0.0
12
+ * WC tested up to: 4.9.0
13
  */
14
  defined( 'ABSPATH' ) || exit ();
15