Payment Plugins for Stripe WooCommerce - Version 3.0.6

Version Description

  • Added - ACH subscription support
  • Updated - Top of checkout styling
  • Updated =Positioning of cart buttons. They are now below cart checkout button
Download this release

Release Info

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

Code changes from version 3.0.5 to 3.0.6

Files changed (42) hide show
  1. assets/css/stripe.css +63 -9
  2. assets/js/frontend/ach-payments.js +1 -1
  3. assets/js/frontend/applepay-cart.js +1 -1
  4. assets/js/frontend/applepay-checkout.js +1 -0
  5. assets/js/frontend/applepay-product.js +35 -1
  6. assets/js/frontend/googlepay-cart.js +1 -1
  7. assets/js/frontend/googlepay-checkout.js +2 -0
  8. assets/js/frontend/payment-request.js +34 -13
  9. assets/js/frontend/wc-stripe.js +45 -7
  10. assets/js/frontend/wc-stripe.min.js +1 -1
  11. i18n/languages/woo-stripe-payment.pot +106 -78
  12. includes/abstract/abstract-wc-payment-gateway-stripe-charge.php +12 -0
  13. includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php +10 -0
  14. includes/abstract/abstract-wc-payment-gateway-stripe.php +48 -8
  15. includes/abstract/abstract-wc-payment-token-stripe.php +16 -2
  16. includes/abstract/abstract-wc-stripe-settings.php +6 -0
  17. includes/class-stripe.php +2 -1
  18. includes/class-wc-stripe-field-manager.php +39 -3
  19. includes/class-wc-stripe-frontend-scripts.php +19 -2
  20. includes/class-wc-stripe-redirect-handler.php +10 -0
  21. includes/controllers/class-wc-stripe-controller-cart.php +100 -11
  22. includes/controllers/class-wc-stripe-controller-checkout.php +26 -0
  23. includes/controllers/class-wc-stripe-controller-googlepay.php +8 -1
  24. includes/gateways/class-wc-payment-gateway-stripe-ach.php +26 -13
  25. includes/gateways/class-wc-payment-gateway-stripe-klarna.php +1 -1
  26. includes/gateways/class-wc-payment-gateway-stripe-payment-request.php +1 -0
  27. includes/tokens/class-wc-payment-token-stripe-ach.php +12 -5
  28. includes/tokens/class-wc-payment-token-stripe-cc.php +4 -9
  29. includes/wc-stripe-functions.php +68 -4
  30. includes/wc-stripe-webhook-functions.php +10 -1
  31. readme.txt +5 -1
  32. stripe-payments.php +1 -1
  33. templates/cart/payment-methods.php +14 -5
  34. templates/cc-forms/bootstrap.php +8 -3
  35. templates/cc-forms/inline.php +1 -1
  36. templates/cc-forms/minimalist.php +1 -1
  37. templates/cc-forms/round.php +1 -1
  38. templates/cc-forms/simple.php +1 -1
  39. templates/checkout/ach.php +1 -0
  40. templates/checkout/checkout-banner.php +1 -0
  41. templates/checkout/payment-method.php +1 -1
  42. templates/payment-methods.php +1 -1
assets/css/stripe.css CHANGED
@@ -3,9 +3,6 @@
3
  float: right;
4
  display: inline-block;
5
  }
6
- .wc-stripe-gateway-desc{
7
- margin-bottom: 10px;
8
- }
9
  li.payment_method_stripe_cc .wc-stripe-card-icons-container img.wc-stripe-card-icon,
10
  li.payment_method_stripe_payment_request .wc-stripe-paymentRequest-icons-container img{
11
  max-width: 44px;
@@ -33,7 +30,7 @@ li.payment_method_stripe_cc .wc-stripe-card-icons-container img.wc-stripe-card-i
33
  padding-top: 2px;
34
  }
35
  ul.payment_methods li[class*=payment_method_stripe_] label>img:first-of-type{
36
- float: right;
37
  }
38
  .wc-stripe_cc-new-method-container{
39
  margin-bottom: 1em;
@@ -51,12 +48,23 @@ ul.payment_methods li[class*=payment_method_stripe_] label>img:first-of-type{
51
  }
52
  input.wc-stripe-payment-type,
53
  input.wc-stripe-klarna-category{
54
- display: none;
 
 
 
55
  }
56
  label.wc-stripe-label-payment-type,
 
57
  label.wc-stripe-label-klarna-category{
58
  margin-bottom: 1em;
59
  display: block;
 
 
 
 
 
 
 
60
  }
61
  label.wc-stripe-label-payment-type:before,
62
  label.wc-stripe-label-klarna-category:before{
@@ -199,11 +207,12 @@ li.payment_method_stripe_payment_request{
199
  }
200
  .wc-stripe-product-checkout-container ul.wc_stripe_product_payment_methods li[class*=payment_method_stripe_],
201
  .wc-stripe-cart-checkout-container ul.wc_stripe_cart_payment_methods li[class*=payment_method_stripe_]{
202
- margin-bottom: 1em;
203
  }
204
  .wc_stripe_product_payment_methods .gpay-button,
205
  .wc_stripe_cart_payment_methods .gpay-button{
206
- width: 100%;
 
207
  }
208
  .wc_stripe_product_payment_methods .disabled{
209
  opacity: 0.45;
@@ -215,8 +224,13 @@ li.payment_method_stripe_payment_request{
215
  li.wc-stripe-payment-method.or{
216
  display: none;
217
  }
 
 
 
 
218
  li[class*=payment_method_stripe_].active ~ li.wc-stripe-payment-method.or{
219
  display: block;
 
220
  }
221
  li.payment_method_stripe_applepay label:first-of-type img{
222
  width: 49px;
@@ -276,13 +290,50 @@ li.payment_method_stripe_ach label:first-of-type img{
276
  max-width: 240px;
277
  }
278
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  .wc-stripe-banner-checkout ul.wc_stripe_checkout_banner_gateways{
280
  list-style: none;
281
- margin: 0 0 1.5em 0;
282
  padding: 0;
283
  }
284
  .wc-stripe-banner-checkout ul.wc_stripe_checkout_banner_gateways li.wc-stripe-checkout-banner-gateway{
285
- margin-bottom: 1em;
 
 
 
 
286
  }
287
  .wc-stripe-banner-checkout ul.wc_stripe_checkout_banner_gateways .gpay-button{
288
  width: 100%;
@@ -403,4 +454,7 @@ li[class*="payment_method_stripe"] .select2-container--default .select2-selectio
403
  }
404
  .wc-stripe-paymentRequest-icons-container img{
405
  float: none;
 
 
 
406
  }
3
  float: right;
4
  display: inline-block;
5
  }
 
 
 
6
  li.payment_method_stripe_cc .wc-stripe-card-icons-container img.wc-stripe-card-icon,
7
  li.payment_method_stripe_payment_request .wc-stripe-paymentRequest-icons-container img{
8
  max-width: 44px;
30
  padding-top: 2px;
31
  }
32
  ul.payment_methods li[class*=payment_method_stripe_] label>img:first-of-type{
33
+ float: right !important;
34
  }
35
  .wc-stripe_cc-new-method-container{
36
  margin-bottom: 1em;
48
  }
49
  input.wc-stripe-payment-type,
50
  input.wc-stripe-klarna-category{
51
+ display: none !important;
52
+ }
53
+ body .wfacp_main_form.woocommerce .wc-stripe-save-source label.checkbox{
54
+ padding: 0 !important;
55
  }
56
  label.wc-stripe-label-payment-type,
57
+ input[type=radio] + label.wc-stripe-label-payment-type,
58
  label.wc-stripe-label-klarna-category{
59
  margin-bottom: 1em;
60
  display: block;
61
+ padding: 0 !important;
62
+ }
63
+ .theme-flatsome div.wc-stripe-saved-methods-container{
64
+ margin: 0 0 1em 0;
65
+ }
66
+ .wc-stripe-gateway-desc.has_tokens{
67
+ margin-bottom: 10px;
68
  }
69
  label.wc-stripe-label-payment-type:before,
70
  label.wc-stripe-label-klarna-category:before{
207
  }
208
  .wc-stripe-product-checkout-container ul.wc_stripe_product_payment_methods li[class*=payment_method_stripe_],
209
  .wc-stripe-cart-checkout-container ul.wc_stripe_cart_payment_methods li[class*=payment_method_stripe_]{
210
+ margin: 0 0 1em 0;
211
  }
212
  .wc_stripe_product_payment_methods .gpay-button,
213
  .wc_stripe_cart_payment_methods .gpay-button{
214
+ width: 100% !important;
215
+ margin: 0;
216
  }
217
  .wc_stripe_product_payment_methods .disabled{
218
  opacity: 0.45;
224
  li.wc-stripe-payment-method.or{
225
  display: none;
226
  }
227
+ .wc-stripe-cart-checkout-container ul.wc_stripe_cart_payment_methods.active li.wc-stripe-payment-method.or{
228
+ display: block;
229
+ margin: 0;
230
+ }
231
  li[class*=payment_method_stripe_].active ~ li.wc-stripe-payment-method.or{
232
  display: block;
233
+ margin: 0;
234
  }
235
  li.payment_method_stripe_applepay label:first-of-type img{
236
  width: 49px;
290
  max-width: 240px;
291
  }
292
  }
293
+ .wc-stripe-banner-checkout{
294
+ padding: 1em 15px 0 15px;
295
+ border: 1px solid #d1d1d1;
296
+ border-width: 0 0 1px;
297
+ position: relative;
298
+ margin: 1em 0;
299
+
300
+ }
301
+ .wc-stripe-banner-checkout span.banner-title{
302
+ position: absolute;
303
+ display: flex;
304
+ align-items: center;
305
+ top: -13px;
306
+ right: 0;
307
+ left: 0;
308
+ background: transparent;
309
+ white-space: nowrap;
310
+ font-size: 16px;
311
+ }
312
+ .wc-stripe-banner-checkout span.banner-title:before,
313
+ .wc-stripe-banner-checkout span.banner-title:after{
314
+ content: ' ';
315
+ height: 1px;
316
+ background: #d1d1d1;
317
+ display: block;
318
+ width: 50%;
319
+ }
320
+ .wc-stripe-banner-checkout span.banner-title:before{
321
+ margin-right: 8px;
322
+ }
323
+ .wc-stripe-banner-checkout span.banner-title:after{
324
+ margin-left: 8px;
325
+ }
326
  .wc-stripe-banner-checkout ul.wc_stripe_checkout_banner_gateways{
327
  list-style: none;
328
+ margin: 0;
329
  padding: 0;
330
  }
331
  .wc-stripe-banner-checkout ul.wc_stripe_checkout_banner_gateways li.wc-stripe-checkout-banner-gateway{
332
+ margin: 0 0 1em 0;
333
+ display: none;
334
+ }
335
+ .wc-stripe-banner-checkout ul.wc_stripe_checkout_banner_gateways li.wc-stripe-checkout-banner-gateway .gpay-button{
336
+ margin: 0;
337
  }
338
  .wc-stripe-banner-checkout ul.wc_stripe_checkout_banner_gateways .gpay-button{
339
  width: 100%;
454
  }
455
  .wc-stripe-paymentRequest-icons-container img{
456
  float: none;
457
+ }
458
+ .select2-container .select2-selection--single .wc-stripe-select2-container.wc-stripe-ach:before{
459
+ display: none;
460
  }
assets/js/frontend/ach-payments.js CHANGED
@@ -38,7 +38,7 @@
38
 
39
  ACH.prototype.place_order = function(e) {
40
  if (this.is_gateway_selected()) {
41
- if (!this.payment_token_received) {
42
  e.preventDefault();
43
  this.linkHandler.open();
44
  }
38
 
39
  ACH.prototype.place_order = function(e) {
40
  if (this.is_gateway_selected()) {
41
+ if (!this.payment_token_received && !this.is_saved_method_selected()) {
42
  e.preventDefault();
43
  this.linkHandler.open();
44
  }
assets/js/frontend/applepay-cart.js CHANGED
@@ -7,7 +7,7 @@
7
  wc_stripe.BaseGateway.call(this, wc_stripe_applepay_cart_params);
8
  wc_stripe.CartGateway.call(this);
9
  this.canMakePayment().then(function() {
10
- $(this.container).addClass('active');
11
  }.bind(this));
12
 
13
  }
7
  wc_stripe.BaseGateway.call(this, wc_stripe_applepay_cart_params);
8
  wc_stripe.CartGateway.call(this);
9
  this.canMakePayment().then(function() {
10
+ $(this.container).addClass('active').parent().addClass('active');
11
  }.bind(this));
12
 
13
  }
assets/js/frontend/applepay-checkout.js CHANGED
@@ -19,6 +19,7 @@
19
  if (this.banner_enabled()) {
20
  var $button = $(this.params.button);
21
  $button.addClass('banner-checkout');
 
22
  $(this.banner_container).append($button);
23
  }
24
  }.bind(this))
19
  if (this.banner_enabled()) {
20
  var $button = $(this.params.button);
21
  $button.addClass('banner-checkout');
22
+ $(this.banner_container).show();
23
  $(this.banner_container).append($button);
24
  }
25
  }.bind(this))
assets/js/frontend/applepay-product.js CHANGED
@@ -16,9 +16,28 @@
16
  */
17
  ApplePay.prototype.canMakePayment = function() {
18
  wc_stripe.ApplePay.prototype.canMakePayment.call(this).then(function() {
19
- $('[name="quantity"]').val(0);
20
  // Apple Pay is enable, so add to cart each time the user updates quantity.
21
  $(document.body).on('change', '[name="quantity"]', this.add_to_cart.bind(this));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }.bind(this))
23
  }
24
 
@@ -42,6 +61,21 @@
42
  $('#wc-stripe-applepay-container').append(this.$button);
43
  }
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  new ApplePay();
46
 
47
  }(jQuery, wc_stripe))
16
  */
17
  ApplePay.prototype.canMakePayment = function() {
18
  wc_stripe.ApplePay.prototype.canMakePayment.call(this).then(function() {
19
+ //$('[name="quantity"]').val(0);
20
  // Apple Pay is enable, so add to cart each time the user updates quantity.
21
  $(document.body).on('change', '[name="quantity"]', this.add_to_cart.bind(this));
22
+ if (!this.is_variable_product()) {
23
+ this.cart_calculation().then(function() {
24
+ this.paymentRequest.update(this.get_payment_request_update({
25
+ total: {
26
+ pending: false
27
+ }
28
+ }));
29
+ }.bind(this)).catch(function() {
30
+ $('[name="quantity"]').val(0);
31
+ }.bind(this))
32
+ } else {
33
+ if (this.do_payment_request_update) {
34
+ this.paymentRequest.update(this.get_payment_request_update({
35
+ total: {
36
+ pending: false
37
+ }
38
+ }));
39
+ }
40
+ }
41
  }.bind(this))
42
  }
43
 
61
  $('#wc-stripe-applepay-container').append(this.$button);
62
  }
63
 
64
+ ApplePay.prototype.found_variation = function(e, variation) {
65
+ if (this.can_pay) {
66
+ this.cart_calculation(variation.variation_id).then(function() {
67
+ wc_stripe.ProductGateway.prototype.found_variation.call(this, e, variation);
68
+ if (this.can_pay) {
69
+ this.paymentRequest.update(this.get_payment_request_update({
70
+ total: {
71
+ pending: false
72
+ }
73
+ }));
74
+ }
75
+ }.bind(this))
76
+ }
77
+ }
78
+
79
  new ApplePay();
80
 
81
  }(jQuery, wc_stripe))
assets/js/frontend/googlepay-cart.js CHANGED
@@ -20,7 +20,7 @@
20
  GPay.prototype.initialize = function() {
21
  this.createPaymentsClient();
22
  this.isReadyToPay().then(function() {
23
- $(this.container).show().addClass('active');
24
  }.bind(this))
25
  }
26
 
20
  GPay.prototype.initialize = function() {
21
  this.createPaymentsClient();
22
  this.isReadyToPay().then(function() {
23
+ $(this.container).show().addClass('active').parent().addClass('active');
24
  }.bind(this))
25
  }
26
 
assets/js/frontend/googlepay-checkout.js CHANGED
@@ -29,6 +29,7 @@
29
  buttonColor: this.params.button_color,
30
  buttonType: this.params.button_style
31
  }));
 
32
  $(this.banner_container).append($button);
33
  }
34
  }.bind(this))
@@ -40,6 +41,7 @@
40
  GPay.prototype.create_button = function() {
41
  wc_stripe.GooglePay.prototype.create_button.apply(this, arguments);
42
  $("#place_order").parent().append(this.$button);
 
43
  this.trigger_payment_method_selected();
44
  }
45
 
29
  buttonColor: this.params.button_color,
30
  buttonType: this.params.button_style
31
  }));
32
+ $(this.banner_container).show();
33
  $(this.banner_container).append($button);
34
  }
35
  }.bind(this))
41
  GPay.prototype.create_button = function() {
42
  wc_stripe.GooglePay.prototype.create_button.apply(this, arguments);
43
  $("#place_order").parent().append(this.$button);
44
+ var position = $('#place_order').css('float');
45
  this.trigger_payment_method_selected();
46
  }
47
 
assets/js/frontend/payment-request.js CHANGED
@@ -18,8 +18,23 @@
18
  */
19
  PaymentRequest.prototype.canMakePayment = function() {
20
  wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function(result) {
21
- $('[name="quantity"]').val(0);
22
  $(document.body).on('change', '[name="quantity"]', this.add_to_cart.bind(this));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }.bind(this))
24
  }
25
 
@@ -31,6 +46,9 @@
31
  PaymentRequest.prototype.button_click = function(e) {
32
  if (this.$button.is('.disabled')) {
33
  e.preventDefault();
 
 
 
34
  }
35
  }
36
 
@@ -54,18 +72,21 @@
54
  }.bind(this))
55
  }
56
 
57
- PaymentRequest.prototype.found_variation = function() {
58
- wc_stripe.ProductGateway.prototype.found_variation.apply(this, arguments);
59
- if (this.can_pay) {
60
- $('[name="quantity"]').val(0);
61
- }
62
-
63
- }
64
-
65
- PaymentRequest.prototype.reset_variation_data = function() {
66
- wc_stripe.ProductGateway.prototype.reset_variation_data.apply(this, arguments);
67
  if (this.can_pay) {
68
- $('[name="quantity"]').val(0);
 
 
 
 
 
 
 
 
 
 
 
 
69
  }
70
  }
71
 
@@ -99,7 +120,7 @@
99
 
100
  PaymentRequest.prototype.canMakePayment = function() {
101
  wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function() {
102
- $(this.container).addClass('active');
103
  }.bind(this))
104
  }
105
 
18
  */
19
  PaymentRequest.prototype.canMakePayment = function() {
20
  wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function(result) {
21
+ //$('[name="quantity"]').val(0);
22
  $(document.body).on('change', '[name="quantity"]', this.add_to_cart.bind(this));
23
+ if (!this.is_variable_product()) {
24
+ this.cart_calculation().then(function() {
25
+ this.paymentRequest.update(this.get_payment_request_update({
26
+ total: {
27
+ pending: false
28
+ }
29
+ }));
30
+ }.bind(this)).catch(function() {
31
+ $('[name="quantity"]').val(0);
32
+ }.bind(this))
33
+ } else {
34
+ if (this.$button.not('.disabled')) {
35
+ this.found_variation(null, this.get_product_data().variation);
36
+ }
37
+ }
38
  }.bind(this))
39
  }
40
 
46
  PaymentRequest.prototype.button_click = function(e) {
47
  if (this.$button.is('.disabled')) {
48
  e.preventDefault();
49
+ } else if (this.get_quantity() == 0) {
50
+ e.preventDefault();
51
+ this.submit_error(this.params.messages.invalid_amount);
52
  }
53
  }
54
 
72
  }.bind(this))
73
  }
74
 
75
+ PaymentRequest.prototype.found_variation = function(e, variation) {
 
 
 
 
 
 
 
 
 
76
  if (this.can_pay) {
77
+ this.cart_calculation(variation.variation_id).then(function() {
78
+ wc_stripe.ProductGateway.prototype.found_variation.call(this, e, variation);
79
+ if (this.can_pay) {
80
+ this.paymentRequest.update(this.get_payment_request_update({
81
+ total: {
82
+ pending: false
83
+ }
84
+ }));
85
+ }
86
+ }.bind(this)).catch(function() {
87
+ wc_stripe.ProductGateway.prototype.found_variation.call(this, e, variation);
88
+ $('[name="quantity"]').val(0);
89
+ }.bind(this))
90
  }
91
  }
92
 
120
 
121
  PaymentRequest.prototype.canMakePayment = function() {
122
  wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function() {
123
+ $(this.container).addClass('active').parent().addClass('active');
124
  }.bind(this))
125
  }
126
 
assets/js/frontend/wc-stripe.js CHANGED
@@ -5,7 +5,7 @@
5
  * [Initiate Stripe]
6
  * @type {[type]}
7
  */
8
- var stripe = Stripe(wc_stripe_params.api_key);
9
 
10
  /**
11
  * @consructor
@@ -22,6 +22,10 @@
22
  this.initialize();
23
  }
24
 
 
 
 
 
25
  wc_stripe.BaseGateway.prototype.set_nonce = function(value) {
26
  $(this.token_selector).val(value);
27
  }
@@ -557,7 +561,7 @@
557
  url: this.params.routes.checkout,
558
  method: 'POST',
559
  dataType: 'json',
560
- data: $.extend({}, this.serialize_form(this.get_form()), { payment_method: this.gateway_id }),
561
  beforeSend: function(xhr) {
562
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
563
  }.bind(this)
@@ -637,7 +641,7 @@
637
  url: this.params.routes.shipping_address,
638
  method: 'POST',
639
  dataType: 'json',
640
- data: { address: this.map_address(ev.shippingAddress), payment_method: this.gateway_id },
641
  beforeSend: function(xhr) {
642
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
643
  }.bind(this)
@@ -664,7 +668,7 @@
664
  url: this.params.routes.shipping_method,
665
  method: 'POST',
666
  dataType: 'json',
667
- data: { shipping_methods: this.map_shipping_methods(ev.shippingOption.id), payment_method: this.gateway_id },
668
  beforeSend: function(xhr) {
669
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
670
  }.bind(this)
@@ -704,7 +708,7 @@
704
 
705
  if (this.banner_enabled()) {
706
  if ($('.woocommerce-billing-fields').length) {
707
- $(this.banner_container).css('max-width', $('.woocommerce-billing-fields').outerWidth(true));
708
  }
709
  }
710
 
@@ -950,6 +954,7 @@
950
  var data = this.get_product_data();
951
  data.price = variation.display_price;
952
  data.needs_shipping = !variation.is_virtual;
 
953
  this.set_product_data(data);
954
  this.enable_payment_button();
955
  }
@@ -1028,7 +1033,8 @@
1028
  product_id: $('#product_id').val(),
1029
  variation_id: this.is_variable_product() ? $('[name="variation_id"]').val() : 0,
1030
  qty: $('[name="quantity"]').val(),
1031
- payment_method: this.gateway_id
 
1032
  },
1033
  beforeSend: function(xhr) {
1034
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
@@ -1052,6 +1058,37 @@
1052
  }.bind(this))
1053
  }
1054
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1055
  /************* Cart Gateway *************/
1056
 
1057
  /**
@@ -1242,7 +1279,8 @@
1242
  data: {
1243
  shipping_address: this.map_address(data.shippingAddress),
1244
  shipping_methods: this.map_shipping_methods(data.shippingOptionData.id),
1245
- shipping_method_id: data.shippingOptionData.id
 
1246
  },
1247
  beforeSend: function(xhr) {
1248
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce)
5
  * [Initiate Stripe]
6
  * @type {[type]}
7
  */
8
+ var stripe = Stripe(wc_stripe_params_v3.api_key);
9
 
10
  /**
11
  * @consructor
22
  this.initialize();
23
  }
24
 
25
+ wc_stripe.BaseGateway.prototype.get_page = function() {
26
+ return wc_stripe_params_v3.page;
27
+ }
28
+
29
  wc_stripe.BaseGateway.prototype.set_nonce = function(value) {
30
  $(this.token_selector).val(value);
31
  }
561
  url: this.params.routes.checkout,
562
  method: 'POST',
563
  dataType: 'json',
564
+ data: $.extend({}, this.serialize_form(this.get_form()), { payment_method: this.gateway_id, page_id: this.get_page() }),
565
  beforeSend: function(xhr) {
566
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
567
  }.bind(this)
641
  url: this.params.routes.shipping_address,
642
  method: 'POST',
643
  dataType: 'json',
644
+ data: { address: this.map_address(ev.shippingAddress), payment_method: this.gateway_id, page_id: this.get_page() },
645
  beforeSend: function(xhr) {
646
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
647
  }.bind(this)
668
  url: this.params.routes.shipping_method,
669
  method: 'POST',
670
  dataType: 'json',
671
+ data: { shipping_methods: this.map_shipping_methods(ev.shippingOption.id), payment_method: this.gateway_id, page_id: this.get_page() },
672
  beforeSend: function(xhr) {
673
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
674
  }.bind(this)
708
 
709
  if (this.banner_enabled()) {
710
  if ($('.woocommerce-billing-fields').length) {
711
+ $('.wc-stripe-banner-checkout').css('max-width', $('.woocommerce-billing-fields').outerWidth(true));
712
  }
713
  }
714
 
954
  var data = this.get_product_data();
955
  data.price = variation.display_price;
956
  data.needs_shipping = !variation.is_virtual;
957
+ data.variation = variation;
958
  this.set_product_data(data);
959
  this.enable_payment_button();
960
  }
1033
  product_id: $('#product_id').val(),
1034
  variation_id: this.is_variable_product() ? $('[name="variation_id"]').val() : 0,
1035
  qty: $('[name="quantity"]').val(),
1036
+ payment_method: this.gateway_id,
1037
+ page_id: this.get_page()
1038
  },
1039
  beforeSend: function(xhr) {
1040
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
1058
  }.bind(this))
1059
  }
1060
 
1061
+ wc_stripe.ProductGateway.prototype.cart_calculation = function(variation_id) {
1062
+ return new Promise(function(resolve, reject) {
1063
+ $.ajax({
1064
+ url: this.params.routes.cart_calculation,
1065
+ method: 'POST',
1066
+ dataType: 'json',
1067
+ data: {
1068
+ product_id: $('#product_id').val(),
1069
+ variation_id: this.is_variable_product() && variation_id ? variation_id : 0,
1070
+ qty: $('[name="quantity"]').val(),
1071
+ payment_method: this.gateway_id
1072
+ },
1073
+ beforeSend: function(xhr) {
1074
+ xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce);
1075
+ }.bind(this)
1076
+ }).done(function(response, status, xhr) {
1077
+ $(document.body).triggerHandler('wc_stripe_updated_rest_nonce', xhr.getResponseHeader('X-WP-Nonce'));
1078
+ if (response.code) {
1079
+ this.cart_calculation_error = true;
1080
+ } else {
1081
+ this.set_total_price(response.data.total);
1082
+ this.set_total_price_cents(response.data.totalCents);
1083
+ this.set_display_items(response.data.displayItems);
1084
+ resolve(response.data);
1085
+ }
1086
+ }.bind(this)).fail(function(xhr, textStatus, errorThrown) {
1087
+
1088
+ }.bind(this))
1089
+ }.bind(this))
1090
+ }
1091
+
1092
  /************* Cart Gateway *************/
1093
 
1094
  /**
1279
  data: {
1280
  shipping_address: this.map_address(data.shippingAddress),
1281
  shipping_methods: this.map_shipping_methods(data.shippingOptionData.id),
1282
+ shipping_method_id: data.shippingOptionData.id,
1283
+ page_id: this.get_page()
1284
  },
1285
  beforeSend: function(xhr) {
1286
  xhr.setRequestHeader('X-WP-Nonce', this.params.rest_nonce)
assets/js/frontend/wc-stripe.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){t.wc_stripe={};var i=Stripe(wc_stripe_params.api_key);wc_stripe.BaseGateway=function(t){this.params=t,this.gateway_id=this.params.gateway_id,this.token_selector=this.params.token_selector,this.saved_method_selector=this.params.saved_method_selector,this.payment_intent_selector=this.params.payment_intent_selector,this.payment_token_received=!1,this.stripe=i,this.elements=i.elements(e.extend({},{locale:"auto"},this.get_element_options())),this.initialize()},wc_stripe.BaseGateway.prototype.set_nonce=function(t){e(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 e('[name="payment_method"]:checked').val()===this.gateway_id},wc_stripe.BaseGateway.prototype.is_saved_method_selected=function(){return this.is_gateway_selected()&&"saved"===e('[name="'+this.gateway_id+'_payment_type_key"]:checked').val()},wc_stripe.BaseGateway.prototype.has_checkout_error=function(){return e("#wc_stripe_checkout_error").length>0&&this.is_gateway_selected()},wc_stripe.BaseGateway.prototype.submit_error=function(t){-1==t.indexOf("</ul>")&&(t='<div class="woocommerce-error">'+t+"</div>"),this.submit_message(t)},wc_stripe.BaseGateway.prototype.submit_error_code=function(t){},wc_stripe.BaseGateway.prototype.submit_message=function(t){e(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove();var i=e(this.message_container);i.closest("form").length&&(i=i.closest("form")),i.prepend(t),i.removeClass("processing").unblock(),i.find(".input-text, select, input:checkbox").blur(),e("html, body").animate({scrollTop:i.offset().top-100},1e3)},wc_stripe.BaseGateway.prototype.get_first_name=function(t){return e("#"+t+"_first_name").val()},wc_stripe.BaseGateway.prototype.get_last_name=function(t){return e("#"+t+"_last_name").val()},wc_stripe.BaseGateway.prototype.should_save_method=function(){return e("#"+this.gateway_id+"_save_source_key").is(":checked")},wc_stripe.BaseGateway.prototype.is_add_payment_method_page=function(){return e(document.body).hasClass("woocommerce-add-payment-method")},wc_stripe.BaseGateway.prototype.get_selected_payment_method=function(){return e(this.saved_method_selector).val()},wc_stripe.BaseGateway.prototype.needs_shipping=function(){return"1"===this.params.needs_shipping},wc_stripe.BaseGateway.prototype.get_currency=function(){return e("#wc_stripe_currency").val()},wc_stripe.BaseGateway.prototype.get_country=function(){return e("#wc_stripe_country").val()},wc_stripe.BaseGateway.prototype.get_customer_name=function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()},wc_stripe.BaseGateway.prototype.get_customer_email=function(){return e("#billing_email").val()},wc_stripe.BaseGateway.prototype.get_address_field_hash=function(t){for(var i=["_first_name","_last_name","_address_1","_address_2","_postcode","_city","_state","_country"],a="",n=0;n<i.length;n++)a+=e(t+i[n]).val()+"_";return a},wc_stripe.BaseGateway.prototype.block=function(){e.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.BaseGateway.prototype.unblock=function(){e.unblockUI()},wc_stripe.BaseGateway.prototype.get_form=function(){return e(this.token_selector).closest("form")},wc_stripe.BaseGateway.prototype.get_total_price=function(){return e("#wc_stripe_order_total").data("amount")},wc_stripe.BaseGateway.prototype.get_total_price_cents=function(){return e("#wc_stripe_order_total_cents").data("amount")},wc_stripe.BaseGateway.prototype.set_total_price=function(t){e("#wc_stripe_order_total").data("amount",t)},wc_stripe.BaseGateway.prototype.set_total_price_cents=function(t){e("#wc_stripe_order_total_cents").data("amount",t)},wc_stripe.BaseGateway.prototype.set_payment_method=function(t){e('[name="payment_method"][value="'+t+'"]').prop("checked",!0).trigger("click")},wc_stripe.BaseGateway.prototype.set_selected_shipping_methods=function(t){if(t&&e('[name^="shipping_method"]').length)for(var i in t){var a=t[i];e('[name="shipping_method['+i+']"][value="'+a+'"]').prop("checked",!0).trigger("change")}},wc_stripe.BaseGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,e(this.token_selector).val(t.id),this.process_checkout()},wc_stripe.BaseGateway.prototype.createPaymentRequest=function(){this.paymentRequest=i.paymentRequest(this.get_payment_request_options()),this.needs_shipping()&&(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))},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:!0,requestPayerEmail:!0,requestPayerPhone:!0,requestShipping:this.needs_shipping()},e=this.get_display_items(),i=this.get_shipping_options();return e&&(t.displayItems=e),this.needs_shipping()&&i&&(t.shippingOptions=i),t},wc_stripe.BaseGateway.prototype.get_payment_request_update=function(t){var i={currency:this.get_currency().toLowerCase(),total:{amount:parseInt(this.get_total_price_cents()),label:this.params.total_label,pending:!0}},a=this.get_display_items(),n=this.get_shipping_options();return a&&(i.displayItems=a),this.needs_shipping()&&n&&(i.shippingOptions=n),t&&(i=e.extend(!0,{},i,t)),i},wc_stripe.BaseGateway.prototype.get_display_items=function(){return e("#wc_stripe_display_items").data("items")},wc_stripe.BaseGateway.prototype.set_display_items=function(t){e("#wc_stripe_display_items").data("items",t)},wc_stripe.BaseGateway.prototype.get_shipping_options=function(){return e("#wc_stripe_shipping_options").data("items")},wc_stripe.BaseGateway.prototype.set_shipping_options=function(t){e("#wc_stripe_shipping_options").data("items",t)},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(e){try{this.payment_response=e,this.populate_checkout_fields(e),e.complete("success"),this.on_token_received(e.paymentMethod)}catch(e){t.alert(e)}},wc_stripe.BaseGateway.prototype.populate_checkout_fields=function(t){e(this.token_selector).val(t.paymentMethod.id),this.populate_address_fields(t)},wc_stripe.BaseGateway.prototype.populate_address_fields=function(t){var i=this.address_mappings();if(t.payerName&&i.payerName.set(t.payerName),t.payerEmail&&i.payerEmail.set(t.payerEmail),t.payerPhone&&i.payerPhone.set(t.payerPhone),t.shippingAddress){var a=t.shippingAddress;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#shipping")}if(t.paymentMethod.billing_details.address){a=t.paymentMethod.billing_details.address;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#billing")}this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},wc_stripe.BaseGateway.prototype.address_mappings=function(){return{payerName:{set:function(t,i){var a=t.split(" ");a.length>0&&e("#billing_first_name").val(a[0]),a.length>1&&e("#billing_last_name").val(a[1])},get:function(t){return e("#billing_first_name").val()+" "+e("#billing_last_name").val()}},payerEmail:{set:function(t){e("#billing_email").val(t)},get:function(){return e("#billing_email").val()}},payerPhone:{set:function(t){e("#billing_phone").val(t)},get:function(){return e("#billing_phone").val()}},recipient:{set:function(t,i){var a=t.split(" ");a.length>0&&e(i+"_first_name").val(a[0]),a.length>1&&e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()}},country:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},addressLine:{set:function(t,i){t.length>0&&e(i+"_address_1").val(t[0]),t.length>1&&e(i+"_address_2").val(t[1])},get:function(t){return[e(t+"_address_1").val(),e(t+"_address_2").val()]}},line1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},line2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},region:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},state:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},city:{set:function(t,i){e(i+"_city").val(t)},get:function(t){e(t+"_city").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}},postal_code:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}}}},wc_stripe.BaseGateway.prototype.process_checkout=function(){return new Promise(function(i,a){this.block(),e.ajax({url:this.params.routes.checkout,method:"POST",dataType:"json",data:e.extend({},this.serialize_form(this.get_form()),{payment_method:this.gateway_id}),beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.reload?t.location.reload():"success"===e.result?t.location=e.redirect:(e.messages&&this.submit_error(e.messages),this.unblock())}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.serialize_form=function(t){var i=t.find("input").filter(function(t,i){return!e(i).is('[name^="add-to-cart"]')}.bind(this)).serializeArray(),a={};for(var n in i){var s=i[n];a[s.name]=s.value}return a.payment_method=this.gateway_id,a},wc_stripe.BaseGateway.prototype.map_shipping_methods=function(t){var e={};if("default"!==t){var i=t.match(/^(\d):(.+)$/);i.length>1&&(e[i[1]]=i[2])}return e},wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different=function(){e('[name="ship_to_different_address"]').length&&e('[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(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_address,method:"POST",dataType:"json",data:{address:this.map_address(t.shippingAddress),payment_method:this.gateway_id},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.update_shipping_method=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_method,method:"POST",dataType:"json",data:{shipping_methods:this.map_shipping_methods(t.shippingOption.id),payment_method:this.gateway_id},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(this.set_selected_shipping_methods(e.data.shipping_methods),t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CheckoutGateway=function(){this.container=this.message_container="li.payment_method_"+this.gateway_id,this.banner_container="li.banner_payment_method_"+this.gateway_id,e(document.body).on("update_checkout",this.update_checkout.bind(this)),e(document.body).on("updated_checkout",this.updated_checkout.bind(this)),e(document.body).on("checkout_error",this.checkout_error.bind(this)),e(this.token_selector).closest("form").on("checkout_place_order_"+this.gateway_id,this.checkout_place_order.bind(this)),e(document.body).on("wc_stripe_new_method_"+this.gateway_id,this.on_show_new_methods.bind(this)),e(document.body).on("wc_stripe_saved_method_"+this.gateway_id,this.on_show_saved_methods.bind(this)),e(document.body).on("wc_stripe_payment_method_selected",this.on_payment_method_selected.bind(this)),this.banner_enabled()&&e(".woocommerce-billing-fields").length&&e(this.banner_container).css("max-width",e(".woocommerce-billing-fields").outerWidth(!0)),this.order_review()},wc_stripe.CheckoutGateway.prototype.order_review=function(){var e=t.location.href.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);if(e&&e.length>1){var i=e[1],a=e[2];this.gateway_id===i&&(this.payment_token_received=!0,this.set_nonce(a),this.set_use_new_option(!0))}},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!(e('[name="terms"]').length&&!e('[name="terms"]').is(":checked"))},wc_stripe.CheckoutGateway.prototype.get_payment_method=function(){return e('[name="payment_method"]:checked').val()},wc_stripe.CheckoutGateway.prototype.set_use_new_option=function(t){e("#"+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,e(this.token_selector).val(t.id),this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.block=function(){e("form.checkout").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.CheckoutGateway.prototype.unblock=function(){e("form.checkout").unblock()},wc_stripe.CheckoutGateway.prototype.hide_place_order=function(){e("#place_order").addClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.show_place_order=function(){e("#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,e('[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.ProductGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.product",e(document.body).on("wc_stripe_updated_rest_nonce",this.set_rest_nonce.bind(this)),e("form.cart").on("found_variation",this.found_variation.bind(this)),e("form.cart").on("reset_data",this.reset_variation_data.bind(this)),this.buttonWidth=e("div.quantity").outerWidth(!0)+e(".single_add_to_cart_button").outerWidth(),e(this.container).css("max-width",this.buttonWidth+"px")},wc_stripe.ProductGateway.prototype.get_quantity=function(){return parseInt(e('[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_product_data();i.price=e.display_price,i.needs_shipping=!e.is_virtual,this.set_product_data(i),this.enable_payment_button()},wc_stripe.ProductGateway.prototype.reset_variation_data=function(){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 e('[name="variation_id"]').length>0},wc_stripe.ProductGateway.prototype.needs_shipping=function(){return this.get_product_data().needs_shipping},wc_stripe.ProductGateway.prototype.get_product_data=function(){return e("#wc_stripe_product_data").data("product")},wc_stripe.ProductGateway.prototype.set_product_data=function(t){e("#wc_stripe_product_data").data("product",t)},wc_stripe.ProductGateway.prototype.add_to_cart=function(){return new Promise(function(t,i){this.block(),e.ajax({url:this.params.routes.add_to_cart,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()?e('[name="variation_id"]').val():0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(a,n,s){this.unblock(),e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",s.getResponseHeader("X-WP-Nonce")),a.code?(this.submit_error(a.message),i(a)):(this.set_total_price(a.data.total),this.set_total_price_cents(a.data.totalCents),this.set_display_items(a.data.displayItems),t(a.data))}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CartGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.woocommerce",e(document.body).on("updated_wc_div",this.updated_html.bind(this)),e(document.body).on("updated_cart_totals",this.updated_html.bind(this))},wc_stripe.CartGateway.prototype.needs_shipping=function(){return 1===e("#wc_stripe_needs_shipping").data("value")},wc_stripe.CartGateway.prototype.submit_error=function(t){this.submit_message(t)},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.GooglePay=function(){};const a={apiVersion:2,apiVersionMinor:0},n={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}};wc_stripe.GooglePay.prototype.address_mappings=function(t){return{name:{set:function(t,i){var a=t.split(" ");e(i+"_first_name").val(a[0]),e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+e(t+"_last_name").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){return e(t+"_postcode").val()}},countryCode:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},phoneNumber:{set:function(t,i){e("#billing_phone").val(t)},get:function(){return"#billing_phone".val()}},address1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},address2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},locality:{set:function(t,i){e(i+"_city").val(t)},get:function(t){return e(t+"_city").val()}},administrativeArea:{set:function(t,i){e(i+"_state").val(t)},get:function(t){return e(t+"_state").val()}}}},wc_stripe.GooglePay.prototype.serialize_form=function(t){return e.extend({},wc_stripe.BaseGateway.prototype.serialize_form.apply(this,arguments),{order_review:!this.dynamic_price_enabled()})},wc_stripe.GooglePay.prototype.populate_address_fields=function(t){var i=t.paymentMethodData.info.billingAddress,a=this.address_mappings();for(var n in i)a[n]&&a[n].set.call(this,i[n],"#billing");if(t.shippingAddress)for(var n in t.shippingAddress)a[n]&&a[n].set.call(this,t.shippingAddress[n],"#shipping");t.email&&e("#billing_email").val(t.email),this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},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(t){return new Promise(function(i,a){e.when(e.ajax({url:this.params.routes.payment_data,dataType:"json",method:"POST",data:{shipping_address:this.map_address(t.shippingAddress),shipping_methods:this.map_shipping_methods(t.shippingOptionData.id),shipping_method_id:t.shippingOptionData.id},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)})).done(function(t){t.code?a(t.data.data):i(t.data)}.bind(this)).fail(function(){a()}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.on_payment_data_changed=function(t){return new Promise(function(e,i){this.update_payment_data(t).then(function(i){e(i.paymentRequestUpdate),this.set_selected_shipping_methods(i.shipping_methods),this.payment_data_updated(i,t)}.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_googlepay_display_items=function(){return e("#googlepay_display_items").data("items")},wc_stripe.GooglePay.prototype.set_googlepay_display_items=function(t){e("#googlepay_display_items").data("items",t)},wc_stripe.GooglePay.prototype.get_shipping_options=function(){return e("#googlepay_shipping_options").data("items")},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.dynamic_price_enabled=function(){return"1"===this.params.dynamic_price},wc_stripe.GooglePay.prototype.get_payment_options=function(){var t={environment:this.params.environment,merchantInfo:this.get_merchant_info()};return this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?t.paymentDataCallbacks={onPaymentDataChanged:this.on_payment_data_changed.bind(this),onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}.bind(this)}:t.paymentDataCallbacks={onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}}),t},wc_stripe.GooglePay.prototype.build_payment_request=function(){var t=e.extend({},a,{emailRequired:!0,merchantInfo:this.get_merchant_info(),allowedPaymentMethods:[e.extend({type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":this.params.api_key}}},n)],shippingAddressRequired:this.needs_shipping()&&this.get_total_price_cents()>0,transactionInfo:{currencyCode:this.get_currency(),totalPriceStatus:"ESTIMATED",totalPrice:this.get_total_price().toString(),displayItems:this.get_googlepay_display_items(),totalPriceLabel:this.params.total_price_label}});return t.allowedPaymentMethods[0].parameters.billingAddressRequired=!0,t.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:e("#billing_phone").length>0},this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?(t.shippingAddressParameters={},t.shippingOptionRequired=!0,t.shippingOptionParameters={shippingOptions:this.get_shipping_options()},t.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]):t.callbackIntents=["PAYMENT_AUTHORIZATION"]),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 i=e.extend({},a);i.allowedPaymentMethods=[n],this.paymentsClient.isReadyToPay(i).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=e(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.populate_address_fields(t),this.on_token_received(e)}.bind(this)).catch(function(t){"CANCELED"!==t.statusCode&&(t.statusMessage&&t.statusMessage.indexOf("paymentDataRequest.callbackIntent")>-1?this.submit_error_code("DEVELOPER_ERROR_WHITELIST"):this.submit_error(t.statusMessage))}.bind(this))},wc_stripe.ApplePay=function(){},wc_stripe.ApplePay.prototype.initialize=function(){e(document.body).on("click",".apple-pay-button",this.start.bind(this)),this.createPaymentRequest(),this.canMakePayment()},wc_stripe.ApplePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.params.button),this.append_button()},wc_stripe.ApplePay.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.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.canMakePayment(),this.paymentRequestButton=this.createPaymentRequestButton(),this.paymentRequestButton.on("click",this.button_click.bind(this))},wc_stripe.PaymentRequest.prototype.button_click=function(t){},wc_stripe.PaymentRequest.prototype.createPaymentRequestButton=function(){return 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(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&!i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.PaymentRequest.prototype.create_button=function(){this.paymentRequestButton.mount("#wc-stripe-payment-request-container")}}(window,jQuery);
1
+ !function(t,e){t.wc_stripe={};var i=Stripe(wc_stripe_params_v3.api_key);wc_stripe.BaseGateway=function(t){this.params=t,this.gateway_id=this.params.gateway_id,this.token_selector=this.params.token_selector,this.saved_method_selector=this.params.saved_method_selector,this.payment_intent_selector=this.params.payment_intent_selector,this.payment_token_received=!1,this.stripe=i,this.elements=i.elements(e.extend({},{locale:"auto"},this.get_element_options())),this.initialize()},wc_stripe.BaseGateway.prototype.get_page=function(){return wc_stripe_params_v3.page},wc_stripe.BaseGateway.prototype.set_nonce=function(t){e(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 e('[name="payment_method"]:checked').val()===this.gateway_id},wc_stripe.BaseGateway.prototype.is_saved_method_selected=function(){return this.is_gateway_selected()&&"saved"===e('[name="'+this.gateway_id+'_payment_type_key"]:checked').val()},wc_stripe.BaseGateway.prototype.has_checkout_error=function(){return e("#wc_stripe_checkout_error").length>0&&this.is_gateway_selected()},wc_stripe.BaseGateway.prototype.submit_error=function(t){-1==t.indexOf("</ul>")&&(t='<div class="woocommerce-error">'+t+"</div>"),this.submit_message(t)},wc_stripe.BaseGateway.prototype.submit_error_code=function(t){},wc_stripe.BaseGateway.prototype.submit_message=function(t){e(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove();var i=e(this.message_container);i.closest("form").length&&(i=i.closest("form")),i.prepend(t),i.removeClass("processing").unblock(),i.find(".input-text, select, input:checkbox").blur(),e("html, body").animate({scrollTop:i.offset().top-100},1e3)},wc_stripe.BaseGateway.prototype.get_first_name=function(t){return e("#"+t+"_first_name").val()},wc_stripe.BaseGateway.prototype.get_last_name=function(t){return e("#"+t+"_last_name").val()},wc_stripe.BaseGateway.prototype.should_save_method=function(){return e("#"+this.gateway_id+"_save_source_key").is(":checked")},wc_stripe.BaseGateway.prototype.is_add_payment_method_page=function(){return e(document.body).hasClass("woocommerce-add-payment-method")},wc_stripe.BaseGateway.prototype.get_selected_payment_method=function(){return e(this.saved_method_selector).val()},wc_stripe.BaseGateway.prototype.needs_shipping=function(){return"1"===this.params.needs_shipping},wc_stripe.BaseGateway.prototype.get_currency=function(){return e("#wc_stripe_currency").val()},wc_stripe.BaseGateway.prototype.get_country=function(){return e("#wc_stripe_country").val()},wc_stripe.BaseGateway.prototype.get_customer_name=function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()},wc_stripe.BaseGateway.prototype.get_customer_email=function(){return e("#billing_email").val()},wc_stripe.BaseGateway.prototype.get_address_field_hash=function(t){for(var i=["_first_name","_last_name","_address_1","_address_2","_postcode","_city","_state","_country"],a="",n=0;n<i.length;n++)a+=e(t+i[n]).val()+"_";return a},wc_stripe.BaseGateway.prototype.block=function(){e.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.BaseGateway.prototype.unblock=function(){e.unblockUI()},wc_stripe.BaseGateway.prototype.get_form=function(){return e(this.token_selector).closest("form")},wc_stripe.BaseGateway.prototype.get_total_price=function(){return e("#wc_stripe_order_total").data("amount")},wc_stripe.BaseGateway.prototype.get_total_price_cents=function(){return e("#wc_stripe_order_total_cents").data("amount")},wc_stripe.BaseGateway.prototype.set_total_price=function(t){e("#wc_stripe_order_total").data("amount",t)},wc_stripe.BaseGateway.prototype.set_total_price_cents=function(t){e("#wc_stripe_order_total_cents").data("amount",t)},wc_stripe.BaseGateway.prototype.set_payment_method=function(t){e('[name="payment_method"][value="'+t+'"]').prop("checked",!0).trigger("click")},wc_stripe.BaseGateway.prototype.set_selected_shipping_methods=function(t){if(t&&e('[name^="shipping_method"]').length)for(var i in t){var a=t[i];e('[name="shipping_method['+i+']"][value="'+a+'"]').prop("checked",!0).trigger("change")}},wc_stripe.BaseGateway.prototype.on_token_received=function(t){this.payment_token_received=!0,e(this.token_selector).val(t.id),this.process_checkout()},wc_stripe.BaseGateway.prototype.createPaymentRequest=function(){this.paymentRequest=i.paymentRequest(this.get_payment_request_options()),this.needs_shipping()&&(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))},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:!0,requestPayerEmail:!0,requestPayerPhone:!0,requestShipping:this.needs_shipping()},e=this.get_display_items(),i=this.get_shipping_options();return e&&(t.displayItems=e),this.needs_shipping()&&i&&(t.shippingOptions=i),t},wc_stripe.BaseGateway.prototype.get_payment_request_update=function(t){var i={currency:this.get_currency().toLowerCase(),total:{amount:parseInt(this.get_total_price_cents()),label:this.params.total_label,pending:!0}},a=this.get_display_items(),n=this.get_shipping_options();return a&&(i.displayItems=a),this.needs_shipping()&&n&&(i.shippingOptions=n),t&&(i=e.extend(!0,{},i,t)),i},wc_stripe.BaseGateway.prototype.get_display_items=function(){return e("#wc_stripe_display_items").data("items")},wc_stripe.BaseGateway.prototype.set_display_items=function(t){e("#wc_stripe_display_items").data("items",t)},wc_stripe.BaseGateway.prototype.get_shipping_options=function(){return e("#wc_stripe_shipping_options").data("items")},wc_stripe.BaseGateway.prototype.set_shipping_options=function(t){e("#wc_stripe_shipping_options").data("items",t)},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(e){try{this.payment_response=e,this.populate_checkout_fields(e),e.complete("success"),this.on_token_received(e.paymentMethod)}catch(e){t.alert(e)}},wc_stripe.BaseGateway.prototype.populate_checkout_fields=function(t){e(this.token_selector).val(t.paymentMethod.id),this.populate_address_fields(t)},wc_stripe.BaseGateway.prototype.populate_address_fields=function(t){var i=this.address_mappings();if(t.payerName&&i.payerName.set(t.payerName),t.payerEmail&&i.payerEmail.set(t.payerEmail),t.payerPhone&&i.payerPhone.set(t.payerPhone),t.shippingAddress){var a=t.shippingAddress;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#shipping")}if(t.paymentMethod.billing_details.address){a=t.paymentMethod.billing_details.address;for(var n in a)i[n]&&i[n].set.call(this,a[n],"#billing")}this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},wc_stripe.BaseGateway.prototype.address_mappings=function(){return{payerName:{set:function(t,i){var a=t.split(" ");a.length>0&&e("#billing_first_name").val(a[0]),a.length>1&&e("#billing_last_name").val(a[1])},get:function(t){return e("#billing_first_name").val()+" "+e("#billing_last_name").val()}},payerEmail:{set:function(t){e("#billing_email").val(t)},get:function(){return e("#billing_email").val()}},payerPhone:{set:function(t){e("#billing_phone").val(t)},get:function(){return e("#billing_phone").val()}},recipient:{set:function(t,i){var a=t.split(" ");a.length>0&&e(i+"_first_name").val(a[0]),a.length>1&&e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+" "+e(t+"_last_name").val()}},country:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},addressLine:{set:function(t,i){t.length>0&&e(i+"_address_1").val(t[0]),t.length>1&&e(i+"_address_2").val(t[1])},get:function(t){return[e(t+"_address_1").val(),e(t+"_address_2").val()]}},line1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},line2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},region:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},state:{set:function(t,i){e(i+"_state").val(t)},get:function(t){e(t+"_state").val()}},city:{set:function(t,i){e(i+"_city").val(t)},get:function(t){e(t+"_city").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}},postal_code:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){e(t+"_postcode").val()}}}},wc_stripe.BaseGateway.prototype.process_checkout=function(){return new Promise(function(i,a){this.block(),e.ajax({url:this.params.routes.checkout,method:"POST",dataType:"json",data:e.extend({},this.serialize_form(this.get_form()),{payment_method:this.gateway_id,page_id:this.get_page()}),beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.reload?t.location.reload():"success"===e.result?t.location=e.redirect:(e.messages&&this.submit_error(e.messages),this.unblock())}.bind(this)).fail(function(t,e,i){this.unblock(),this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.serialize_form=function(t){var i=t.find("input").filter(function(t,i){return!e(i).is('[name^="add-to-cart"]')}.bind(this)).serializeArray(),a={};for(var n in i){var s=i[n];a[s.name]=s.value}return a.payment_method=this.gateway_id,a},wc_stripe.BaseGateway.prototype.map_shipping_methods=function(t){var e={};if("default"!==t){var i=t.match(/^(\d):(.+)$/);i.length>1&&(e[i[1]]=i[2])}return e},wc_stripe.BaseGateway.prototype.maybe_set_ship_to_different=function(){e('[name="ship_to_different_address"]').length&&e('[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(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_address,method:"POST",dataType:"json",data:{address:this.map_address(t.shippingAddress),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.BaseGateway.prototype.update_shipping_method=function(t){return new Promise(function(i,a){e.ajax({url:this.params.routes.shipping_method,method:"POST",dataType:"json",data:{shipping_methods:this.map_shipping_methods(t.shippingOption.id),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(e){e.code?(t.updateWith(e.data.newData),a(e.data)):(this.set_selected_shipping_methods(e.data.shipping_methods),t.updateWith(e.data.newData),i(e.data))}.bind(this)).fail(function(t,e,i){this.submit_error(i)}.bind(this))}.bind(this))},wc_stripe.CheckoutGateway=function(){this.container=this.message_container="li.payment_method_"+this.gateway_id,this.banner_container="li.banner_payment_method_"+this.gateway_id,e(document.body).on("update_checkout",this.update_checkout.bind(this)),e(document.body).on("updated_checkout",this.updated_checkout.bind(this)),e(document.body).on("checkout_error",this.checkout_error.bind(this)),e(this.token_selector).closest("form").on("checkout_place_order_"+this.gateway_id,this.checkout_place_order.bind(this)),e(document.body).on("wc_stripe_new_method_"+this.gateway_id,this.on_show_new_methods.bind(this)),e(document.body).on("wc_stripe_saved_method_"+this.gateway_id,this.on_show_saved_methods.bind(this)),e(document.body).on("wc_stripe_payment_method_selected",this.on_payment_method_selected.bind(this)),this.banner_enabled()&&e(".woocommerce-billing-fields").length&&e(".wc-stripe-banner-checkout").css("max-width",e(".woocommerce-billing-fields").outerWidth(!0)),this.order_review()},wc_stripe.CheckoutGateway.prototype.order_review=function(){var e=t.location.href.match(/order_review.+payment_method=([\w]+).+payment_nonce=(.+)/);if(e&&e.length>1){var i=e[1],a=e[2];this.gateway_id===i&&(this.payment_token_received=!0,this.set_nonce(a),this.set_use_new_option(!0))}},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!(e('[name="terms"]').length&&!e('[name="terms"]').is(":checked"))},wc_stripe.CheckoutGateway.prototype.get_payment_method=function(){return e('[name="payment_method"]:checked').val()},wc_stripe.CheckoutGateway.prototype.set_use_new_option=function(t){e("#"+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,e(this.token_selector).val(t.id),this.hide_payment_button(),this.show_place_order()},wc_stripe.CheckoutGateway.prototype.block=function(){e("form.checkout").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},wc_stripe.CheckoutGateway.prototype.unblock=function(){e("form.checkout").unblock()},wc_stripe.CheckoutGateway.prototype.hide_place_order=function(){e("#place_order").addClass("wc-stripe-hide")},wc_stripe.CheckoutGateway.prototype.show_place_order=function(){e("#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,e('[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.ProductGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.product",e(document.body).on("wc_stripe_updated_rest_nonce",this.set_rest_nonce.bind(this)),e("form.cart").on("found_variation",this.found_variation.bind(this)),e("form.cart").on("reset_data",this.reset_variation_data.bind(this)),this.buttonWidth=e("div.quantity").outerWidth(!0)+e(".single_add_to_cart_button").outerWidth(),e(this.container).css("max-width",this.buttonWidth+"px")},wc_stripe.ProductGateway.prototype.get_quantity=function(){return parseInt(e('[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_product_data();i.price=e.display_price,i.needs_shipping=!e.is_virtual,i.variation=e,this.set_product_data(i),this.enable_payment_button()},wc_stripe.ProductGateway.prototype.reset_variation_data=function(){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 e('[name="variation_id"]').length>0},wc_stripe.ProductGateway.prototype.needs_shipping=function(){return this.get_product_data().needs_shipping},wc_stripe.ProductGateway.prototype.get_product_data=function(){return e("#wc_stripe_product_data").data("product")},wc_stripe.ProductGateway.prototype.set_product_data=function(t){e("#wc_stripe_product_data").data("product",t)},wc_stripe.ProductGateway.prototype.add_to_cart=function(){return new Promise(function(t,i){this.block(),e.ajax({url:this.params.routes.add_to_cart,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()?e('[name="variation_id"]').val():0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(a,n,s){this.unblock(),e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",s.getResponseHeader("X-WP-Nonce")),a.code?(this.submit_error(a.message),i(a)):(this.set_total_price(a.data.total),this.set_total_price_cents(a.data.totalCents),this.set_display_items(a.data.displayItems),t(a.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(i,a){e.ajax({url:this.params.routes.cart_calculation,method:"POST",dataType:"json",data:{product_id:e("#product_id").val(),variation_id:this.is_variable_product()&&t?t:0,qty:e('[name="quantity"]').val(),payment_method:this.gateway_id},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)}).done(function(t,a,n){e(document.body).triggerHandler("wc_stripe_updated_rest_nonce",n.getResponseHeader("X-WP-Nonce")),t.code?this.cart_calculation_error=!0:(this.set_total_price(t.data.total),this.set_total_price_cents(t.data.totalCents),this.set_display_items(t.data.displayItems),i(t.data))}.bind(this)).fail(function(t,e,i){}.bind(this))}.bind(this))},wc_stripe.CartGateway=function(){this.container="li.payment_method_"+this.gateway_id,this.message_container="div.woocommerce",e(document.body).on("updated_wc_div",this.updated_html.bind(this)),e(document.body).on("updated_cart_totals",this.updated_html.bind(this))},wc_stripe.CartGateway.prototype.needs_shipping=function(){return 1===e("#wc_stripe_needs_shipping").data("value")},wc_stripe.CartGateway.prototype.submit_error=function(t){this.submit_message(t)},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.GooglePay=function(){};const a={apiVersion:2,apiVersionMinor:0},n={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]}};wc_stripe.GooglePay.prototype.address_mappings=function(t){return{name:{set:function(t,i){var a=t.split(" ");e(i+"_first_name").val(a[0]),e(i+"_last_name").val(a[1])},get:function(t){return e(t+"_first_name").val()+e(t+"_last_name").val()}},postalCode:{set:function(t,i){e(i+"_postcode").val(t)},get:function(t){return e(t+"_postcode").val()}},countryCode:{set:function(t,i){e(i+"_country").val(t)},get:function(t){return e(t+"_country").val()}},phoneNumber:{set:function(t,i){e("#billing_phone").val(t)},get:function(){return"#billing_phone".val()}},address1:{set:function(t,i){e(i+"_address_1").val(t)},get:function(t){return e(t+"_address_1").val()}},address2:{set:function(t,i){e(i+"_address_2").val(t)},get:function(t){return e(t+"_address_2").val()}},locality:{set:function(t,i){e(i+"_city").val(t)},get:function(t){return e(t+"_city").val()}},administrativeArea:{set:function(t,i){e(i+"_state").val(t)},get:function(t){return e(t+"_state").val()}}}},wc_stripe.GooglePay.prototype.serialize_form=function(t){return e.extend({},wc_stripe.BaseGateway.prototype.serialize_form.apply(this,arguments),{order_review:!this.dynamic_price_enabled()})},wc_stripe.GooglePay.prototype.populate_address_fields=function(t){var i=t.paymentMethodData.info.billingAddress,a=this.address_mappings();for(var n in i)a[n]&&a[n].set.call(this,i[n],"#billing");if(t.shippingAddress)for(var n in t.shippingAddress)a[n]&&a[n].set.call(this,t.shippingAddress[n],"#shipping");t.email&&e("#billing_email").val(t.email),this.maybe_set_ship_to_different(),e('[name="billing_country"]').trigger("change")},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(t){return new Promise(function(i,a){e.when(e.ajax({url:this.params.routes.payment_data,dataType:"json",method:"POST",data:{shipping_address:this.map_address(t.shippingAddress),shipping_methods:this.map_shipping_methods(t.shippingOptionData.id),shipping_method_id:t.shippingOptionData.id,page_id:this.get_page()},beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",this.params.rest_nonce)}.bind(this)})).done(function(t){t.code?a(t.data.data):i(t.data)}.bind(this)).fail(function(){a()}.bind(this))}.bind(this))},wc_stripe.GooglePay.prototype.on_payment_data_changed=function(t){return new Promise(function(e,i){this.update_payment_data(t).then(function(i){e(i.paymentRequestUpdate),this.set_selected_shipping_methods(i.shipping_methods),this.payment_data_updated(i,t)}.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_googlepay_display_items=function(){return e("#googlepay_display_items").data("items")},wc_stripe.GooglePay.prototype.set_googlepay_display_items=function(t){e("#googlepay_display_items").data("items",t)},wc_stripe.GooglePay.prototype.get_shipping_options=function(){return e("#googlepay_shipping_options").data("items")},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.dynamic_price_enabled=function(){return"1"===this.params.dynamic_price},wc_stripe.GooglePay.prototype.get_payment_options=function(){var t={environment:this.params.environment,merchantInfo:this.get_merchant_info()};return this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?t.paymentDataCallbacks={onPaymentDataChanged:this.on_payment_data_changed.bind(this),onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}.bind(this)}:t.paymentDataCallbacks={onPaymentAuthorized:function(t){return new Promise(function(t,e){t({transactionState:"SUCCESS"})}.bind(this))}}),t},wc_stripe.GooglePay.prototype.build_payment_request=function(){var t=e.extend({},a,{emailRequired:!0,merchantInfo:this.get_merchant_info(),allowedPaymentMethods:[e.extend({type:"CARD",tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":"2018-10-31","stripe:publishableKey":this.params.api_key}}},n)],shippingAddressRequired:this.needs_shipping()&&this.get_total_price_cents()>0,transactionInfo:{currencyCode:this.get_currency(),totalPriceStatus:"ESTIMATED",totalPrice:this.get_total_price().toString(),displayItems:this.get_googlepay_display_items(),totalPriceLabel:this.params.total_price_label}});return t.allowedPaymentMethods[0].parameters.billingAddressRequired=!0,t.allowedPaymentMethods[0].parameters.billingAddressParameters={format:"FULL",phoneNumberRequired:e("#billing_phone").length>0},this.dynamic_price_enabled()&&(this.needs_shipping()&&this.get_total_price_cents()>0?(t.shippingAddressParameters={},t.shippingOptionRequired=!0,t.shippingOptionParameters={shippingOptions:this.get_shipping_options()},t.callbackIntents=["SHIPPING_ADDRESS","SHIPPING_OPTION","PAYMENT_AUTHORIZATION"]):t.callbackIntents=["PAYMENT_AUTHORIZATION"]),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 i=e.extend({},a);i.allowedPaymentMethods=[n],this.paymentsClient.isReadyToPay(i).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=e(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.populate_address_fields(t),this.on_token_received(e)}.bind(this)).catch(function(t){"CANCELED"!==t.statusCode&&(t.statusMessage&&t.statusMessage.indexOf("paymentDataRequest.callbackIntent")>-1?this.submit_error_code("DEVELOPER_ERROR_WHITELIST"):this.submit_error(t.statusMessage))}.bind(this))},wc_stripe.ApplePay=function(){},wc_stripe.ApplePay.prototype.initialize=function(){e(document.body).on("click",".apple-pay-button",this.start.bind(this)),this.createPaymentRequest(),this.canMakePayment()},wc_stripe.ApplePay.prototype.create_button=function(){this.$button&&this.$button.remove(),this.$button=e(this.params.button),this.append_button()},wc_stripe.ApplePay.prototype.canMakePayment=function(){return new Promise(function(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.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.canMakePayment(),this.paymentRequestButton=this.createPaymentRequestButton(),this.paymentRequestButton.on("click",this.button_click.bind(this))},wc_stripe.PaymentRequest.prototype.button_click=function(t){},wc_stripe.PaymentRequest.prototype.createPaymentRequestButton=function(){return 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(t,i){this.paymentRequest.canMakePayment().then(function(i){i&&!i.applePay&&(this.can_pay=!0,this.create_button(),e(this.container).show(),t(i))}.bind(this))}.bind(this))},wc_stripe.PaymentRequest.prototype.create_button=function(){this.paymentRequestButton.mount("#wc-stripe-payment-request-container")}}(window,jQuery);
i18n/languages/woo-stripe-payment.pot CHANGED
@@ -2,7 +2,7 @@
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: woo-stripe-payment\n"
5
- "POT-Creation-Date: 2019-12-17 21:50-0800\n"
6
  "PO-Revision-Date: 2019-08-16 14:27-0700\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
@@ -21,7 +21,7 @@ msgstr ""
21
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:69
22
  #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:53
23
  #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:71
24
- #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:96
25
  #, php-format
26
  msgid "Error processing payment. Reason: %s"
27
  msgstr ""
@@ -43,63 +43,63 @@ msgstr ""
43
  msgid "Order charge successful in Stripe. Charge: %s. Payment Method: %s"
44
  msgstr ""
45
 
46
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:133
47
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:196
48
  #, php-format
49
  msgid "Order amount captured in Stripe. Amount: %s"
50
  msgstr ""
51
 
52
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:137
53
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:200
54
  #, php-format
55
  msgid "Error capturing charge in Stripe. Reason: %s"
56
  msgstr ""
57
 
58
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:147
59
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:221
60
  #, php-format
61
  msgid "Error voiding charge. Reason: %s"
62
  msgstr ""
63
 
64
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:149
65
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:223
66
  msgid "Charge voided in Stripe."
67
  msgstr ""
68
 
69
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:176
70
  #, php-format
71
  msgid ""
72
  "Recurring payment for subscription failed. Reason: %s. Payment method: %s"
73
  msgstr ""
74
 
75
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:180
76
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:262
77
  #, php-format
78
  msgid "Recurring payment captured in Stripe. Payment method: %s"
79
  msgstr ""
80
 
81
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:182
82
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:220
83
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:264
84
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:330
85
  #, php-format
86
  msgid "Recurring payment authorized in Stripe. Payment method: %s"
87
  msgstr ""
88
 
89
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:194
90
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:296
91
  #, php-format
92
  msgid "Error deleting Stripe card. Token Id: %s"
93
  msgstr ""
94
 
95
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:214
96
  #, php-format
97
  msgid ""
98
  "Pre-order payment for subscription failed. Reason: %s. Payment method: %s"
99
  msgstr ""
100
 
101
- #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:218
102
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:328
103
  #, php-format
104
  msgid "Pre-order payment captured in Stripe. Payment method: %s"
105
  msgstr ""
@@ -138,94 +138,98 @@ msgstr ""
138
  msgid "authorization"
139
  msgstr ""
140
 
141
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:118
142
  msgid "A new payment method is required."
143
  msgstr ""
144
 
145
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:251
146
  #, php-format
147
  msgid "Recurring payment for order failed. Reason: %s"
148
  msgstr ""
149
 
150
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:268
151
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:334
152
  #, php-format
153
  msgid "Customer must manually complete payment for payment method %s"
154
  msgstr ""
155
 
156
- #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:317
157
  #, php-format
158
  msgid "Pre-order payment for order failed. Reason: %s"
159
  msgstr ""
160
 
161
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:294
162
  msgid ""
163
  "Please read and accept the terms and conditions to proceed with your order."
164
  msgstr ""
165
 
166
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:307
167
- #: includes/controllers/class-wc-stripe-controller-cart.php:99
168
- #: includes/controllers/class-wc-stripe-controller-cart.php:139
169
- #: includes/controllers/class-wc-stripe-controller-googlepay.php:116
170
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:70
171
  msgid "Total"
172
  msgstr ""
173
 
174
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:365
175
  #, php-format
176
  msgid "Error saving your payment method. Reason: %s"
177
  msgstr ""
178
 
179
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:376
180
  #, php-format
181
  msgid "Error saving payment method. Reason: %s"
182
  msgstr ""
183
 
184
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:388
185
  msgid "Transaction Id cannot be empty."
186
  msgstr ""
187
 
188
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:395
189
  #, php-format
190
  msgid "Order refunded in Stripe. Amount: %s"
191
  msgstr ""
192
 
193
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:589
 
 
 
 
194
  #: includes/admin/meta-boxes/views/html-order-pay.php:42
195
  msgid "New Card"
196
  msgstr ""
197
 
198
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:593
199
  #: includes/admin/meta-boxes/views/html-order-pay.php:30
200
  msgid "Saved Cards"
201
  msgstr ""
202
 
203
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:802
204
  #, php-format
205
  msgid "Attemp to save payment method failed. Reason: %s"
206
  msgstr ""
207
 
208
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:822
209
  msgid ""
210
  "We were not able to save your payment method. To prevent billing issues with "
211
  "your subscription, please add a payment method to the subscription."
212
  msgstr ""
213
 
214
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:824
215
  #, php-format
216
  msgid "We were not able to save your payment method. Reason: %s"
217
  msgstr ""
218
 
219
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:856
220
  msgid "Payment Method Token"
221
  msgstr ""
222
 
223
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:882
224
  #, php-format
225
  msgid "Error saving payment method for subscription. Reason: %s"
226
  msgstr ""
227
 
228
- #: includes/abstract/abstract-wc-payment-gateway-stripe.php:935
229
  #, php-format
230
  msgid "Order %s from %s"
231
  msgstr ""
@@ -585,12 +589,12 @@ msgstr ""
585
  msgid "Error capturing charge. Reason: %s"
586
  msgstr ""
587
 
588
- #: includes/class-wc-stripe-redirect-handler.php:45
589
  #, php-format
590
  msgid "Error retrieving payment source. Reason: %s"
591
  msgstr ""
592
 
593
- #: includes/class-wc-stripe-redirect-handler.php:49
594
  msgid "Payment authorization failed. Please select another payment method."
595
  msgstr ""
596
 
@@ -599,18 +603,18 @@ msgstr ""
599
  msgid "%1$s is an invalid controller name."
600
  msgstr ""
601
 
602
- #: includes/controllers/class-wc-stripe-controller-cart.php:69
603
  msgid "Quantity must be greater than zero."
604
  msgstr ""
605
 
606
- #: includes/controllers/class-wc-stripe-controller-checkout.php:131
607
  #, php-format
608
  msgid ""
609
  "Some required fields were missing. Please click %shere%s to complete your "
610
  "payment."
611
  msgstr ""
612
 
613
- #: includes/controllers/class-wc-stripe-controller-checkout.php:164
614
  msgid "Please review your order details then click Place Order."
615
  msgstr ""
616
 
@@ -642,7 +646,7 @@ msgid ""
642
  "Stripe dashboard"
643
  msgstr ""
644
 
645
- #: includes/controllers/class-wc-stripe-controller-googlepay.php:83
646
  msgid "Your shipping address is not serviceable."
647
  msgstr ""
648
 
@@ -675,22 +679,30 @@ msgstr ""
675
  msgid "Invalid signaute received. Verify that your webhook secret is correct."
676
  msgstr ""
677
 
678
- #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:19
679
  msgid "ACH"
680
  msgstr ""
681
 
682
- #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:22
683
  msgid "Stripe ACH"
684
  msgstr ""
685
 
686
- #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:23
687
  msgid "ACH gateway that integrates with your Stripe account."
688
  msgstr ""
689
 
690
- #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:25
691
  msgid "Bank Payment"
692
  msgstr ""
693
 
 
 
 
 
 
 
 
 
694
  #: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:14
695
  #: includes/gateways/settings/applepay-settings.php:17
696
  msgid "Apple Pay"
@@ -874,28 +886,28 @@ msgid "Please update you product quantity before using Google Pay."
874
  msgstr ""
875
 
876
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:87
877
- #: includes/wc-stripe-functions.php:365
878
  msgid "Subscription"
879
  msgstr ""
880
 
881
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:107
882
- #: includes/wc-stripe-functions.php:351
883
  msgid "Shipping"
884
  msgstr ""
885
 
886
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:114
887
  #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:187
888
- #: includes/wc-stripe-functions.php:358
889
  msgid "Tax"
890
  msgstr ""
891
 
892
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:145
893
- #: includes/wc-stripe-functions.php:416
894
  msgid "Waiting..."
895
  msgstr ""
896
 
897
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:146
898
- #: includes/wc-stripe-functions.php:417
899
  msgid "loading shipping methods..."
900
  msgstr ""
901
 
@@ -997,10 +1009,14 @@ msgid ""
997
  msgstr ""
998
 
999
  #: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:63
1000
- msgid "Adding to cart..."
1001
  msgstr ""
1002
 
1003
  #: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:64
 
 
 
 
1004
  msgid "Please select a product option before updating quantity."
1005
  msgstr ""
1006
 
@@ -1582,45 +1598,45 @@ msgstr ""
1582
  msgid "The height of the button. Max height is 64"
1583
  msgstr ""
1584
 
1585
- #: includes/tokens/class-wc-payment-token-stripe-ach.php:58
1586
- #: includes/tokens/class-wc-payment-token-stripe-ach.php:63
1587
- #: includes/tokens/class-wc-payment-token-stripe-cc.php:90
1588
  msgid "Type Ending In"
1589
  msgstr ""
1590
 
1591
- #: includes/tokens/class-wc-payment-token-stripe-ach.php:60
1592
  msgid "{bank_name} ending in {last4}"
1593
  msgstr ""
1594
 
1595
- #: includes/tokens/class-wc-payment-token-stripe-ach.php:65
1596
  msgid "{bank_name} **** {last4}"
1597
  msgstr ""
1598
 
1599
- #: includes/tokens/class-wc-payment-token-stripe-cc.php:92
1600
  msgid "{brand} ending in {last4}"
1601
  msgstr ""
1602
 
1603
- #: includes/tokens/class-wc-payment-token-stripe-cc.php:95
1604
  msgid "Type Masked Number"
1605
  msgstr ""
1606
 
1607
- #: includes/tokens/class-wc-payment-token-stripe-cc.php:100
1608
  msgid "Type Dash Masked Number"
1609
  msgstr ""
1610
 
1611
- #: includes/tokens/class-wc-payment-token-stripe-cc.php:105
1612
  msgid "Type Last 4"
1613
  msgstr ""
1614
 
1615
- #: includes/tokens/class-wc-payment-token-stripe-cc.php:110
1616
  msgid "Type Dash & Last 4"
1617
  msgstr ""
1618
 
1619
- #: includes/tokens/class-wc-payment-token-stripe-cc.php:115
1620
  msgid "Last Four"
1621
  msgstr ""
1622
 
1623
- #: includes/tokens/class-wc-payment-token-stripe-cc.php:120
1624
  msgid "Card Type"
1625
  msgstr ""
1626
 
@@ -1632,23 +1648,23 @@ msgstr ""
1632
  msgid "Please enter a valid postcode / ZIP."
1633
  msgstr ""
1634
 
1635
- #: includes/wc-stripe-functions.php:638
1636
  msgid "Bootstrap form"
1637
  msgstr ""
1638
 
1639
- #: includes/wc-stripe-functions.php:672
1640
  msgid "Simple form"
1641
  msgstr ""
1642
 
1643
- #: includes/wc-stripe-functions.php:705
1644
  msgid "Minimalist form"
1645
  msgstr ""
1646
 
1647
- #: includes/wc-stripe-functions.php:739
1648
  msgid "Inline Form"
1649
  msgstr ""
1650
 
1651
- #: includes/wc-stripe-functions.php:775
1652
  msgid "Rounded Form"
1653
  msgstr ""
1654
 
@@ -1661,7 +1677,7 @@ msgstr ""
1661
  msgid "Your PHP version is %s but Stripe requires version 5.4+."
1662
  msgstr ""
1663
 
1664
- #: templates/cart/payment-methods.php:20
1665
  msgid "or"
1666
  msgstr ""
1667
 
@@ -1704,6 +1720,18 @@ msgstr ""
1704
  msgid "password"
1705
  msgstr ""
1706
 
 
 
 
 
 
 
 
 
 
 
 
 
1707
  #: templates/checkout/credit-card.php:17
1708
  msgid "Save Card"
1709
  msgstr ""
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: woo-stripe-payment\n"
5
+ "POT-Creation-Date: 2020-01-07 12:49-0800\n"
6
  "PO-Revision-Date: 2019-08-16 14:27-0700\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
21
  #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:69
22
  #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:53
23
  #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:71
24
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:100
25
  #, php-format
26
  msgid "Error processing payment. Reason: %s"
27
  msgstr ""
43
  msgid "Order charge successful in Stripe. Charge: %s. Payment Method: %s"
44
  msgstr ""
45
 
46
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:135
47
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:197
48
  #, php-format
49
  msgid "Order amount captured in Stripe. Amount: %s"
50
  msgstr ""
51
 
52
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:139
53
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:201
54
  #, php-format
55
  msgid "Error capturing charge in Stripe. Reason: %s"
56
  msgstr ""
57
 
58
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:149
59
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:222
60
  #, php-format
61
  msgid "Error voiding charge. Reason: %s"
62
  msgstr ""
63
 
64
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:151
65
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:224
66
  msgid "Charge voided in Stripe."
67
  msgstr ""
68
 
69
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:178
70
  #, php-format
71
  msgid ""
72
  "Recurring payment for subscription failed. Reason: %s. Payment method: %s"
73
  msgstr ""
74
 
75
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:182
76
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:263
77
  #, php-format
78
  msgid "Recurring payment captured in Stripe. Payment method: %s"
79
  msgstr ""
80
 
81
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:184
82
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:222
83
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:265
84
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:331
85
  #, php-format
86
  msgid "Recurring payment authorized in Stripe. Payment method: %s"
87
  msgstr ""
88
 
89
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:196
90
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:297
91
  #, php-format
92
  msgid "Error deleting Stripe card. Token Id: %s"
93
  msgstr ""
94
 
95
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:216
96
  #, php-format
97
  msgid ""
98
  "Pre-order payment for subscription failed. Reason: %s. Payment method: %s"
99
  msgstr ""
100
 
101
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-charge.php:220
102
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:329
103
  #, php-format
104
  msgid "Pre-order payment captured in Stripe. Payment method: %s"
105
  msgstr ""
138
  msgid "authorization"
139
  msgstr ""
140
 
141
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:119
142
  msgid "A new payment method is required."
143
  msgstr ""
144
 
145
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:252
146
  #, php-format
147
  msgid "Recurring payment for order failed. Reason: %s"
148
  msgstr ""
149
 
150
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:269
151
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:335
152
  #, php-format
153
  msgid "Customer must manually complete payment for payment method %s"
154
  msgstr ""
155
 
156
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php:318
157
  #, php-format
158
  msgid "Pre-order payment for order failed. Reason: %s"
159
  msgstr ""
160
 
161
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:299
162
  msgid ""
163
  "Please read and accept the terms and conditions to proceed with your order."
164
  msgstr ""
165
 
166
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:313
167
+ #: includes/controllers/class-wc-stripe-controller-cart.php:128
168
+ #: includes/controllers/class-wc-stripe-controller-cart.php:175
169
+ #: includes/controllers/class-wc-stripe-controller-googlepay.php:123
170
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:70
171
  msgid "Total"
172
  msgstr ""
173
 
174
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:379
175
  #, php-format
176
  msgid "Error saving your payment method. Reason: %s"
177
  msgstr ""
178
 
179
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:390
180
  #, php-format
181
  msgid "Error saving payment method. Reason: %s"
182
  msgstr ""
183
 
184
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:402
185
  msgid "Transaction Id cannot be empty."
186
  msgstr ""
187
 
188
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:409
189
  #, php-format
190
  msgid "Order refunded in Stripe. Amount: %s"
191
  msgstr ""
192
 
193
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:586
194
+ msgid "n/a"
195
+ msgstr ""
196
+
197
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:607
198
  #: includes/admin/meta-boxes/views/html-order-pay.php:42
199
  msgid "New Card"
200
  msgstr ""
201
 
202
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:611
203
  #: includes/admin/meta-boxes/views/html-order-pay.php:30
204
  msgid "Saved Cards"
205
  msgstr ""
206
 
207
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:820
208
  #, php-format
209
  msgid "Attemp to save payment method failed. Reason: %s"
210
  msgstr ""
211
 
212
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:840
213
  msgid ""
214
  "We were not able to save your payment method. To prevent billing issues with "
215
  "your subscription, please add a payment method to the subscription."
216
  msgstr ""
217
 
218
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:842
219
  #, php-format
220
  msgid "We were not able to save your payment method. Reason: %s"
221
  msgstr ""
222
 
223
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:874
224
  msgid "Payment Method Token"
225
  msgstr ""
226
 
227
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:900
228
  #, php-format
229
  msgid "Error saving payment method for subscription. Reason: %s"
230
  msgstr ""
231
 
232
+ #: includes/abstract/abstract-wc-payment-gateway-stripe.php:953
233
  #, php-format
234
  msgid "Order %s from %s"
235
  msgstr ""
589
  msgid "Error capturing charge. Reason: %s"
590
  msgstr ""
591
 
592
+ #: includes/class-wc-stripe-redirect-handler.php:48
593
  #, php-format
594
  msgid "Error retrieving payment source. Reason: %s"
595
  msgstr ""
596
 
597
+ #: includes/class-wc-stripe-redirect-handler.php:52
598
  msgid "Payment authorization failed. Please select another payment method."
599
  msgstr ""
600
 
603
  msgid "%1$s is an invalid controller name."
604
  msgstr ""
605
 
606
+ #: includes/controllers/class-wc-stripe-controller-cart.php:93
607
  msgid "Quantity must be greater than zero."
608
  msgstr ""
609
 
610
+ #: includes/controllers/class-wc-stripe-controller-checkout.php:150
611
  #, php-format
612
  msgid ""
613
  "Some required fields were missing. Please click %shere%s to complete your "
614
  "payment."
615
  msgstr ""
616
 
617
+ #: includes/controllers/class-wc-stripe-controller-checkout.php:183
618
  msgid "Please review your order details then click Place Order."
619
  msgstr ""
620
 
646
  "Stripe dashboard"
647
  msgstr ""
648
 
649
+ #: includes/controllers/class-wc-stripe-controller-googlepay.php:86
650
  msgid "Your shipping address is not serviceable."
651
  msgstr ""
652
 
679
  msgid "Invalid signaute received. Verify that your webhook secret is correct."
680
  msgstr ""
681
 
682
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:20
683
  msgid "ACH"
684
  msgstr ""
685
 
686
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:23
687
  msgid "Stripe ACH"
688
  msgstr ""
689
 
690
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:24
691
  msgid "ACH gateway that integrates with your Stripe account."
692
  msgstr ""
693
 
694
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:26
695
  msgid "Bank Payment"
696
  msgstr ""
697
 
698
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:182
699
+ msgid "Saved Banks"
700
+ msgstr ""
701
+
702
+ #: includes/gateways/class-wc-payment-gateway-stripe-ach.php:186
703
+ msgid "New Bank"
704
+ msgstr ""
705
+
706
  #: includes/gateways/class-wc-payment-gateway-stripe-applepay.php:14
707
  #: includes/gateways/settings/applepay-settings.php:17
708
  msgid "Apple Pay"
886
  msgstr ""
887
 
888
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:87
889
+ #: includes/wc-stripe-functions.php:366
890
  msgid "Subscription"
891
  msgstr ""
892
 
893
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:107
894
+ #: includes/wc-stripe-functions.php:352
895
  msgid "Shipping"
896
  msgstr ""
897
 
898
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:114
899
  #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:187
900
+ #: includes/wc-stripe-functions.php:359
901
  msgid "Tax"
902
  msgstr ""
903
 
904
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:145
905
+ #: includes/wc-stripe-functions.php:417
906
  msgid "Waiting..."
907
  msgstr ""
908
 
909
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:146
910
+ #: includes/wc-stripe-functions.php:418
911
  msgid "loading shipping methods..."
912
  msgstr ""
913
 
1009
  msgstr ""
1010
 
1011
  #: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:63
1012
+ msgid "Please update you product quantity before paying."
1013
  msgstr ""
1014
 
1015
  #: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:64
1016
+ msgid "Adding to cart..."
1017
+ msgstr ""
1018
+
1019
+ #: includes/gateways/class-wc-payment-gateway-stripe-payment-request.php:65
1020
  msgid "Please select a product option before updating quantity."
1021
  msgstr ""
1022
 
1598
  msgid "The height of the button. Max height is 64"
1599
  msgstr ""
1600
 
1601
+ #: includes/tokens/class-wc-payment-token-stripe-ach.php:61
1602
+ #: includes/tokens/class-wc-payment-token-stripe-ach.php:66
1603
+ #: includes/tokens/class-wc-payment-token-stripe-cc.php:85
1604
  msgid "Type Ending In"
1605
  msgstr ""
1606
 
1607
+ #: includes/tokens/class-wc-payment-token-stripe-ach.php:63
1608
  msgid "{bank_name} ending in {last4}"
1609
  msgstr ""
1610
 
1611
+ #: includes/tokens/class-wc-payment-token-stripe-ach.php:68
1612
  msgid "{bank_name} **** {last4}"
1613
  msgstr ""
1614
 
1615
+ #: includes/tokens/class-wc-payment-token-stripe-cc.php:87
1616
  msgid "{brand} ending in {last4}"
1617
  msgstr ""
1618
 
1619
+ #: includes/tokens/class-wc-payment-token-stripe-cc.php:90
1620
  msgid "Type Masked Number"
1621
  msgstr ""
1622
 
1623
+ #: includes/tokens/class-wc-payment-token-stripe-cc.php:95
1624
  msgid "Type Dash Masked Number"
1625
  msgstr ""
1626
 
1627
+ #: includes/tokens/class-wc-payment-token-stripe-cc.php:100
1628
  msgid "Type Last 4"
1629
  msgstr ""
1630
 
1631
+ #: includes/tokens/class-wc-payment-token-stripe-cc.php:105
1632
  msgid "Type Dash & Last 4"
1633
  msgstr ""
1634
 
1635
+ #: includes/tokens/class-wc-payment-token-stripe-cc.php:110
1636
  msgid "Last Four"
1637
  msgstr ""
1638
 
1639
+ #: includes/tokens/class-wc-payment-token-stripe-cc.php:115
1640
  msgid "Card Type"
1641
  msgstr ""
1642
 
1648
  msgid "Please enter a valid postcode / ZIP."
1649
  msgstr ""
1650
 
1651
+ #: includes/wc-stripe-functions.php:639
1652
  msgid "Bootstrap form"
1653
  msgstr ""
1654
 
1655
+ #: includes/wc-stripe-functions.php:673
1656
  msgid "Simple form"
1657
  msgstr ""
1658
 
1659
+ #: includes/wc-stripe-functions.php:706
1660
  msgid "Minimalist form"
1661
  msgstr ""
1662
 
1663
+ #: includes/wc-stripe-functions.php:740
1664
  msgid "Inline Form"
1665
  msgstr ""
1666
 
1667
+ #: includes/wc-stripe-functions.php:776
1668
  msgid "Rounded Form"
1669
  msgstr ""
1670
 
1677
  msgid "Your PHP version is %s but Stripe requires version 5.4+."
1678
  msgstr ""
1679
 
1680
+ #: templates/cart/payment-methods.php:12
1681
  msgid "or"
1682
  msgstr ""
1683
 
1720
  msgid "password"
1721
  msgstr ""
1722
 
1723
+ #: templates/checkout/ach.php:13
1724
+ msgid "pin"
1725
+ msgstr ""
1726
+
1727
+ #: templates/checkout/ach.php:13
1728
+ msgid "when required"
1729
+ msgstr ""
1730
+
1731
+ #: templates/checkout/checkout-banner.php:9
1732
+ msgid "Express Checkout"
1733
+ msgstr ""
1734
+
1735
  #: templates/checkout/credit-card.php:17
1736
  msgid "Save Card"
1737
  msgstr ""
includes/abstract/abstract-wc-payment-gateway-stripe-charge.php CHANGED
@@ -89,6 +89,8 @@ abstract class WC_Payment_Gateway_Stripe_Charge extends WC_Payment_Gateway_Strip
89
 
90
  WC ()->cart->empty_cart ();
91
 
 
 
92
  return array( 'result' => 'success',
93
  'redirect' => $order->get_checkout_order_received_url ()
94
  );
@@ -222,4 +224,14 @@ abstract class WC_Payment_Gateway_Stripe_Charge extends WC_Payment_Gateway_Strip
222
  $this->save_order_meta ( $order, $charge );
223
  }
224
  }
 
 
 
 
 
 
 
 
 
 
225
  }
89
 
90
  WC ()->cart->empty_cart ();
91
 
92
+ $this->trigger_post_payment_processes ( $order, $this );
93
+
94
  return array( 'result' => 'success',
95
  'redirect' => $order->get_checkout_order_received_url ()
96
  );
224
  $this->save_order_meta ( $order, $charge );
225
  }
226
  }
227
+
228
+ /**
229
+ *
230
+ * {@inheritDoc}
231
+ *
232
+ * @see WC_Payment_Gateway_Stripe::get_payment_method_from_charge()
233
+ */
234
+ public function get_payment_method_from_charge($charge) {
235
+ return $charge->source->id;
236
+ }
237
  }
includes/abstract/abstract-wc-payment-gateway-stripe-payment-intent.php CHANGED
@@ -102,6 +102,7 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
102
  $this->set_payment_save_error ( $order, $this->wp_error );
103
  }
104
  }
 
105
 
106
  return array( 'result' => 'success',
107
  'redirect' => $order->get_checkout_order_received_url ()
@@ -335,4 +336,13 @@ abstract class WC_Payment_Gateway_Stripe_Payment_Intent extends WC_Payment_Gatew
335
  }
336
  }
337
  }
 
 
 
 
 
 
 
 
 
338
  }
102
  $this->set_payment_save_error ( $order, $this->wp_error );
103
  }
104
  }
105
+ $this->trigger_post_payment_processes ( $order, $this );
106
 
107
  return array( 'result' => 'success',
108
  'redirect' => $order->get_checkout_order_received_url ()
336
  }
337
  }
338
  }
339
+
340
+ /**
341
+ *
342
+ * {@inheritDoc}
343
+ * @see WC_Payment_Gateway_Stripe::get_payment_method_from_charge()
344
+ */
345
+ public function get_payment_method_from_charge($charge) {
346
+ return $charge->payment_method;
347
+ }
348
  }
includes/abstract/abstract-wc-payment-gateway-stripe.php CHANGED
@@ -11,6 +11,8 @@ if (! class_exists ( 'WC_Payment_Gateway' )) {
11
  */
12
  abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
13
 
 
 
14
  public $token_key;
15
 
16
  public $saved_method_key;
@@ -63,6 +65,8 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
63
  */
64
  public $synchronous = true;
65
 
 
 
66
  /**
67
  *
68
  * @var bool
@@ -95,9 +99,6 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
95
  add_action ( 'woocommerce_update_options_payment_gateways_' . $this->id, [
96
  $this, 'process_admin_options'
97
  ] );
98
- add_action ( 'woocommerce_settings_checkout_' . $this->id, [
99
- $this, 'enqueue_admin_scripts'
100
- ] );
101
  add_filter ( 'woocommerce_payment_methods_list_item', [
102
  $this, 'payment_methods_list_item'
103
  ], 10, 2 );
@@ -155,11 +156,15 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
155
  }
156
 
157
  public function admin_options() {
 
 
 
158
  $this->output_settings_nav ();
159
  printf ( '<input type="hidden" id="wc_stripe_prefix" name="wc_stripe_prefix" value="%1$s"/>', $this->get_prefix () );
160
  echo '<div class="wc-stripe-settings-container ' . $this->id . '">';
161
  parent::admin_options ();
162
  echo '</div>';
 
163
  }
164
 
165
  public function output_settings_nav() {
@@ -296,6 +301,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
296
  'routes' => array(
297
  'setup_intent' => wc_stripe ()->rest_api->payment_intent->rest_url ( 'setup-intent' ),
298
  'add_to_cart' => wc_stripe ()->rest_api->cart->rest_url ( 'add-to-cart' ),
 
299
  'shipping_method' => wc_stripe ()->rest_api->cart->rest_url ( 'shipping-method' ),
300
  'shipping_address' => wc_stripe ()->rest_api->cart->rest_url ( 'shipping-address' ),
301
  'checkout' => wc_stripe ()->rest_api->checkout->rest_url ( 'checkout' )
@@ -332,7 +338,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
332
  *
333
  * @var WC_Payment_Token_Stripe $token
334
  */
335
- $token = $this->get_payment_token ( $charge->payment_method, $charge->payment_method_details );
336
  $order->set_transaction_id ( $charge->id );
337
  $order->set_payment_method_title ( $token->get_payment_method_title () );
338
  $order->update_meta_data ( '_wc_stripe_mode', wc_stripe_mode () );
@@ -354,6 +360,14 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
354
  }
355
  }
356
 
 
 
 
 
 
 
 
 
357
  public function add_payment_method() {
358
  $customer_id = wc_stripe_get_customer_id ();
359
  if (empty ( $customer_id )) {
@@ -566,7 +580,11 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
566
  if ($payment_token->get_type () === $this->token_type) {
567
  $item[ 'method' ][ 'last4' ] = $payment_token->get_last4 ();
568
  $item[ 'method' ][ 'brand' ] = ucfirst ( $payment_token->get_brand () );
569
- $item[ 'expires' ] = sprintf ( '%s / %s', $payment_token->get_exp_month (), $payment_token->get_exp_year () );
 
 
 
 
570
  $item[ 'wc_stripe_method' ] = true;
571
  }
572
  return $item;
@@ -679,7 +697,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
679
  * @return bool
680
  */
681
  public function product_checkout_enabled() {
682
- return in_array ( 'product', $this->get_option ( 'payment_sections' ) );
683
  }
684
 
685
  /**
@@ -688,7 +706,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
688
  * @return bool
689
  */
690
  public function cart_checkout_enabled() {
691
- return in_array ( 'cart', $this->get_option ( 'payment_sections' ) );
692
  }
693
 
694
  /**
@@ -697,7 +715,7 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
697
  * @return bool
698
  */
699
  public function banner_checkout_enabled() {
700
- return $this->supports ( 'wc_stripe_banner_checkout' ) && in_array ( 'checkout_banner', $this->get_option ( 'payment_sections' ) );
701
  }
702
 
703
  /**
@@ -1065,4 +1083,26 @@ abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
1065
  $lock = get_transient ( '_stripe_lock_order_' . ( is_object ( $order ) ? $order->get_id () : $order ) );
1066
  return $lock != false;
1067
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1068
  }
11
  */
12
  abstract class WC_Payment_Gateway_Stripe extends WC_Payment_Gateway {
13
 
14
+ private $admin_output = false;
15
+
16
  public $token_key;
17
 
18
  public $saved_method_key;
65
  */
66
  public $synchronous = true;
67
 
68
+ protected $post_payment_processes = [];
69
+
70
  /**
71
  *
72
  * @var bool
99
  add_action ( 'woocommerce_update_options_payment_gateways_' . $this->id, [
100
  $this, 'process_admin_options'
101
  ] );
 
 
 
102
  add_filter ( 'woocommerce_payment_methods_list_item', [
103
  $this, 'payment_methods_list_item'
104
  ], 10, 2 );
156
  }
157
 
158
  public function admin_options() {
159
+ if ($this->admin_output) {
160
+ return;
161
+ }
162
  $this->output_settings_nav ();
163
  printf ( '<input type="hidden" id="wc_stripe_prefix" name="wc_stripe_prefix" value="%1$s"/>', $this->get_prefix () );
164
  echo '<div class="wc-stripe-settings-container ' . $this->id . '">';
165
  parent::admin_options ();
166
  echo '</div>';
167
+ $this->admin_output = true;
168
  }
169
 
170
  public function output_settings_nav() {
301
  'routes' => array(
302
  'setup_intent' => wc_stripe ()->rest_api->payment_intent->rest_url ( 'setup-intent' ),
303
  'add_to_cart' => wc_stripe ()->rest_api->cart->rest_url ( 'add-to-cart' ),
304
+ 'cart_calculation' => wc_stripe ()->rest_api->cart->rest_url ( 'cart-calculation' ),
305
  'shipping_method' => wc_stripe ()->rest_api->cart->rest_url ( 'shipping-method' ),
306
  'shipping_address' => wc_stripe ()->rest_api->cart->rest_url ( 'shipping-address' ),
307
  'checkout' => wc_stripe ()->rest_api->checkout->rest_url ( 'checkout' )
338
  *
339
  * @var WC_Payment_Token_Stripe $token
340
  */
341
+ $token = $this->get_payment_token ( $this->get_payment_method_from_charge ( $charge ), $charge->payment_method_details );
342
  $order->set_transaction_id ( $charge->id );
343
  $order->set_payment_method_title ( $token->get_payment_method_title () );
344
  $order->update_meta_data ( '_wc_stripe_mode', wc_stripe_mode () );
360
  }
361
  }
362
 
363
+ /**
364
+ * Given a charge object, return the ID of the payment method used for the charge.
365
+ *
366
+ * @since 3.0.6
367
+ * @param \Stripe\Charge $charge
368
+ */
369
+ public abstract function get_payment_method_from_charge($charge);
370
+
371
  public function add_payment_method() {
372
  $customer_id = wc_stripe_get_customer_id ();
373
  if (empty ( $customer_id )) {
580
  if ($payment_token->get_type () === $this->token_type) {
581
  $item[ 'method' ][ 'last4' ] = $payment_token->get_last4 ();
582
  $item[ 'method' ][ 'brand' ] = ucfirst ( $payment_token->get_brand () );
583
+ if ($payment_token->has_expiration ()) {
584
+ $item[ 'expires' ] = sprintf ( '%s / %s', $payment_token->get_exp_month (), $payment_token->get_exp_year () );
585
+ } else {
586
+ $item[ 'expires' ] = __ ( 'n/a', 'woo-stripe-payment' );
587
+ }
588
  $item[ 'wc_stripe_method' ] = true;
589
  }
590
  return $item;
697
  * @return bool
698
  */
699
  public function product_checkout_enabled() {
700
+ return in_array ( 'product', $this->get_option ( 'payment_sections', [] ) );
701
  }
702
 
703
  /**
706
  * @return bool
707
  */
708
  public function cart_checkout_enabled() {
709
+ return in_array ( 'cart', $this->get_option ( 'payment_sections', [] ) );
710
  }
711
 
712
  /**
715
  * @return bool
716
  */
717
  public function banner_checkout_enabled() {
718
+ return $this->supports ( 'wc_stripe_banner_checkout' ) && in_array ( 'checkout_banner', $this->get_option ( 'payment_sections', [] ) );
719
  }
720
 
721
  /**
1083
  $lock = get_transient ( '_stripe_lock_order_' . ( is_object ( $order ) ? $order->get_id () : $order ) );
1084
  return $lock != false;
1085
  }
1086
+
1087
+ public function set_post_payment_process($callback) {
1088
+ $this->post_payment_processes[] = $callback;
1089
+ }
1090
+
1091
+ /**
1092
+ *
1093
+ * @param WC_Order $order
1094
+ * @param WC_Payment_Gateway_Stripe $gateway
1095
+ */
1096
+ public function trigger_post_payment_processes($order, $gateway) {
1097
+ foreach ( $this->post_payment_processes as $callback ) {
1098
+ call_user_func_array ( $callback, func_get_args () );
1099
+ }
1100
+ }
1101
+
1102
+ public function validate_payment_sections_field($key, $value) {
1103
+ if (empty ( $value )) {
1104
+ $value = [];
1105
+ }
1106
+ return $value;
1107
+ }
1108
  }
includes/abstract/abstract-wc-payment-token-stripe.php CHANGED
@@ -7,15 +7,17 @@ if (! defined ( 'ABSPATH' )) {
7
  * @since 3.0.0
8
  * @author PaymentPlugins
9
  * @package Stripe/Abstract
10
- *
11
  */
12
  abstract class WC_Payment_Token_Stripe extends WC_Payment_Token {
13
 
 
 
14
  protected $object_type = 'payment_token';
15
 
16
  protected $extra_data = array( 'format' => '',
17
  'method_type' => '',
18
- 'environment' => 'production'
19
  );
20
 
21
  protected $stripe_data = array();
@@ -123,7 +125,19 @@ abstract class WC_Payment_Token_Stripe extends WC_Payment_Token {
123
  */
124
  public abstract function get_formats();
125
 
 
 
 
 
 
 
 
 
126
  public function get_html_classes() {
127
  return '';
128
  }
 
 
 
 
129
  }
7
  * @since 3.0.0
8
  * @author PaymentPlugins
9
  * @package Stripe/Abstract
10
+ *
11
  */
12
  abstract class WC_Payment_Token_Stripe extends WC_Payment_Token {
13
 
14
+ protected $has_expiration = false;
15
+
16
  protected $object_type = 'payment_token';
17
 
18
  protected $extra_data = array( 'format' => '',
19
  'method_type' => '',
20
+ 'environment' => 'production', 'brand' => ''
21
  );
22
 
23
  protected $stripe_data = array();
125
  */
126
  public abstract function get_formats();
127
 
128
+ public function get_brand($context = 'view') {
129
+ return $this->get_prop ( 'brand', $context );
130
+ }
131
+
132
+ public function set_brand($value) {
133
+ $this->set_prop ( 'brand', $value );
134
+ }
135
+
136
  public function get_html_classes() {
137
  return '';
138
  }
139
+
140
+ public function has_expiration() {
141
+ return $this->has_expiration;
142
+ }
143
  }
includes/abstract/abstract-wc-stripe-settings.php CHANGED
@@ -9,6 +9,8 @@ abstract class WC_Stripe_Settings_API extends WC_Settings_API {
9
 
10
  protected $tab_title;
11
 
 
 
12
  public function __construct() {
13
  $this->init_form_fields ();
14
  $this->init_settings ();
@@ -27,11 +29,15 @@ abstract class WC_Stripe_Settings_API extends WC_Settings_API {
27
  }
28
 
29
  public function admin_options() {
 
 
 
30
  $this->output_settings_nav ();
31
  printf ( '<input type="hidden" id="wc_stripe_prefix" name="wc_stripe_prefix" value="%1$s"/>', $this->get_prefix () );
32
  echo '<div class="wc-stripe-settings-container ' . $this->id . '">';
33
  parent::admin_options ();
34
  echo '</div>';
 
35
  }
36
 
37
  public function output_settings_nav() {
9
 
10
  protected $tab_title;
11
 
12
+ private $admin_output = false;
13
+
14
  public function __construct() {
15
  $this->init_form_fields ();
16
  $this->init_settings ();
29
  }
30
 
31
  public function admin_options() {
32
+ if ($this->admin_output) {
33
+ return;
34
+ }
35
  $this->output_settings_nav ();
36
  printf ( '<input type="hidden" id="wc_stripe_prefix" name="wc_stripe_prefix" value="%1$s"/>', $this->get_prefix () );
37
  echo '<div class="wc-stripe-settings-container ' . $this->id . '">';
38
  parent::admin_options ();
39
  echo '</div>';
40
+ $this->admin_output = true;
41
  }
42
 
43
  public function output_settings_nav() {
includes/class-stripe.php CHANGED
@@ -21,7 +21,7 @@ class WC_Stripe_Manager {
21
  *
22
  * @var string
23
  */
24
- public $version = '3.0.5';
25
 
26
  /**
27
  *
@@ -60,6 +60,7 @@ class WC_Stripe_Manager {
60
  'woocommerce_dependencies'
61
  ) );
62
  $this->includes ();
 
63
  }
64
 
65
  /**
21
  *
22
  * @var string
23
  */
24
+ public $version = '3.0.6';
25
 
26
  /**
27
  *
60
  'woocommerce_dependencies'
61
  ) );
62
  $this->includes ();
63
+ //$this->version = rand(0, 12000);
64
  }
65
 
66
  /**
includes/class-wc-stripe-field-manager.php CHANGED
@@ -7,6 +7,8 @@
7
  */
8
  class WC_Stripe_Field_Manager {
9
 
 
 
10
  public static function init() {
11
  add_action ( 'woocommerce_checkout_before_customer_details', array(
12
  __CLASS__, 'output_banner_checkout_fields'
@@ -14,8 +16,8 @@ class WC_Stripe_Field_Manager {
14
  add_action ( 'woocommerce_after_add_to_cart_button', array(
15
  __CLASS__, 'output_product_checkout_fields'
16
  ) );
17
- add_action ( 'woocommerce_proceed_to_checkout', [
18
- __CLASS__, 'output_cart_fields'
19
  ] );
20
  add_action ( 'woocommerce_review_order_after_order_total', [
21
  __CLASS__, 'output_checkout_fields'
@@ -26,6 +28,21 @@ class WC_Stripe_Field_Manager {
26
  add_action ( 'before_woocommerce_pay', array(
27
  __CLASS__, 'change_payment_request'
28
  ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
 
31
  public static function output_banner_checkout_fields() {
@@ -115,7 +132,8 @@ class WC_Stripe_Field_Manager {
115
  }
116
 
117
  wc_stripe_get_template ( 'cart/payment-methods.php', [
118
- 'gateways' => $gateways
 
119
  ] );
120
  echo '</form>';
121
  }
@@ -133,6 +151,12 @@ class WC_Stripe_Field_Manager {
133
  wc_stripe_hidden_field ( 'billing_last_name', '', WC ()->customer->get_last_name () );
134
  }
135
 
 
 
 
 
 
 
136
  /**
137
  *
138
  * @param WC_Order $order
@@ -157,6 +181,18 @@ class WC_Stripe_Field_Manager {
157
  public static function output_needs_shipping($needs_shipping) {
158
  printf ( '<input type="hidden" id="wc_stripe_needs_shipping" data-value="%s" />', $needs_shipping );
159
  }
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
  if (! is_admin ()) {
162
  WC_Stripe_Field_Manager::init ();
7
  */
8
  class WC_Stripe_Field_Manager {
9
 
10
+ private static $_cart_priority = 30;
11
+
12
  public static function init() {
13
  add_action ( 'woocommerce_checkout_before_customer_details', array(
14
  __CLASS__, 'output_banner_checkout_fields'
16
  add_action ( 'woocommerce_after_add_to_cart_button', array(
17
  __CLASS__, 'output_product_checkout_fields'
18
  ) );
19
+ add_action ( 'template_redirect', [ __CLASS__,
20
+ 'template_redirect'
21
  ] );
22
  add_action ( 'woocommerce_review_order_after_order_total', [
23
  __CLASS__, 'output_checkout_fields'
28
  add_action ( 'before_woocommerce_pay', array(
29
  __CLASS__, 'change_payment_request'
30
  ) );
31
+ add_action ( 'woocommerce_quantity_input_args', array(
32
+ __CLASS__, 'quantity_input_value'
33
+ ) );
34
+ add_action ( 'woocommerce_pay_order_after_submit', array(
35
+ __CLASS__, 'pay_order_fields'
36
+ ) );
37
+ }
38
+
39
+ public static function template_redirect() {
40
+ if (is_cart ()) {
41
+ self::$_cart_priority = apply_filters ( 'wc_stripe_cart_buttons_order', 30 );
42
+ add_action ( 'woocommerce_proceed_to_checkout', [
43
+ __CLASS__, 'output_cart_fields'
44
+ ], apply_filters ( 'wc_stripe_cart_buttons_order', self::$_cart_priority ) );
45
+ }
46
  }
47
 
48
  public static function output_banner_checkout_fields() {
132
  }
133
 
134
  wc_stripe_get_template ( 'cart/payment-methods.php', [
135
+ 'gateways' => $gateways,
136
+ 'after' => self::$_cart_priority > 20
137
  ] );
138
  echo '</form>';
139
  }
151
  wc_stripe_hidden_field ( 'billing_last_name', '', WC ()->customer->get_last_name () );
152
  }
153
 
154
+ public static function pay_order_fields() {
155
+ global $wp;
156
+ $order = wc_get_order ( absint ( $wp->query_vars[ 'order-pay' ] ) );
157
+ self::output_required_fields ( $order );
158
+ }
159
+
160
  /**
161
  *
162
  * @param WC_Order $order
181
  public static function output_needs_shipping($needs_shipping) {
182
  printf ( '<input type="hidden" id="wc_stripe_needs_shipping" data-value="%s" />', $needs_shipping );
183
  }
184
+
185
+ public static function quantity_input_value($args) {
186
+ if (is_product ()) {
187
+ foreach ( WC ()->payment_gateways ()->get_available_payment_gateways () as $id => $gateway ) {
188
+ if ($gateway->supports ( 'wc_stripe_product_checkout' )) {
189
+ $args[ 'min_value' ] = 0;
190
+ break;
191
+ }
192
+ }
193
+ }
194
+ return $args;
195
+ }
196
  }
197
  if (! is_admin ()) {
198
  WC_Stripe_Field_Manager::init ();
includes/class-wc-stripe-frontend-scripts.php CHANGED
@@ -48,8 +48,9 @@ class WC_Stripe_Frontend_Scripts {
48
  'jquery'
49
  ) );
50
 
51
- wp_localize_script ( $this->get_handle ( 'wc-stripe' ), 'wc_stripe_params', [
52
- 'api_key' => wc_stripe_get_publishable_key ()
 
53
  ] );
54
  }
55
 
@@ -110,4 +111,20 @@ class WC_Stripe_Frontend_Scripts {
110
  public function get_min() {
111
  return $suffix = SCRIPT_DEBUG ? '' : '.min';
112
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
48
  'jquery'
49
  ) );
50
 
51
+ wp_localize_script ( $this->get_handle ( 'wc-stripe' ), 'wc_stripe_params_v3', [
52
+ 'api_key' => wc_stripe_get_publishable_key (),
53
+ 'page' => $this->get_page_id ()
54
  ] );
55
  }
56
 
111
  public function get_min() {
112
  return $suffix = SCRIPT_DEBUG ? '' : '.min';
113
  }
114
+
115
+ private function get_page_id() {
116
+ if (is_product ()) {
117
+ return 'product';
118
+ }
119
+ if (is_cart ()) {
120
+ return 'cart';
121
+ }
122
+ if (is_checkout ()) {
123
+ return 'checkout';
124
+ }
125
+ if (is_add_payment_method_page ()) {
126
+ return 'add_payment_method';
127
+ }
128
+ return '';
129
+ }
130
  }
includes/class-wc-stripe-redirect-handler.php CHANGED
@@ -11,6 +11,9 @@ class WC_Stripe_Redirect_Handler {
11
  add_action ( 'template_redirect', [ __CLASS__,
12
  'local_payment_redirect'
13
  ] );
 
 
 
14
  }
15
 
16
  /**
@@ -68,5 +71,12 @@ class WC_Stripe_Redirect_Handler {
68
  wp_safe_redirect ( $order->get_checkout_order_received_url () );
69
  exit ();
70
  }
 
 
 
 
 
 
 
71
  }
72
  WC_Stripe_Redirect_Handler::init ();
11
  add_action ( 'template_redirect', [ __CLASS__,
12
  'local_payment_redirect'
13
  ] );
14
+ add_action ( 'get_header', [ __CLASS__,
15
+ 'maybe_restore_cart'
16
+ ], 100 );
17
  }
18
 
19
  /**
71
  wp_safe_redirect ( $order->get_checkout_order_received_url () );
72
  exit ();
73
  }
74
+
75
+ public static function maybe_restore_cart() {
76
+ global $wp;
77
+ if (isset ( $wp->query_vars[ 'order-received' ] ) && isset ( $_GET[ 'wc_stripe_product_checkout' ] )) {
78
+ add_action ( 'woocommerce_cart_emptied', 'wc_stripe_restore_cart_after_product_checkout' );
79
+ }
80
+ }
81
  }
82
  WC_Stripe_Redirect_Handler::init ();
includes/controllers/class-wc-stripe-controller-cart.php CHANGED
@@ -57,6 +57,30 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
57
  ]
58
  ]
59
  ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
 
62
  /**
@@ -88,9 +112,14 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
88
 
89
  wc_stripe_update_shipping_methods ( $shipping_methods );
90
 
91
- WC ()->cart->calculate_totals ();
 
 
 
 
 
92
 
93
- return rest_ensure_response ( apply_filters ( 'wc_stripe_update_shipping_method_response', [
94
  'data' => $gateway->get_update_shipping_method_response ( [
95
  'newData' => [
96
  'status' => 'success',
@@ -105,6 +134,10 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
105
  'shipping_methods' => WC ()->session->get ( 'chosen_shipping_methods', [] )
106
  ] )
107
  ] ) );
 
 
 
 
108
  }
109
 
110
  /**
@@ -123,14 +156,17 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
123
  try {
124
  wc_stripe_update_customer_location ( $address );
125
 
126
- // calculate cart totals so shipping etc is updated.
127
- WC ()->cart->calculate_totals ();
 
 
 
128
 
129
  if (! $this->has_shipping_methods ( WC ()->shipping ()->get_packages () )) {
130
  throw new Exception ( 'No valid shipping methods.' );
131
  }
132
 
133
- return rest_ensure_response ( apply_filters ( 'wc_stripe_update_shipping_method_response', [
134
  'data' => $gateway->get_update_shipping_address_response ( [
135
  'newData' => [
136
  'status' => 'success',
@@ -145,13 +181,17 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
145
  ] )
146
  ] ) );
147
  } catch ( Exception $e ) {
148
- return new WP_Error ( 'address-error', $e->getMessage (), [
149
  'status' => 200,
150
  'newData' => [
151
  'status' => 'invalid_shipping_address'
152
  ]
153
  ] );
154
  }
 
 
 
 
155
  }
156
 
157
  /**
@@ -168,20 +208,59 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
168
  */
169
  $gateway = WC ()->payment_gateways ()->payment_gateways ()[ $payment_method ];
170
 
171
- // empty the cart since we only care about adding the product selected by the customer
172
- WC ()->cart->empty_cart ();
173
  $product_id = $request->get_param ( 'product_id' );
174
  $qty = $request->get_param ( 'qty' );
175
- $variation_id = $request->get_param ( 'variation_id' ) == null ? 0 : $request->get_param ( 'variation_id' );
 
 
 
 
176
  if (WC ()->cart->add_to_cart ( $product_id, $qty, $variation_id ) == false) {
177
  return new WP_Error ( 'cart-error', $this->get_error_messages (), [
178
  'status' => 200
179
  ] );
180
  } else {
181
- WC ()->cart->calculate_totals ();
182
  // add to cart was successful. Send a new X-WP-Nonce since it will be different now that a WC session exists.
183
  rest_get_server ()->send_header ( 'X-WP-Nonce', wp_create_nonce ( 'wp_rest' ) );
184
- return rest_ensure_response ( apply_filters ( 'wc_stripe_add_to_cart_response', [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  'data' => $gateway->add_to_cart_response ( [
186
  'total' => WC ()->cart->total,
187
  'subtotal' => WC ()->cart->subtotal,
@@ -190,7 +269,17 @@ class WC_Stripe_Controller_Cart extends WC_Stripe_Rest_Controller {
190
  'shippingOptions' => wc_stripe_get_shipping_options ()
191
  ] )
192
  ], $gateway, $request ) );
 
 
 
 
193
  }
 
 
 
 
 
 
194
  }
195
 
196
  protected function get_error_messages() {
57
  ]
58
  ]
59
  ] );
60
+ /**
61
+ *
62
+ * @since 3.0.6
63
+ */
64
+ register_rest_route ( $this->rest_uri (), 'cart-calculation', [
65
+ 'methods' => WP_REST_Server::CREATABLE,
66
+ 'callback' => [ $this,
67
+ 'cart_calculation'
68
+ ],
69
+ 'args' => [
70
+ 'product_id' => [
71
+ 'required' => true
72
+ ],
73
+ 'qty' => [ 'required' => true,
74
+ 'validate_callback' => [
75
+ $this,
76
+ 'validate_quantity'
77
+ ]
78
+ ],
79
+ 'payment_method' => [
80
+ 'required' => true
81
+ ]
82
+ ]
83
+ ] );
84
  }
85
 
86
  /**
112
 
113
  wc_stripe_update_shipping_methods ( $shipping_methods );
114
 
115
+ // if this request is coming from product page, stash cart and use product cart
116
+ if ('product' == $request->get_param ( 'page_id' )) {
117
+ wc_stripe_stash_cart ( WC ()->cart );
118
+ } else {
119
+ WC ()->cart->calculate_totals ();
120
+ }
121
 
122
+ $response = rest_ensure_response ( apply_filters ( 'wc_stripe_update_shipping_method_response', [
123
  'data' => $gateway->get_update_shipping_method_response ( [
124
  'newData' => [
125
  'status' => 'success',
134
  'shipping_methods' => WC ()->session->get ( 'chosen_shipping_methods', [] )
135
  ] )
136
  ] ) );
137
+ if ('product' == $request->get_param ( 'page_id' )) {
138
+ wc_stripe_restore_cart ( WC ()->cart );
139
+ }
140
+ return $response;
141
  }
142
 
143
  /**
156
  try {
157
  wc_stripe_update_customer_location ( $address );
158
 
159
+ if ('product' == $request->get_param ( 'page_id' )) {
160
+ wc_stripe_stash_cart ( WC ()->cart );
161
+ } else {
162
+ WC ()->cart->calculate_totals ();
163
+ }
164
 
165
  if (! $this->has_shipping_methods ( WC ()->shipping ()->get_packages () )) {
166
  throw new Exception ( 'No valid shipping methods.' );
167
  }
168
 
169
+ $response = rest_ensure_response ( apply_filters ( 'wc_stripe_update_shipping_method_response', [
170
  'data' => $gateway->get_update_shipping_address_response ( [
171
  'newData' => [
172
  'status' => 'success',
181
  ] )
182
  ] ) );
183
  } catch ( Exception $e ) {
184
+ $response = new WP_Error ( 'address-error', $e->getMessage (), [
185
  'status' => 200,
186
  'newData' => [
187
  'status' => 'invalid_shipping_address'
188
  ]
189
  ] );
190
  }
191
+ if ('product' == $request->get_param ( 'page_id' )) {
192
+ wc_stripe_restore_cart ( WC ()->cart );
193
+ }
194
+ return $response;
195
  }
196
 
197
  /**
208
  */
209
  $gateway = WC ()->payment_gateways ()->payment_gateways ()[ $payment_method ];
210
 
 
 
211
  $product_id = $request->get_param ( 'product_id' );
212
  $qty = $request->get_param ( 'qty' );
213
+ $variation_id = $request->get_param ( 'variation_id' );
214
+
215
+ // stash cart so clean calculation can be performed.
216
+ wc_stripe_stash_cart ( WC ()->cart, false );
217
+
218
  if (WC ()->cart->add_to_cart ( $product_id, $qty, $variation_id ) == false) {
219
  return new WP_Error ( 'cart-error', $this->get_error_messages (), [
220
  'status' => 200
221
  ] );
222
  } else {
 
223
  // add to cart was successful. Send a new X-WP-Nonce since it will be different now that a WC session exists.
224
  rest_get_server ()->send_header ( 'X-WP-Nonce', wp_create_nonce ( 'wp_rest' ) );
225
+ $response = rest_ensure_response ( apply_filters ( 'wc_stripe_add_to_cart_response', [
226
+ 'data' => $gateway->add_to_cart_response ( [
227
+ 'total' => WC ()->cart->total,
228
+ 'subtotal' => WC ()->cart->subtotal,
229
+ 'totalCents' => wc_stripe_add_number_precision ( WC ()->cart->total ),
230
+ 'displayItems' => wc_stripe_get_display_items (),
231
+ 'shippingOptions' => wc_stripe_get_shipping_options ()
232
+ ] )
233
+ ], $gateway, $request ) );
234
+ // save the product cart so it can be used for shipping calculations etc.
235
+ wc_stripe_stash_product_cart ( WC ()->cart );
236
+ // put cart contents back to how they were before.
237
+ wc_stripe_restore_cart ( WC ()->cart );
238
+ return $response;
239
+ }
240
+ }
241
+
242
+ /**
243
+ * Performs a cart calculation
244
+ *
245
+ * @param WP_REST_Request $request
246
+ */
247
+ public function cart_calculation($request) {
248
+ // WC 3.0.0 requires WOOCOMMERCE_CART to be defined.
249
+ wc_maybe_define_constant ( 'WOOCOMMERCE_CART', true );
250
+ $product_id = $request->get_param ( 'product_id' );
251
+ $qty = $request->get_param ( 'qty' );
252
+ $variation_id = $request->get_param ( 'variation_id' ) == null ? 0 : $request->get_param ( 'variation_id' );
253
+
254
+ wc_stripe_stash_cart ( WC ()->cart, false );
255
+
256
+ if (WC ()->cart->add_to_cart ( $product_id, $qty, $variation_id )) {
257
+ $payment_method = $request->get_param ( 'payment_method' );
258
+ /**
259
+ *
260
+ * @var WC_Payment_Gateway_Stripe $gateway
261
+ */
262
+ $gateway = WC ()->payment_gateways ()->payment_gateways ()[ $payment_method ];
263
+ $response = rest_ensure_response ( apply_filters ( 'wc_stripe_add_to_cart_response', [
264
  'data' => $gateway->add_to_cart_response ( [
265
  'total' => WC ()->cart->total,
266
  'subtotal' => WC ()->cart->subtotal,
269
  'shippingOptions' => wc_stripe_get_shipping_options ()
270
  ] )
271
  ], $gateway, $request ) );
272
+ } else {
273
+ $response = new WP_Error ( 'cart-error', $this->get_error_messages (), [
274
+ 'status' => 200
275
+ ] );
276
  }
277
+ wc_stripe_stash_product_cart ( WC ()->cart );
278
+ wc_stripe_restore_cart ( WC ()->cart );
279
+ wc_clear_notices ();
280
+ // add to cart was successful. Send a new X-WP-Nonce since it will be different now that a WC session exists.
281
+ rest_get_server ()->send_header ( 'X-WP-Nonce', wp_create_nonce ( 'wp_rest' ) );
282
+ return $response;
283
  }
284
 
285
  protected function get_error_messages() {
includes/controllers/class-wc-stripe-controller-checkout.php CHANGED
@@ -57,6 +57,16 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
57
  }
58
  // set the checkout nonce so no exceptions are thrown.
59
  $_REQUEST[ '_wpnonce' ] = $_POST[ '_wpnonce' ] = wp_create_nonce ( 'woocommerce-process_checkout' );
 
 
 
 
 
 
 
 
 
 
60
  $checkout->process_checkout ();
61
  } catch ( Exception $e ) {
62
  wc_add_notice ( $e->getMessage (), 'error' );
@@ -121,6 +131,15 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
121
  ), 10, 3 );
122
  }
123
 
 
 
 
 
 
 
 
 
 
124
  /**
125
  *
126
  * @param array $data
@@ -167,4 +186,11 @@ class WC_Stripe_Controller_Checkout extends WC_Stripe_Rest_Controller {
167
  ), 200 );
168
  }
169
  }
 
 
 
 
 
 
 
170
  }
57
  }
58
  // set the checkout nonce so no exceptions are thrown.
59
  $_REQUEST[ '_wpnonce' ] = $_POST[ '_wpnonce' ] = wp_create_nonce ( 'woocommerce-process_checkout' );
60
+
61
+ if ('product' == $request->get_param ( 'page_id' )) {
62
+ wc_stripe_stash_cart ( WC ()->cart );
63
+ $gateway->set_post_payment_process ( [
64
+ $this, 'post_payment_processes'
65
+ ] );
66
+ add_filter ( 'woocommerce_get_checkout_order_received_url', function ($url, $order) {
67
+ return add_query_arg ( 'wc_stripe_product_checkout', $order->get_payment_method (), $url );
68
+ }, 10, 2 );
69
+ }
70
  $checkout->process_checkout ();
71
  } catch ( Exception $e ) {
72
  wc_add_notice ( $e->getMessage (), 'error' );
131
  ), 10, 3 );
132
  }
133
 
134
+ /**
135
+ *
136
+ * @param WC_Order $order
137
+ * @param WC_Payment_Gateway_Stripe $gateway
138
+ */
139
+ public function set_stashed_cart($order, $gateway) {
140
+ wc_stripe_restore_cart ( WC ()->cart );
141
+ }
142
+
143
  /**
144
  *
145
  * @param array $data
186
  ), 200 );
187
  }
188
  }
189
+
190
+ public function post_payment_processes($order, $gateway) {
191
+ wc_stripe_restore_cart ( WC ()->cart );
192
+ $data = WC ()->session->get ( 'wc_stripe_cart', [] );
193
+ unset ( $data[ 'product_cart' ] );
194
+ WC ()->session->set ( 'wc_stripe_cart', $data );
195
+ }
196
  }
includes/controllers/class-wc-stripe-controller-googlepay.php CHANGED
@@ -70,6 +70,9 @@ class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
70
  $this->gateway = WC ()->payment_gateways ()->payment_gateways ()[ 'stripe_googlepay' ];
71
 
72
  try {
 
 
 
73
  wc_stripe_update_customer_location ( $address );
74
 
75
  wc_stripe_update_shipping_methods ( $this->shipping_methods );
@@ -83,12 +86,16 @@ class WC_Stripe_Controller_GooglePay extends WC_Stripe_Rest_Controller {
83
  throw new Exception ( __ ( 'Your shipping address is not serviceable.', 'woo-stripe-payment' ) );
84
  }
85
 
86
- return rest_ensure_response ( apply_filters ( 'wc_stripe_googlepay_paymentdata_response', [
87
  'data' => [
88
  'shipping_methods' => $this->get_shipping_methods (),
89
  'paymentRequestUpdate' => $this->get_payment_response_data ()
90
  ]
91
  ] ) );
 
 
 
 
92
  } catch ( Exception $e ) {
93
  return new WP_Error ( 'payment-data-error', $e->getMessage (), [
94
  'status' => 200,
70
  $this->gateway = WC ()->payment_gateways ()->payment_gateways ()[ 'stripe_googlepay' ];
71
 
72
  try {
73
+ if ('product' == $request->get_param ( 'page_id' )) {
74
+ wc_stripe_stash_cart ( WC ()->cart );
75
+ }
76
  wc_stripe_update_customer_location ( $address );
77
 
78
  wc_stripe_update_shipping_methods ( $this->shipping_methods );
86
  throw new Exception ( __ ( 'Your shipping address is not serviceable.', 'woo-stripe-payment' ) );
87
  }
88
 
89
+ $response = rest_ensure_response ( apply_filters ( 'wc_stripe_googlepay_paymentdata_response', [
90
  'data' => [
91
  'shipping_methods' => $this->get_shipping_methods (),
92
  'paymentRequestUpdate' => $this->get_payment_response_data ()
93
  ]
94
  ] ) );
95
+ if ('product' == $request->get_param ( 'page_id' )) {
96
+ wc_stripe_restore_cart ( WC ()->cart );
97
+ }
98
+ return $response;
99
  } catch ( Exception $e ) {
100
  return new WP_Error ( 'payment-data-error', $e->getMessage (), [
101
  'status' => 200,
includes/gateways/class-wc-payment-gateway-stripe-ach.php CHANGED
@@ -47,9 +47,13 @@ class WC_Payment_Gateway_Stripe_ACH extends WC_Payment_Gateway_Stripe_Charge {
47
  * @see WC_Payment_Gateway_Stripe::init_supports()
48
  */
49
  public function init_supports() {
50
- $this->supports = [ 'tokenization', 'products',
51
- 'refunds'
52
- ];
 
 
 
 
53
  }
54
 
55
  /**
@@ -85,17 +89,18 @@ class WC_Payment_Gateway_Stripe_ACH extends WC_Payment_Gateway_Stripe_Charge {
85
  $order = wc_get_order ( $order_id );
86
 
87
  // generate the access token first.
88
- try {
89
- $result = $this->fetch_access_token ( $this->get_public_token () );
90
-
91
- $result = $this->fetch_bank_token ( $result->access_token );
92
-
93
- $this->set_new_source_token ( $result->stripe_bank_account_token );
94
-
95
- return parent::process_payment ( $order_id );
96
- } catch ( Exception $e ) {
97
- wc_add_notice ( sprintf ( __ ( 'Error processing payment. Reason: %s', 'woo-stripe-payment' ), $e->getMessage () ), 'error' );
98
  }
 
99
  }
100
 
101
  private function do_api_request($uri, $body, $method = 'POST') {
@@ -172,4 +177,12 @@ class WC_Payment_Gateway_Stripe_ACH extends WC_Payment_Gateway_Stripe_Charge {
172
  private function get_public_token() {
173
  return $this->get_new_source_token ();
174
  }
 
 
 
 
 
 
 
 
175
  }
47
  * @see WC_Payment_Gateway_Stripe::init_supports()
48
  */
49
  public function init_supports() {
50
+ /*
51
+ * $this->supports = [ 'tokenization', 'products',
52
+ * 'refunds'
53
+ * ];
54
+ */
55
+ parent::init_supports ();
56
+ unset ( $this->supports[ 'add_payment_method' ] );
57
  }
58
 
59
  /**
89
  $order = wc_get_order ( $order_id );
90
 
91
  // generate the access token first.
92
+ if (! $this->use_saved_source ()) {
93
+ try {
94
+ $result = $this->fetch_access_token ( $this->get_public_token () );
95
+
96
+ $result = $this->fetch_bank_token ( $result->access_token );
97
+
98
+ $this->set_new_source_token ( $result->stripe_bank_account_token );
99
+ } catch ( Exception $e ) {
100
+ wc_add_notice ( sprintf ( __ ( 'Error processing payment. Reason: %s', 'woo-stripe-payment' ), $e->getMessage () ), 'error' );
101
+ }
102
  }
103
+ return parent::process_payment ( $order_id );
104
  }
105
 
106
  private function do_api_request($uri, $body, $method = 'POST') {
177
  private function get_public_token() {
178
  return $this->get_new_source_token ();
179
  }
180
+
181
+ public function get_saved_methods_label() {
182
+ return __ ( 'Saved Banks', 'woo-stripe-payment' );
183
+ }
184
+
185
+ public function get_new_method_label() {
186
+ return __ ( 'New Bank', 'woo-stripe-payment' );
187
+ }
188
  }
includes/gateways/class-wc-payment-gateway-stripe-klarna.php CHANGED
@@ -84,7 +84,7 @@ class WC_Payment_Gateway_Stripe_Klarna extends WC_Payment_Gateway_Stripe_Local_P
84
 
85
  public function is_local_payment_available() {
86
  $currency = get_woocommerce_currency ();
87
- $country = WC ()->customer->get_billing_country ();
88
  if ($country) {
89
  $params = $this->get_required_parameters ();
90
  return isset ( $params[ $currency ] ) && array_search ( $country, $params[ $currency ] ) !== false;
84
 
85
  public function is_local_payment_available() {
86
  $currency = get_woocommerce_currency ();
87
+ $country = WC ()->customer ? WC ()->customer->get_billing_country () : null;
88
  if ($country) {
89
  $params = $this->get_required_parameters ();
90
  return isset ( $params[ $currency ] ) && array_search ( $country, $params[ $currency ] ) !== false;
includes/gateways/class-wc-payment-gateway-stripe-payment-request.php CHANGED
@@ -60,6 +60,7 @@ class WC_Payment_Gateway_Stripe_Payment_Request extends WC_Payment_Gateway_Strip
60
  'chrome' => wc_stripe ()->assets_url ( 'img/chrome.svg' )
61
  ],
62
  'messages' => [
 
63
  'add_to_cart' => __ ( 'Adding to cart...', 'woo-stripe-payment' ),
64
  'choose_product' => __ ( 'Please select a product option before updating quantity.', 'woo-stripe-payment' )
65
  ]
60
  'chrome' => wc_stripe ()->assets_url ( 'img/chrome.svg' )
61
  ],
62
  'messages' => [
63
+ 'invalid_amount' => __ ( 'Please update you product quantity before paying.', 'woo-stripe-payment' ),
64
  'add_to_cart' => __ ( 'Adding to cart...', 'woo-stripe-payment' ),
65
  'choose_product' => __ ( 'Please select a product option before updating quantity.', 'woo-stripe-payment' )
66
  ]
includes/tokens/class-wc-payment-token-stripe-ach.php CHANGED
@@ -10,7 +10,7 @@ class WC_Payment_Token_Stripe_ACH extends WC_Payment_Token_Stripe {
10
  protected $type = 'Stripe_ACH';
11
 
12
  protected $stripe_data = array( 'bank_name' => '',
13
- 'routing' => '', 'last4' => ''
14
  );
15
 
16
  /**
@@ -22,10 +22,13 @@ class WC_Payment_Token_Stripe_ACH extends WC_Payment_Token_Stripe {
22
  public function details_to_props($details) {
23
  if (isset ( $details[ 'ach_debit' ] )) {
24
  $bank = $details[ 'ach_debit' ];
25
- $this->set_bank_name ( $bank[ 'bank_name' ] );
26
- $this->set_last4 ( $bank[ 'last4' ] );
27
- $this->set_routing_number ( $bank[ 'routing_number' ] );
28
  }
 
 
 
 
29
  }
30
 
31
  public function get_bank_name($context = 'view') {
@@ -45,7 +48,7 @@ class WC_Payment_Token_Stripe_ACH extends WC_Payment_Token_Stripe {
45
  }
46
 
47
  public function set_routing_number($value) {
48
- $this->set_prop ( 'routing', $value );
49
  }
50
 
51
  public function set_last4($value) {
@@ -66,4 +69,8 @@ class WC_Payment_Token_Stripe_ACH extends WC_Payment_Token_Stripe {
66
  )
67
  );
68
  }
 
 
 
 
69
  }
10
  protected $type = 'Stripe_ACH';
11
 
12
  protected $stripe_data = array( 'bank_name' => '',
13
+ 'routing_number' => '', 'last4' => ''
14
  );
15
 
16
  /**
22
  public function details_to_props($details) {
23
  if (isset ( $details[ 'ach_debit' ] )) {
24
  $bank = $details[ 'ach_debit' ];
25
+ } elseif ($details instanceof \Stripe\BankAccount) {
26
+ $bank = $details;
 
27
  }
28
+ $this->set_brand ( $bank[ 'bank_name' ] );
29
+ $this->set_bank_name ( $bank[ 'bank_name' ] );
30
+ $this->set_last4 ( $bank[ 'last4' ] );
31
+ $this->set_routing_number ( $bank[ 'routing_number' ] );
32
  }
33
 
34
  public function get_bank_name($context = 'view') {
48
  }
49
 
50
  public function set_routing_number($value) {
51
+ $this->set_prop ( 'routing_number', $value );
52
  }
53
 
54
  public function set_last4($value) {
69
  )
70
  );
71
  }
72
+
73
+ public function get_html_classes() {
74
+ return 'wc-stripe-ach';
75
+ }
76
  }
includes/tokens/class-wc-payment-token-stripe-cc.php CHANGED
@@ -4,12 +4,15 @@ if (! class_exists ( 'WC_Payment_Token_Stripe' )) {
4
  }
5
  /**
6
  * @sin 3.0.0
 
7
  * @author PaymentPlugins
8
  * @package Stripe/Tokens
9
- *
10
  */
11
  class WC_Payment_Token_Stripe_CC extends WC_Payment_Token_Stripe {
12
 
 
 
13
  protected $type = 'Stripe_CC';
14
 
15
  protected $stripe_data = array( 'brand' => '',
@@ -32,14 +35,6 @@ class WC_Payment_Token_Stripe_CC extends WC_Payment_Token_Stripe {
32
  $this->set_masked_number ( sprintf ( '********%s', $card[ 'last4' ] ) );
33
  }
34
 
35
- public function get_brand($context = 'view') {
36
- return $this->get_prop ( 'brand', $context );
37
- }
38
-
39
- public function set_brand($value) {
40
- $this->set_prop ( 'brand', $value );
41
- }
42
-
43
  public function get_last4($context = 'view') {
44
  return $this->get_prop ( 'last4', $context );
45
  }
4
  }
5
  /**
6
  * @sin 3.0.0
7
+ *
8
  * @author PaymentPlugins
9
  * @package Stripe/Tokens
10
+ *
11
  */
12
  class WC_Payment_Token_Stripe_CC extends WC_Payment_Token_Stripe {
13
 
14
+ protected $has_expiration = true;
15
+
16
  protected $type = 'Stripe_CC';
17
 
18
  protected $stripe_data = array( 'brand' => '',
35
  $this->set_masked_number ( sprintf ( '********%s', $card[ 'last4' ] ) );
36
  }
37
 
 
 
 
 
 
 
 
 
38
  public function get_last4($context = 'view') {
39
  return $this->get_prop ( 'last4', $context );
40
  }
includes/wc-stripe-functions.php CHANGED
@@ -332,8 +332,9 @@ function wc_stripe_shipping_address_serviceable() {
332
  */
333
  function wc_stripe_get_display_items($encode = false, $order = null) {
334
  $items = [];
 
335
  if (! $order) {
336
- foreach ( WC ()->cart->get_cart () as $cart_item ) {
337
  /**
338
  *
339
  * @var WC_Product $product
@@ -346,18 +347,18 @@ function wc_stripe_get_display_items($encode = false, $order = null) {
346
  'amount' => wc_stripe_add_number_precision ( $product->get_price () * $qty )
347
  ];
348
  }
349
- if (WC ()->cart->needs_shipping ()) {
350
  $items[] = [
351
  'label' => __ ( 'Shipping', 'woo-stripe-payment' ),
352
  'pending' => false,
353
- 'amount' => wc_stripe_add_number_precision ( WC ()->cart->shipping_total )
354
  ];
355
  }
356
  if (wc_tax_enabled ()) {
357
  $items[] = [
358
  'label' => __ ( 'Tax', 'woo-stripe-payment' ),
359
  'pending' => false,
360
- 'amount' => wc_stripe_add_number_precision ( WC ()->cart->get_taxes_total () )
361
  ];
362
  }
363
  } else {
@@ -876,4 +877,67 @@ function wc_stripe_get_order_from_transaction($transaction_id) {
876
  global $wpdb;
877
  $order_id = $wpdb->get_var ( $wpdb->prepare ( "SELECT ID FROM {$wpdb->posts} AS posts LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id WHERE meta.meta_key = %s AND meta.meta_value = %s LIMIT 1", '_transaction_id', $transaction_id ) );
878
  return wc_get_order ( $order_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
879
  }
332
  */
333
  function wc_stripe_get_display_items($encode = false, $order = null) {
334
  $items = [];
335
+ $cart = WC ()->cart;
336
  if (! $order) {
337
+ foreach ( $cart->get_cart () as $cart_item ) {
338
  /**
339
  *
340
  * @var WC_Product $product
347
  'amount' => wc_stripe_add_number_precision ( $product->get_price () * $qty )
348
  ];
349
  }
350
+ if ($cart->needs_shipping ()) {
351
  $items[] = [
352
  'label' => __ ( 'Shipping', 'woo-stripe-payment' ),
353
  'pending' => false,
354
+ 'amount' => wc_stripe_add_number_precision ( $cart->shipping_total )
355
  ];
356
  }
357
  if (wc_tax_enabled ()) {
358
  $items[] = [
359
  'label' => __ ( 'Tax', 'woo-stripe-payment' ),
360
  'pending' => false,
361
+ 'amount' => wc_stripe_add_number_precision ( $cart->get_taxes_total () )
362
  ];
363
  }
364
  } else {
877
  global $wpdb;
878
  $order_id = $wpdb->get_var ( $wpdb->prepare ( "SELECT ID FROM {$wpdb->posts} AS posts LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id WHERE meta.meta_key = %s AND meta.meta_value = %s LIMIT 1", '_transaction_id', $transaction_id ) );
879
  return wc_get_order ( $order_id );
880
+ }
881
+
882
+ /**
883
+ * Stash the WC cart contents in the session and empty it's contents.
884
+ * If $product_cart is true, add the stashed product(s)
885
+ * to the cart.
886
+ *
887
+ * @since 3.0.6
888
+ *
889
+ * @param WC_Cart $cart
890
+ */
891
+ function wc_stripe_stash_cart($cart, $product_cart = true) {
892
+ $data = WC ()->session->get ( 'wc_stripe_cart', [] );
893
+ $data[ 'cart' ] = $cart->get_cart_for_session ();
894
+ WC ()->session->set ( 'wc_stripe_cart', $data );
895
+ $cart->empty_cart ( false );
896
+ if ($product_cart && isset ( $data[ 'product_cart' ] )) {
897
+ foreach ( $data[ 'product_cart' ] as $cart_item ) {
898
+ $cart->add_to_cart ( $cart_item[ 'product_id' ], $cart_item[ 'quantity' ], $cart_item[ 'variation_id' ] );
899
+ }
900
+ }
901
+ }
902
+
903
+ /**
904
+ *
905
+ * @since 3.0.6
906
+ * @param number $product_id
907
+ * @param number $qty
908
+ * @param number $variation_id
909
+ */
910
+ function wc_stripe_stash_product_cart($cart) {
911
+ $data = WC ()->session->get ( 'wc_stripe_cart', [] );
912
+ $data[ 'product_cart' ] = $cart->get_cart_for_session ();
913
+ WC ()->session->set ( 'wc_stripe_cart', $data );
914
+ WC ()->cart->set_session ();
915
+ }
916
+
917
+ /**
918
+ *
919
+ * @since 3.0.6
920
+ * @param WC_Cart $cart
921
+ */
922
+ function wc_stripe_restore_cart($cart) {
923
+ $data = WC ()->session->get ( 'wc_stripe_cart', [
924
+ 'cart' => []
925
+ ] );
926
+ $cart->cart_contents = $data[ 'cart' ];
927
+ $cart->set_session ();
928
+ }
929
+
930
+ /**
931
+ *
932
+ * @since 3.0.6
933
+ */
934
+ function wc_stripe_restore_cart_after_product_checkout() {
935
+ wc_stripe_restore_cart ( WC ()->cart );
936
+ $cart_contents = [];
937
+ foreach ( WC ()->cart->get_cart () as $key => $cart_item ) {
938
+ $cart_item[ 'data' ] = wc_get_product ( $cart_item[ 'variation_id' ] ? $cart_item[ 'variation_id' ] : $cart_item[ 'product_id' ] );
939
+ $cart_contents[ $key ] = $cart_item;
940
+ }
941
+ WC ()->cart->cart_contents = $cart_contents;
942
+ WC ()->cart->calculate_totals ();
943
  }
includes/wc-stripe-webhook-functions.php CHANGED
@@ -28,7 +28,7 @@ function wc_stripe_process_source_chargeable($source, $request) {
28
 
29
  // if the order has a transaction ID, then a charge has already been created.
30
  if ($gateway->has_order_lock ( $order ) || ( $transaction_id = $order->get_transaction_id () )) {
31
- wc_stripe_log_info ( sprintf ( 'source.chargeable event received. Charge has already been created for order %s. Event exited.', $order_id ) );
32
  return;
33
  }
34
  $gateway->set_new_source_token ( $source->id );
@@ -62,5 +62,14 @@ function wc_stripe_process_charge_succeeded($charge, $request) {
62
  // call payment complete so shipping, emails, etc are triggered.
63
  $order->payment_complete ();
64
  $order->add_order_note ( __ ( 'Charge.succeeded webhook recieved. Payment has been completed.', 'woo-stripe-payment' ) );
 
 
 
 
 
 
 
 
 
65
  }
66
  }
28
 
29
  // if the order has a transaction ID, then a charge has already been created.
30
  if ($gateway->has_order_lock ( $order ) || ( $transaction_id = $order->get_transaction_id () )) {
31
+ wc_stripe_log_info ( sprintf ( 'source.chargeable event received. Charge has already been created for order %s. Event exited.', $order->get_id () ) );
32
  return;
33
  }
34
  $gateway->set_new_source_token ( $source->id );
62
  // call payment complete so shipping, emails, etc are triggered.
63
  $order->payment_complete ();
64
  $order->add_order_note ( __ ( 'Charge.succeeded webhook recieved. Payment has been completed.', 'woo-stripe-payment' ) );
65
+
66
+ if (wcs_stripe_active () && wcs_order_contains_subscription ( $order )) {
67
+ /**
68
+ *
69
+ * @var WC_Payment_Gateway_Stripe $gateway
70
+ */
71
+ $gateway = WC ()->payment_gateways ()->payment_gateways ()[ $order->get_payment_method () ];
72
+ $gateway->save_order_meta ( $order, $charge );
73
+ }
74
  }
75
  }
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.3
6
  Requires PHP: 5.4
7
- Stable tag: 3.0.5
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -53,6 +53,10 @@ If you're site is not loading over https, then Stripe won't render the Payment R
53
  7. Payment options at top of checkout page for easy one click checkout
54
 
55
  == Changelog ==
 
 
 
 
56
  = 3.0.5 =
57
  * Added - ACH payment support
58
  * Added - New credit card form
4
  Requires at least: 3.0.1
5
  Tested up to: 5.3
6
  Requires PHP: 5.4
7
+ Stable tag: 3.0.6
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
53
  7. Payment options at top of checkout page for easy one click checkout
54
 
55
  == Changelog ==
56
+ = 3.0.6 =
57
+ * Added - ACH subscription support
58
+ * Updated - Top of checkout styling
59
+ * Updated =Positioning of cart buttons. They are now below cart checkout button
60
  = 3.0.5 =
61
  * Added - ACH payment support
62
  * Added - New credit card form
stripe-payments.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Stripe For WooCommerce
5
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
6
  * Description: Accept credit cards, Google Pay, & Apple Pay, ACH, Klarna and more using Stripe.
7
- * Version: 3.0.5
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
4
  * Plugin Name: Stripe For WooCommerce
5
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
6
  * Description: Accept credit cards, Google Pay, & Apple Pay, ACH, Klarna and more using Stripe.
7
+ * Version: 3.0.6
8
  * Author: Payment Plugins, support@paymentplugins.com
9
  * Text Domain: woo-stripe-payment
10
  * Domain Path: /i18n/languages/
templates/cart/payment-methods.php CHANGED
@@ -7,6 +7,13 @@
7
  ?>
8
  <div class="wc-stripe-cart-checkout-container">
9
  <ul class="wc_stripe_cart_payment_methods">
 
 
 
 
 
 
 
10
  <?php foreach($gateways as $gateway):?>
11
  <li
12
  class="wc-stripe-payment-method payment_method_<?php echo esc_attr($gateway->id)?>">
@@ -15,10 +22,12 @@
15
  </div>
16
  </li>
17
  <?php endforeach;?>
18
- <li class="wc-stripe-payment-method or">
19
- <p class="wc-stripe-cart-or">
20
- &mdash;&nbsp;<?php _e('or', 'woo-stripe-payment')?>&mdash;&nbsp;
21
- </p>
22
- </li>
 
 
23
  </ul>
24
  </div>
7
  ?>
8
  <div class="wc-stripe-cart-checkout-container">
9
  <ul class="wc_stripe_cart_payment_methods">
10
+ <?php if($after):?>
11
+ <li class="wc-stripe-payment-method or">
12
+ <p class="wc-stripe-cart-or">
13
+ &mdash;&nbsp;<?php _e('or', 'woo-stripe-payment')?>&mdash;&nbsp;
14
+ </p>
15
+ </li>
16
+ <?php endif;?>
17
  <?php foreach($gateways as $gateway):?>
18
  <li
19
  class="wc-stripe-payment-method payment_method_<?php echo esc_attr($gateway->id)?>">
22
  </div>
23
  </li>
24
  <?php endforeach;?>
25
+ <?php if(!$after):?>
26
+ <li class="wc-stripe-payment-method or">
27
+ <p class="wc-stripe-cart-or">
28
+ &mdash;&nbsp;<?php _e('or', 'woo-stripe-payment')?>&mdash;&nbsp;
29
+ </p>
30
+ </li>
31
+ <?php endif;?>
32
  </ul>
33
  </div>
templates/cc-forms/bootstrap.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * @version 3.0.4
4
  */
5
  ?>
6
  <div class="wc-stripe-bootstrap-form">
@@ -27,7 +27,7 @@
27
  <?php endif;?>
28
  </div>
29
  </div>
30
- <style>
31
  .wc-stripe-bootstrap-form #stripe-postal-code{
32
  width: 100%;
33
  padding: 10px 12px;
@@ -37,6 +37,10 @@
37
  line-height: normal;
38
  color: #495057;
39
  -webkit-appearance: none;
 
 
 
 
40
  }
41
  #stripe-postal-code:focused{
42
  background: transparent;
@@ -69,6 +73,7 @@ li.payment_method_stripe_cc .payment_box{
69
  }
70
  .wc-stripe-bootstrap-form{
71
  background: #fff !important;
 
72
  }
73
  .wc-stripe-bootstrap-form .row {
74
  display: -ms-flexbox;
@@ -133,7 +138,7 @@ li.payment_method_stripe_cc .payment_box{
133
  -webkit-transform: translateY(-155%);
134
  -ms-transform: translateY(-155%);
135
  transform: translateY(-155%);
136
- background: #fff;
137
  font-weight: 500;
138
  padding-right: 5px;
139
  padding-left: 5px;
1
  <?php
2
  /**
3
+ * @version 3.0.6
4
  */
5
  ?>
6
  <div class="wc-stripe-bootstrap-form">
27
  <?php endif;?>
28
  </div>
29
  </div>
30
+ <style type="text/css">
31
  .wc-stripe-bootstrap-form #stripe-postal-code{
32
  width: 100%;
33
  padding: 10px 12px;
37
  line-height: normal;
38
  color: #495057;
39
  -webkit-appearance: none;
40
+ margin: 0;
41
+ }
42
+ .wc-stripe_cc-container .wc-stripe-save-source .save-source-label{
43
+ margin-top: 0 !important;
44
  }
45
  #stripe-postal-code:focused{
46
  background: transparent;
73
  }
74
  .wc-stripe-bootstrap-form{
75
  background: #fff !important;
76
+ margin-top: 10px;
77
  }
78
  .wc-stripe-bootstrap-form .row {
79
  display: -ms-flexbox;
138
  -webkit-transform: translateY(-155%);
139
  -ms-transform: translateY(-155%);
140
  transform: translateY(-155%);
141
+ background: #fff !important;
142
  font-weight: 500;
143
  padding-right: 5px;
144
  padding-left: 5px;
templates/cc-forms/inline.php CHANGED
@@ -26,7 +26,7 @@
26
  <?php endif;?>
27
  </fieldset>
28
  </div>
29
- <style>
30
  .wc-stripe-inline-form {
31
  background-color: transparent;
32
  padding: 20px 10px;
26
  <?php endif;?>
27
  </fieldset>
28
  </div>
29
+ <style type="text/css">
30
  .wc-stripe-inline-form {
31
  background-color: transparent;
32
  padding: 20px 10px;
templates/cc-forms/minimalist.php CHANGED
@@ -36,7 +36,7 @@ wc_stripe()->scripts()->enqueue_script('cc-forms', wc_stripe()->assets_url('js/f
36
  </div>
37
  <?php endif;?>
38
  </div>
39
- <style>
40
  .wc-stripe_cc-new-method-container{
41
  padding-top: 20px;
42
  }
36
  </div>
37
  <?php endif;?>
38
  </div>
39
+ <style type="text/css">
40
  .wc-stripe_cc-new-method-container{
41
  padding-top: 20px;
42
  }
templates/cc-forms/round.php CHANGED
@@ -15,7 +15,7 @@
15
  <?php endif;?>
16
  </div>
17
  </div>
18
- <style>
19
  .wc-stripe-round-form .StripeElement {
20
  box-shadow: none !important;
21
  }
15
  <?php endif;?>
16
  </div>
17
  </div>
18
+ <style type="text/css">
19
  .wc-stripe-round-form .StripeElement {
20
  box-shadow: none !important;
21
  }
templates/cc-forms/simple.php CHANGED
@@ -37,7 +37,7 @@
37
  </div>
38
  <?php endif;?>
39
  </div>
40
- <style>
41
  .wc-stripe-simple-form {
42
  background-color: #fff;
43
  padding: 10px 0;
37
  </div>
38
  <?php endif;?>
39
  </div>
40
+ <style type="text/css">
41
  .wc-stripe-simple-form {
42
  background-color: #fff;
43
  padding: 10px 0;
templates/checkout/ach.php CHANGED
@@ -10,5 +10,6 @@ wc_stripe_hidden_field ( $gateway->metadata_key );
10
  <p><?php _e('sandbox testing credentials', 'woo-stripe-payment')?>:</p>
11
  <p><strong><?php _e('username', 'woo-stripe-payment')?></strong>:&nbsp;user_good</p>
12
  <p><strong><?php _e('password', 'woo-stripe-payment')?></strong>:&nbsp;pass_good</p>
 
13
  <?php endif;?>
14
  </div>
10
  <p><?php _e('sandbox testing credentials', 'woo-stripe-payment')?>:</p>
11
  <p><strong><?php _e('username', 'woo-stripe-payment')?></strong>:&nbsp;user_good</p>
12
  <p><strong><?php _e('password', 'woo-stripe-payment')?></strong>:&nbsp;pass_good</p>
13
+ <p><strong><?php _e('pin', 'woo-stripe-payment')?></strong>:&nbsp;credential_good&nbsp;(<?php _e('when required', 'woo-stripe-payment')?>)</p>
14
  <?php endif;?>
15
  </div>
templates/checkout/checkout-banner.php CHANGED
@@ -6,6 +6,7 @@
6
  */
7
  ?>
8
  <div class="wc-stripe-banner-checkout">
 
9
  <ul class="wc_stripe_checkout_banner_gateways">
10
  <?php foreach($gateways as $gateway):?>
11
  <li class="wc-stripe-checkout-banner-gateway banner_payment_method_<?php echo $gateway->id?>">
6
  */
7
  ?>
8
  <div class="wc-stripe-banner-checkout">
9
+ <span class="banner-title"><?php _e('Express Checkout', 'woo-stripe-payment')?></span>
10
  <ul class="wc_stripe_checkout_banner_gateways">
11
  <?php foreach($gateways as $gateway):?>
12
  <li class="wc-stripe-checkout-banner-gateway banner_payment_method_<?php echo $gateway->id?>">
templates/checkout/payment-method.php CHANGED
@@ -6,7 +6,7 @@
6
  */
7
  ?>
8
  <?php if(($desc = $gateway->get_description())):?>
9
- <div class="wc-stripe-gateway-desc">
10
  <?php echo wpautop( wptexturize( $desc ) )?>
11
  </div>
12
  <?php endif;?>
6
  */
7
  ?>
8
  <?php if(($desc = $gateway->get_description())):?>
9
+ <div class="wc-stripe-gateway-desc<?php if($tokens):?> has_tokens<?php endif;?>">
10
  <?php echo wpautop( wptexturize( $desc ) )?>
11
  </div>
12
  <?php endif;?>
templates/payment-methods.php CHANGED
@@ -5,7 +5,7 @@
5
  ?>
6
  <input type="radio" class="wc-stripe-payment-type" checked="checked" id="<?php echo $gateway->id?>_use_saved" name="<?php echo $gateway->payment_type_key?>" value="saved"/>
7
  <label for="<?php echo $gateway->id?>_use_saved" class="wc-stripe-label-payment-type"><?php echo $gateway->get_saved_methods_label()?></label>
8
- <div class="wc-<?php echo $gateway->id?>-saved-methods-container">
9
  <select class="wc-stripe-saved-methods" id="<?php echo $gateway->saved_method_key?>" name="<?php echo $gateway->saved_method_key?>">
10
  <?php foreach($tokens as $token):?>
11
  <option class="wc-stripe-saved-method <?php echo $token->get_html_classes()?>" value="<?php echo $token->get_token()?>"><?php echo $token->get_payment_method_title($gateway->get_option('method_format'))?></option>
5
  ?>
6
  <input type="radio" class="wc-stripe-payment-type" checked="checked" id="<?php echo $gateway->id?>_use_saved" name="<?php echo $gateway->payment_type_key?>" value="saved"/>
7
  <label for="<?php echo $gateway->id?>_use_saved" class="wc-stripe-label-payment-type"><?php echo $gateway->get_saved_methods_label()?></label>
8
+ <div class="wc-stripe-saved-methods-container wc-<?php echo $gateway->id?>-saved-methods-container">
9
  <select class="wc-stripe-saved-methods" id="<?php echo $gateway->saved_method_key?>" name="<?php echo $gateway->saved_method_key?>">
10
  <?php foreach($tokens as $token):?>
11
  <option class="wc-stripe-saved-method <?php echo $token->get_html_classes()?>" value="<?php echo $token->get_token()?>"><?php echo $token->get_payment_method_title($gateway->get_option('method_format'))?></option>