Payment Plugins for Stripe WooCommerce - Version 3.1.3

Version Description

  • Added - WC 4.1.1 support
  • Added - Klarna payment categories option
  • Added - Order ID filter added
  • Added - Local payment button filter so text on buttons can be changed
  • Update - Webhook controller returns 401 for failed signature
Download this release

Release Info

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

Code changes from version 3.1.2 to 3.1.3

Files changed (32) hide show
  1. assets/js/frontend/applepay-cart.js +9 -6
  2. assets/js/frontend/applepay-checkout.js +5 -1
  3. assets/js/frontend/applepay-product.js +5 -1
  4. assets/js/frontend/local-payment.js +5 -4
  5. assets/js/frontend/payment-request.js +14 -2
  6. assets/js/frontend/wc-stripe.js +6 -1
  7. assets/js/frontend/wc-stripe.min.js +1 -1
  8. i18n/languages/woo-stripe-payment.pot +30 -14
  9. includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php +18 -0
  10. includes/admin/class-wc-stripe-admin-menus.php +4 -9
  11. includes/class-stripe.php +1 -1
  12. includes/class-wc-stripe-constants.php +7 -0
  13. includes/class-wc-stripe-payment-intent.php +6 -2
  14. includes/class-wc-stripe-redirect-handler.php +3 -2
  15. includes/controllers/class-wc-stripe-controller-webhook.php +1 -1
  16. includes/gateways/class-wc-payment-gateway-stripe-alipay.php +1 -1
  17. includes/gateways/class-wc-payment-gateway-stripe-bancontact.php +1 -1
  18. includes/gateways/class-wc-payment-gateway-stripe-eps.php +1 -1
  19. includes/gateways/class-wc-payment-gateway-stripe-fpx.php +1 -1
  20. includes/gateways/class-wc-payment-gateway-stripe-giropay.php +1 -1
  21. includes/gateways/class-wc-payment-gateway-stripe-ideal.php +1 -1
  22. includes/gateways/class-wc-payment-gateway-stripe-klarna.php +66 -22
  23. includes/gateways/class-wc-payment-gateway-stripe-multibanco.php +1 -1
  24. includes/gateways/class-wc-payment-gateway-stripe-p24.php +1 -1
  25. includes/gateways/class-wc-payment-gateway-stripe-sepa.php +1 -1
  26. includes/gateways/class-wc-payment-gateway-stripe-sofort.php +1 -1
  27. includes/gateways/class-wc-payment-gateway-stripe-wechat.php +1 -1
  28. includes/wc-stripe-functions.php +14 -0
  29. includes/wc-stripe-webhook-functions.php +1 -1
  30. readme.txt +7 -1
  31. stripe-payments.php +2 -2
  32. templates/checkout/klarna.php +10 -7
assets/js/frontend/applepay-cart.js CHANGED
@@ -5,12 +5,6 @@
5
  */
6
  function ApplePay() {
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
- this.add_cart_totals_class();
12
- }.bind(this));
13
-
14
  }
15
 
16
  /**
@@ -19,6 +13,15 @@
19
  */
20
  ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CartGateway.prototype, wc_stripe.ApplePay.prototype);
21
 
 
 
 
 
 
 
 
 
 
22
  /**
23
  * @return {[type]}
24
  */
5
  */
6
  function ApplePay() {
7
  wc_stripe.BaseGateway.call(this, wc_stripe_applepay_cart_params);
 
 
 
 
 
 
8
  }
9
 
10
  /**
13
  */
14
  ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CartGateway.prototype, wc_stripe.ApplePay.prototype);
15
 
16
+ ApplePay.prototype.initialize = function() {
17
+ wc_stripe.CartGateway.call(this);
18
+ wc_stripe.ApplePay.prototype.initialize.call(this);
19
+ this.canMakePayment().then(function() {
20
+ $(this.container).addClass('active').parent().addClass('active');
21
+ this.add_cart_totals_class();
22
+ }.bind(this));
23
+ }
24
+
25
  /**
26
  * @return {[type]}
27
  */
assets/js/frontend/applepay-checkout.js CHANGED
@@ -5,7 +5,6 @@
5
  */
6
  function ApplePay() {
7
  wc_stripe.BaseGateway.call(this, wc_stripe_applepay_checkout_params);
8
- wc_stripe.CheckoutGateway.call(this);
9
  }
10
 
11
  /**
@@ -14,6 +13,11 @@
14
  */
15
  ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype, wc_stripe.ApplePay.prototype);
16
 
 
 
 
 
 
17
  ApplePay.prototype.canMakePayment = function() {
18
  wc_stripe.ApplePay.prototype.canMakePayment.apply(this, arguments).then(function() {
19
  if (this.banner_enabled()) {
5
  */
6
  function ApplePay() {
7
  wc_stripe.BaseGateway.call(this, wc_stripe_applepay_checkout_params);
 
8
  }
9
 
10
  /**
13
  */
14
  ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype, wc_stripe.ApplePay.prototype);
15
 
16
+ ApplePay.prototype.initialize = function() {
17
+ wc_stripe.CheckoutGateway.call(this);
18
+ wc_stripe.ApplePay.prototype.initialize.call(this);
19
+ }
20
+
21
  ApplePay.prototype.canMakePayment = function() {
22
  wc_stripe.ApplePay.prototype.canMakePayment.apply(this, arguments).then(function() {
23
  if (this.banner_enabled()) {
assets/js/frontend/applepay-product.js CHANGED
@@ -2,7 +2,6 @@
2
 
3
  function ApplePay() {
4
  wc_stripe.BaseGateway.call(this, wc_stripe_applepay_product_params);
5
- wc_stripe.ProductGateway.call(this);
6
  this.old_qty = this.get_quantity();
7
  }
8
 
@@ -12,6 +11,11 @@
12
  */
13
  ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.ProductGateway.prototype, wc_stripe.ApplePay.prototype);
14
 
 
 
 
 
 
15
  /**
16
  * @return {[type]}
17
  */
2
 
3
  function ApplePay() {
4
  wc_stripe.BaseGateway.call(this, wc_stripe_applepay_product_params);
 
5
  this.old_qty = this.get_quantity();
6
  }
7
 
11
  */
12
  ApplePay.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.ProductGateway.prototype, wc_stripe.ApplePay.prototype);
13
 
14
+ ApplePay.prototype.initialize = function() {
15
+ wc_stripe.ProductGateway.call(this);
16
+ wc_stripe.ApplePay.prototype.initialize.call(this);
17
+ }
18
+
19
  /**
20
  * @return {[type]}
21
  */
assets/js/frontend/local-payment.js CHANGED
@@ -226,9 +226,9 @@
226
  }
227
 
228
  Klarna.prototype.category_change = function(e) {
229
- $('[id^="klarna-instance-"]').hide();
230
  var category = $('[name="klarna_category"]:checked').val();
231
- $('#klarna-instance-' + category).show();
232
  }
233
 
234
  Klarna.prototype.hashChange = function(e) {
@@ -272,7 +272,7 @@
272
  }
273
  }
274
  }
275
- $('[name="klarna_category"]').first().prop('checked', true).trigger('change');
276
  }
277
  }
278
 
@@ -292,7 +292,8 @@
292
  if (res.error) {
293
  this.submit_error(res.error);
294
  } else {
295
- this.submit_error('Klarna error');
 
296
  }
297
  }
298
  }.bind(this));
226
  }
227
 
228
  Klarna.prototype.category_change = function(e) {
229
+ $('[id^="klarna-instance-"]').slideUp();
230
  var category = $('[name="klarna_category"]:checked').val();
231
+ $('#klarna-instance-' + category).slideDown();
232
  }
233
 
234
  Klarna.prototype.hashChange = function(e) {
272
  }
273
  }
274
  }
275
+ $('[id^="klarna-category-"]:visible [name="klarna_category"]').first().prop('checked', true).trigger('change');
276
  }
277
  }
278
 
292
  if (res.error) {
293
  this.submit_error(res.error);
294
  } else {
295
+ this.payment_categories = null;
296
+ this.submit_error(this.params.messages.klarna_error);
297
  }
298
  }
299
  }.bind(this));
assets/js/frontend/payment-request.js CHANGED
@@ -13,6 +13,11 @@
13
 
14
  PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.ProductGateway.prototype, wc_stripe.PaymentRequest.prototype);
15
 
 
 
 
 
 
16
  /**
17
  * [canMakePayment description]
18
  * @return {[type]} [description]
@@ -114,11 +119,15 @@
114
  */
115
  function PaymentRequest() {
116
  wc_stripe.BaseGateway.call(this, wc_stripe_payment_request_params);
117
- wc_stripe.CartGateway.call(this);
118
  }
119
 
120
  PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CartGateway.prototype, wc_stripe.PaymentRequest.prototype);
121
 
 
 
 
 
 
122
  PaymentRequest.prototype.canMakePayment = function() {
123
  wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function() {
124
  $(this.container).addClass('active').parent().addClass('active');
@@ -160,11 +169,14 @@
160
  */
161
  function PaymentRequest() {
162
  wc_stripe.BaseGateway.call(this, wc_stripe_payment_request_params);
163
- wc_stripe.CheckoutGateway.call(this);
164
  }
165
 
166
  PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype, wc_stripe.PaymentRequest.prototype);
167
 
 
 
 
 
168
  /**
169
  * [canMakePayment description]
170
  * @return {[type]} [description]
13
 
14
  PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.ProductGateway.prototype, wc_stripe.PaymentRequest.prototype);
15
 
16
+ PaymentRequest.prototype.initialize = function() {
17
+ wc_stripe.ProductGateway.call(this);
18
+ wc_stripe.PaymentRequest.prototype.initialize.call(this);
19
+ }
20
+
21
  /**
22
  * [canMakePayment description]
23
  * @return {[type]} [description]
119
  */
120
  function PaymentRequest() {
121
  wc_stripe.BaseGateway.call(this, wc_stripe_payment_request_params);
 
122
  }
123
 
124
  PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CartGateway.prototype, wc_stripe.PaymentRequest.prototype);
125
 
126
+ PaymentRequest.prototype.initialize = function() {
127
+ wc_stripe.CartGateway.call(this);
128
+ wc_stripe.PaymentRequest.prototype.initialize.call(this);
129
+ }
130
+
131
  PaymentRequest.prototype.canMakePayment = function() {
132
  wc_stripe.PaymentRequest.prototype.canMakePayment.apply(this, arguments).then(function() {
133
  $(this.container).addClass('active').parent().addClass('active');
169
  */
170
  function PaymentRequest() {
171
  wc_stripe.BaseGateway.call(this, wc_stripe_payment_request_params);
 
172
  }
173
 
174
  PaymentRequest.prototype = $.extend({}, wc_stripe.BaseGateway.prototype, wc_stripe.CheckoutGateway.prototype, wc_stripe.PaymentRequest.prototype);
175
 
176
+ PaymentRequest.prototype.initialize = function() {
177
+ wc_stripe.CheckoutGateway.call(this);
178
+ wc_stripe.PaymentRequest.prototype.initialize.call(this);
179
+ }
180
  /**
181
  * [canMakePayment description]
182
  * @return {[type]} [description]
assets/js/frontend/wc-stripe.js CHANGED
@@ -260,7 +260,12 @@
260
  }
261
 
262
  wc_stripe.BaseGateway.prototype.createPaymentRequest = function() {
263
- this.paymentRequest = stripe.paymentRequest(this.get_payment_request_options());
 
 
 
 
 
264
 
265
  // events
266
  if (this.needs_shipping()) {
260
  }
261
 
262
  wc_stripe.BaseGateway.prototype.createPaymentRequest = function() {
263
+ try {
264
+ this.paymentRequest = stripe.paymentRequest(this.get_payment_request_options());
265
+ } catch (err) {
266
+ this.submit_error(err.message);
267
+ return;
268
+ }
269
 
270
  // events
271
  if (this.needs_shipping()) {
assets/js/frontend/wc-stripe.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){t.wc_stripe={};var i=null;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=this.get_error_message(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.get_error_message=function(t){return"object"==typeof t&&t.code&&(t=wc_stripe_messages[t.code]?wc_stripe_messages[t.code]:t.message),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.CheckoutGateway.prototype.checkout_fields_valid=function(){if("undefined"==typeof wc_stripe_checkout_fields)return!0;var t=Object.keys(wc_stripe_checkout_fields.billing),i=Object.keys(wc_stripe_checkout_fields.shipping);function a(t,i){for(var a=0;a<t.length;a++){if(i[t[a]].required){var n=e("#"+t[a]).val();if(void 0===n||0==n.length)return void(valid=!1)}}}return valid=!0,a(t,wc_stripe_checkout_fields.billing),this.needs_shipping()&&e("#ship-to-different-address-checkbox").is(":checked")&&a(i,wc_stripe_checkout_fields.shipping),valid=this.is_valid_checkout(),valid},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(),(marginLeft=e(".single_add_to_cart_button").css("marginLeft"))&&(this.buttonWidth+=parseInt(marginLeft.replace("px",""))),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(this.get_error_message(t))},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.CartGateway.prototype.add_cart_totals_class=function(){e(".cart_totals").addClass("stripe_cart_gateway_active")},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")};try{i=Stripe(wc_stripe_params_v3.api_key)}catch(e){return t.alert(e),void console.log(e)}}(window,jQuery);
1
+ !function(t,e){t.wc_stripe={};var i=null;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=this.get_error_message(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.get_error_message=function(t){return"object"==typeof t&&t.code&&(t=wc_stripe_messages[t.code]?wc_stripe_messages[t.code]:t.message),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(){try{this.paymentRequest=i.paymentRequest(this.get_payment_request_options())}catch(t){return void this.submit_error(t.message)}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.CheckoutGateway.prototype.checkout_fields_valid=function(){if("undefined"==typeof wc_stripe_checkout_fields)return!0;var t=Object.keys(wc_stripe_checkout_fields.billing),i=Object.keys(wc_stripe_checkout_fields.shipping);function a(t,i){for(var a=0;a<t.length;a++){if(i[t[a]].required){var n=e("#"+t[a]).val();if(void 0===n||0==n.length)return void(valid=!1)}}}return valid=!0,a(t,wc_stripe_checkout_fields.billing),this.needs_shipping()&&e("#ship-to-different-address-checkbox").is(":checked")&&a(i,wc_stripe_checkout_fields.shipping),valid=this.is_valid_checkout(),valid},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(),(marginLeft=e(".single_add_to_cart_button").css("marginLeft"))&&(this.buttonWidth+=parseInt(marginLeft.replace("px",""))),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(this.get_error_message(t))},wc_stripe.CartGateway.prototype.updated_html=function(t){},wc_stripe.CartGateway.prototype.add_cart_totals_class=function(){e(".cart_totals").addClass("stripe_cart_gateway_active")},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")};try{i=Stripe(wc_stripe_params_v3.api_key)}catch(e){return t.alert(e),void console.log(e)}}(window,jQuery);
i18n/languages/woo-stripe-payment.pot CHANGED
@@ -2,14 +2,14 @@
2
  # This file is distributed under the same license as the Stripe For WooCommerce plugin.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Stripe For WooCommerce 3.1.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2020-05-05T17:45:47+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: woo-stripe-payment\n"
@@ -90,11 +90,11 @@ msgstr ""
90
  msgid "Order %s"
91
  msgstr ""
92
 
93
- #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:239
94
  msgid "Gateway will appear when store currency is <strong>%s</strong>"
95
  msgstr ""
96
 
97
- #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:242
98
  msgid " & billing country is <strong>%s</strong>"
99
  msgstr ""
100
 
@@ -261,7 +261,7 @@ msgstr ""
261
  msgid "Logs"
262
  msgstr ""
263
 
264
- #: includes/admin/class-wc-stripe-admin-menus.php:36
265
  #: includes/admin/views/html-settings-nav.php:17
266
  #: includes/class-wc-stripe-install.php:31
267
  msgid "Documentation"
@@ -651,11 +651,11 @@ msgstr ""
651
  msgid "Error retrieving payment source. Reason: %s"
652
  msgstr ""
653
 
654
- #: includes/class-wc-stripe-redirect-handler.php:53
655
  msgid "Payment authorization failed. Please select another payment method."
656
  msgstr ""
657
 
658
- #: includes/class-wc-stripe-redirect-handler.php:54
659
  msgid "Payment authorization failed."
660
  msgstr ""
661
 
@@ -894,7 +894,7 @@ msgstr ""
894
 
895
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:122
896
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:174
897
- #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:169
898
  #: includes/wc-stripe-functions.php:363
899
  #: includes/wc-stripe-functions.php:411
900
  msgid "Shipping"
@@ -902,7 +902,7 @@ msgstr ""
902
 
903
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:130
904
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:195
905
- #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:179
906
  #: includes/wc-stripe-functions.php:379
907
  #: includes/wc-stripe-functions.php:419
908
  msgid "Discount"
@@ -914,7 +914,7 @@ msgid "Fees"
914
  msgstr ""
915
 
916
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:203
917
- #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:200
918
  #: includes/wc-stripe-functions.php:387
919
  msgid "Tax"
920
  msgstr ""
@@ -949,22 +949,38 @@ msgstr ""
949
  msgid "Klarna gateway that integrates with your Stripe account."
950
  msgstr ""
951
 
952
- #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:192
 
 
 
 
 
 
 
 
953
  msgid "Fee"
954
  msgstr ""
955
 
956
- #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:228
957
  msgid "Pay Now"
958
  msgstr ""
959
 
960
- #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:229
961
  msgid "Pay Later"
962
  msgstr ""
963
 
964
- #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:230
965
  msgid "Pay Over Time"
966
  msgstr ""
967
 
 
 
 
 
 
 
 
 
968
  #: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:24
969
  #: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:30
970
  msgid "Multibanco"
2
  # This file is distributed under the same license as the Stripe For WooCommerce plugin.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Stripe For WooCommerce 3.1.3\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-stripe-payment\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2020-05-26T01:32:43+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.4.0\n"
15
  "X-Domain: woo-stripe-payment\n"
90
  msgid "Order %s"
91
  msgstr ""
92
 
93
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:244
94
  msgid "Gateway will appear when store currency is <strong>%s</strong>"
95
  msgstr ""
96
 
97
+ #: includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php:247
98
  msgid " & billing country is <strong>%s</strong>"
99
  msgstr ""
100
 
261
  msgid "Logs"
262
  msgstr ""
263
 
264
+ #: includes/admin/class-wc-stripe-admin-menus.php:31
265
  #: includes/admin/views/html-settings-nav.php:17
266
  #: includes/class-wc-stripe-install.php:31
267
  msgid "Documentation"
651
  msgid "Error retrieving payment source. Reason: %s"
652
  msgstr ""
653
 
654
+ #: includes/class-wc-stripe-redirect-handler.php:54
655
  msgid "Payment authorization failed. Please select another payment method."
656
  msgstr ""
657
 
658
+ #: includes/class-wc-stripe-redirect-handler.php:55
659
  msgid "Payment authorization failed."
660
  msgstr ""
661
 
894
 
895
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:122
896
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:174
897
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:194
898
  #: includes/wc-stripe-functions.php:363
899
  #: includes/wc-stripe-functions.php:411
900
  msgid "Shipping"
902
 
903
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:130
904
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:195
905
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:204
906
  #: includes/wc-stripe-functions.php:379
907
  #: includes/wc-stripe-functions.php:419
908
  msgid "Discount"
914
  msgstr ""
915
 
916
  #: includes/gateways/class-wc-payment-gateway-stripe-googlepay.php:203
917
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:225
918
  #: includes/wc-stripe-functions.php:387
919
  msgid "Tax"
920
  msgstr ""
949
  msgid "Klarna gateway that integrates with your Stripe account."
950
  msgstr ""
951
 
952
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:104
953
+ msgid "Payment Categories"
954
+ msgstr ""
955
+
956
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:110
957
+ msgid "Thes are the payment categories that will be displayed on the checkout page if they are supported. Note, depending on the customer's billing country, not all enabled options may show."
958
+ msgstr ""
959
+
960
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:217
961
  msgid "Fee"
962
  msgstr ""
963
 
964
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:256
965
  msgid "Pay Now"
966
  msgstr ""
967
 
968
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:257
969
  msgid "Pay Later"
970
  msgstr ""
971
 
972
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:258
973
  msgid "Pay Over Time"
974
  msgstr ""
975
 
976
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:269
977
+ msgid "Click %shere%s for Klarna test payment methods."
978
+ msgstr ""
979
+
980
+ #: includes/gateways/class-wc-payment-gateway-stripe-klarna.php:274
981
+ msgid "Your purchase is not approved."
982
+ msgstr ""
983
+
984
  #: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:24
985
  #: includes/gateways/class-wc-payment-gateway-stripe-multibanco.php:30
986
  msgid "Multibanco"
includes/abstract/abstract-wc-payment-gateway-stripe-local-payment.php CHANGED
@@ -233,6 +233,11 @@ abstract class WC_Payment_Gateway_Stripe_Local_Payment extends WC_Payment_Gatewa
233
  return $token;
234
  }
235
 
 
 
 
 
 
236
  protected function get_payment_description() {
237
  $desc = '';
238
  if ($this->currencies) {
@@ -244,7 +249,20 @@ abstract class WC_Payment_Gateway_Stripe_Local_Payment extends WC_Payment_Gatewa
244
  return $desc;
245
  }
246
 
 
 
 
247
  public function get_local_payment_description() {
248
  return apply_filters ( 'wc_stripe_local_payment_description', $this->local_payment_description );
249
  }
 
 
 
 
 
 
 
 
 
 
250
  }
233
  return $token;
234
  }
235
 
236
+ /**
237
+ * Return a description for (for admin sections) describing the required currency & or billing country(s).
238
+ *
239
+ * @return string
240
+ */
241
  protected function get_payment_description() {
242
  $desc = '';
243
  if ($this->currencies) {
249
  return $desc;
250
  }
251
 
252
+ /**
253
+ * Return a description of the payment method.
254
+ */
255
  public function get_local_payment_description() {
256
  return apply_filters ( 'wc_stripe_local_payment_description', $this->local_payment_description );
257
  }
258
+
259
+ /**
260
+ *
261
+ * @since 3.1.3
262
+ * @param string $text
263
+ * @return string
264
+ */
265
+ public function get_order_button_text($text) {
266
+ return apply_filters ( 'wc_stripe_order_button_text', $text, $this );
267
+ }
268
  }
includes/admin/class-wc-stripe-admin-menus.php CHANGED
@@ -22,18 +22,13 @@ class WC_Stripe_Admin_Menus {
22
  }
23
 
24
  public static function admin_menu() {
25
- add_menu_page ( __ ( 'Stripe Gateway', 'woo-stripe-payment' ), __ ( 'Stripe Gateway', 'woo-stripe-payment' ), 'administrator', 'wc_stripe', null, null, '7.458' );
26
  }
27
 
28
  public static function sub_menu() {
29
- add_submenu_page ( 'wc_stripe', __ ( 'Settings', 'woo-stripe-payment' ), __ ( 'Settings', 'woo-stripe-payment' ), 'administrator', admin_url ( 'admin.php?page=wc-settings&tab=checkout&section=stripe_api' ) );
30
- add_submenu_page ( 'wc_stripe', __ ( 'Logs', 'woo-stripe-payment' ), __ ( 'Logs', 'woo-stripe-payment' ), 'administrator', admin_url ( 'admin.php?page=wc-status&tab=logs' ) );
31
- /*
32
- * add_submenu_page ( 'wc_stripe', __ ( 'Data Migration', 'woo-stripe-payment' ), __ ( 'Data Migration', 'woo-stripe-payment' ), 'administrator', 'wc-stripe-data-migration', array(
33
- * __CLASS__, 'data_migration_page'
34
- * ) );
35
- */
36
- add_submenu_page ( 'wc_stripe', __ ( 'Documentation', 'woo-stripe-payment' ), __ ( 'Documentation', 'woo-stripe-payment' ), 'administrator', 'https://docs.paymentplugins.com/wc-stripe/config' );
37
  }
38
 
39
  public static function remove_submenu() {
22
  }
23
 
24
  public static function admin_menu() {
25
+ add_menu_page ( __ ( 'Stripe Gateway', 'woo-stripe-payment' ), __ ( 'Stripe Gateway', 'woo-stripe-payment' ), 'manage_woocommerce', 'wc_stripe', null, null, '7.458' );
26
  }
27
 
28
  public static function sub_menu() {
29
+ add_submenu_page ( 'wc_stripe', __ ( 'Settings', 'woo-stripe-payment' ), __ ( 'Settings', 'woo-stripe-payment' ), 'manage_woocommerce', admin_url ( 'admin.php?page=wc-settings&tab=checkout&section=stripe_api' ) );
30
+ add_submenu_page ( 'wc_stripe', __ ( 'Logs', 'woo-stripe-payment' ), __ ( 'Logs', 'woo-stripe-payment' ), 'manage_woocommerce', admin_url ( 'admin.php?page=wc-status&tab=logs' ) );
31
+ add_submenu_page ( 'wc_stripe', __ ( 'Documentation', 'woo-stripe-payment' ), __ ( 'Documentation', 'woo-stripe-payment' ), 'manage_woocommerce', 'https://docs.paymentplugins.com/wc-stripe/config' );
 
 
 
 
 
32
  }
33
 
34
  public static function remove_submenu() {
includes/class-stripe.php CHANGED
@@ -24,7 +24,7 @@ class WC_Stripe_Manager {
24
  *
25
  * @var string
26
  */
27
- public $version = '3.1.2';
28
 
29
  /**
30
  *
24
  *
25
  * @var string
26
  */
27
+ public $version = '3.1.3';
28
 
29
  /**
30
  *
includes/class-wc-stripe-constants.php CHANGED
@@ -36,4 +36,11 @@ class WC_Stripe_Constants {
36
  const PRODUCT_GATEWAY_ORDER = '_stripe_gateway_order';
37
 
38
  const BUTTON_POSITION = '_stripe_button_position';
 
 
 
 
 
 
 
39
  }
36
  const PRODUCT_GATEWAY_ORDER = '_stripe_gateway_order';
37
 
38
  const BUTTON_POSITION = '_stripe_button_position';
39
+
40
+ /**
41
+ *
42
+ * @since 3.1.3
43
+ * @var unknown
44
+ */
45
+ const REDIRECT_HANDLER = 'redirect_handler';
46
  }
includes/class-wc-stripe-payment-intent.php CHANGED
@@ -160,12 +160,16 @@ class WC_Stripe_Payment_Intent extends WC_Stripe_Payment {
160
  }
161
 
162
  /**
163
- * Compares the order's saved intent to the order's updates attributes.
164
- * If there is a delta, then the payment intent can be updated.
 
165
  *
166
  * @param WC_Order $order
167
  */
168
  public function can_update_payment_intent($order) {
 
 
 
169
  $intent = $order->get_meta ( WC_Stripe_Constants::PAYMENT_INTENT );
170
  if ($intent) {
171
  $order_hash = implode ( '_', [
160
  }
161
 
162
  /**
163
+ * Compares the order's saved intent to the order's attributes.
164
+ * If there is a delta, then the payment intent can be updated. The intent should
165
+ * only be updated if this is the checkout page.
166
  *
167
  * @param WC_Order $order
168
  */
169
  public function can_update_payment_intent($order) {
170
+ if (! is_checkout () || defined ( WC_Stripe_Constants::REDIRECT_HANDLER )) {
171
+ return false;
172
+ }
173
  $intent = $order->get_meta ( WC_Stripe_Constants::PAYMENT_INTENT );
174
  if ($intent) {
175
  $order_hash = implode ( '_', [
includes/class-wc-stripe-redirect-handler.php CHANGED
@@ -39,8 +39,9 @@ class WC_Stripe_Redirect_Handler {
39
  wc_add_notice ( sprintf ( __ ( 'Error retrieving payment source. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message () ), 'error' );
40
  return;
41
  } else {
 
42
  $order_id = $result->metadata[ 'order_id' ];
43
- $order = wc_get_order ( $order_id );
44
 
45
  /**
46
  *
@@ -49,7 +50,7 @@ class WC_Stripe_Redirect_Handler {
49
  $payment_method = WC ()->payment_gateways ()->payment_gateways ()[ $order->get_payment_method () ];
50
  $redirect = $order->get_checkout_order_received_url ();
51
 
52
- if ('failed' === $result->status || 'requires_payment_method' == $result->status) {
53
  wc_add_notice ( __ ( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
54
  $order->update_status ( 'failed', __ ( 'Payment authorization failed.', 'woo-stripe-payment' ) );
55
  if ($result instanceof \Stripe\PaymentIntent) {
39
  wc_add_notice ( sprintf ( __ ( 'Error retrieving payment source. Reason: %s', 'woo-stripe-payment' ), $result->get_error_message () ), 'error' );
40
  return;
41
  } else {
42
+ define ( WC_Stripe_Constants::REDIRECT_HANDLER, true );
43
  $order_id = $result->metadata[ 'order_id' ];
44
+ $order = wc_get_order ( wc_stripe_filter_order_id ( $order_id, $result ) );
45
 
46
  /**
47
  *
50
  $payment_method = WC ()->payment_gateways ()->payment_gateways ()[ $order->get_payment_method () ];
51
  $redirect = $order->get_checkout_order_received_url ();
52
 
53
+ if ('failed' === $result->status || 'requires_payment_method' === $result->status) {
54
  wc_add_notice ( __ ( 'Payment authorization failed. Please select another payment method.', 'woo-stripe-payment' ), 'error' );
55
  $order->update_status ( 'failed', __ ( 'Payment authorization failed.', 'woo-stripe-payment' ) );
56
  if ($result instanceof \Stripe\PaymentIntent) {
includes/controllers/class-wc-stripe-controller-webhook.php CHANGED
@@ -44,7 +44,7 @@ class WC_Stripe_Controller_Webhook extends WC_Stripe_Rest_Controller {
44
  return rest_ensure_response ( apply_filters ( 'wc_stripe_webhook_response', [], $event, $request ) );
45
  } catch ( \Stripe\Error\SignatureVerification $e ) {
46
  wc_stripe_log_info ( __ ( 'Invalid signature received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ) );
47
- return $this->send_error_response ( __ ( 'Invalid signature received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ) );
48
  } catch ( Exception $e ) {
49
  return $this->send_error_response ( $e->getMessage () );
50
  }
44
  return rest_ensure_response ( apply_filters ( 'wc_stripe_webhook_response', [], $event, $request ) );
45
  } catch ( \Stripe\Error\SignatureVerification $e ) {
46
  wc_stripe_log_info ( __ ( 'Invalid signature received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ) );
47
+ return $this->send_error_response ( __ ( 'Invalid signature received. Verify that your webhook secret is correct.', 'woo-stripe-payment' ), 401 );
48
  } catch ( Exception $e ) {
49
  return $this->send_error_response ( $e->getMessage () );
50
  }
includes/gateways/class-wc-payment-gateway-stripe-alipay.php CHANGED
@@ -28,7 +28,7 @@ class WC_Payment_Gateway_Stripe_Alipay extends WC_Payment_Gateway_Stripe_Local_P
28
  $this->method_title = __ ( 'Alipay', 'woo-stripe-payment' );
29
  $this->method_description = __ ( 'Alipay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
30
  $this->icon = wc_stripe ()->assets_url ( 'img/alipay.svg' );
31
- $this->order_button_text = __ ( 'Alipay', 'woo-stripe-payment' );
32
  parent::__construct ();
33
  }
34
  }
28
  $this->method_title = __ ( 'Alipay', 'woo-stripe-payment' );
29
  $this->method_description = __ ( 'Alipay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
30
  $this->icon = wc_stripe ()->assets_url ( 'img/alipay.svg' );
31
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'Alipay', 'woo-stripe-payment' ) );
32
  parent::__construct ();
33
  }
34
  }
includes/gateways/class-wc-payment-gateway-stripe-bancontact.php CHANGED
@@ -28,7 +28,7 @@ class WC_Payment_Gateway_Stripe_Bancontact extends WC_Payment_Gateway_Stripe_Loc
28
  $this->method_title = __ ( 'Bancontact', 'woo-stripe-payment' );
29
  $this->method_description = __ ( 'Bancontact gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
30
  $this->icon = wc_stripe ()->assets_url ( 'img/bancontact.svg' );
31
- $this->order_button_text = __ ( 'Bancontact', 'woo-stripe-payment' );
32
  parent::__construct ();
33
  }
34
  }
28
  $this->method_title = __ ( 'Bancontact', 'woo-stripe-payment' );
29
  $this->method_description = __ ( 'Bancontact gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
30
  $this->icon = wc_stripe ()->assets_url ( 'img/bancontact.svg' );
31
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'Bancontact', 'woo-stripe-payment' ) );
32
  parent::__construct ();
33
  }
34
  }
includes/gateways/class-wc-payment-gateway-stripe-eps.php CHANGED
@@ -27,7 +27,7 @@ class WC_Payment_Gateway_Stripe_EPS extends WC_Payment_Gateway_Stripe_Local_Paym
27
  $this->method_title = __ ( 'EPS', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'EPS gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/eps.svg' );
30
- $this->order_button_text = __ ( 'EPS', 'woo-stripe-payment' );
31
  parent::__construct ();
32
  }
33
  }
27
  $this->method_title = __ ( 'EPS', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'EPS gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/eps.svg' );
30
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'EPS', 'woo-stripe-payment' ) );
31
  parent::__construct ();
32
  }
33
  }
includes/gateways/class-wc-payment-gateway-stripe-fpx.php CHANGED
@@ -27,7 +27,7 @@ class WC_Payment_Gateway_Stripe_FPX extends WC_Payment_Gateway_Stripe_Local_Paym
27
  $this->method_title = __ ( 'FPX', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'FPX gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/fpx.svg' );
30
- $this->order_button_text = __ ( 'FPX', 'woo-stripe-payment' );
31
  parent::__construct ();
32
  }
33
 
27
  $this->method_title = __ ( 'FPX', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'FPX gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/fpx.svg' );
30
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'FPX', 'woo-stripe-payment' ) );
31
  parent::__construct ();
32
  }
33
 
includes/gateways/class-wc-payment-gateway-stripe-giropay.php CHANGED
@@ -27,7 +27,7 @@ class WC_Payment_Gateway_Stripe_Giropay extends WC_Payment_Gateway_Stripe_Local_
27
  $this->method_title = __ ( 'Giropay', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'Giropay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/giropay.svg' );
30
- $this->order_button_text = __ ( 'Giropay', 'woo-stripe-payment' );
31
  parent::__construct ();
32
  }
33
  }
27
  $this->method_title = __ ( 'Giropay', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'Giropay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/giropay.svg' );
30
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'Giropay', 'woo-stripe-payment' ) );
31
  parent::__construct ();
32
  }
33
  }
includes/gateways/class-wc-payment-gateway-stripe-ideal.php CHANGED
@@ -29,7 +29,7 @@ class WC_Payment_Gateway_Stripe_Ideal extends WC_Payment_Gateway_Stripe_Local_Pa
29
  $this->method_title = __ ( 'iDEAL', 'woo-stripe-payment' );
30
  $this->method_description = __ ( 'Ideal gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
31
  $this->icon = wc_stripe ()->assets_url ( 'img/ideal.svg' );
32
- $this->order_button_text = __ ( 'iDEAL', 'woo-stripe-payment' );
33
  parent::__construct ();
34
  }
35
  }
29
  $this->method_title = __ ( 'iDEAL', 'woo-stripe-payment' );
30
  $this->method_description = __ ( 'Ideal gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
31
  $this->icon = wc_stripe ()->assets_url ( 'img/ideal.svg' );
32
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'iDEAL', 'woo-stripe-payment' ) );
33
  parent::__construct ();
34
  }
35
  }
includes/gateways/class-wc-payment-gateway-stripe-klarna.php CHANGED
@@ -26,7 +26,7 @@ class WC_Payment_Gateway_Stripe_Klarna extends WC_Payment_Gateway_Stripe_Local_P
26
  $this->method_title = __ ( 'Klarna', 'woo-stripe-payment' );
27
  $this->method_description = __ ( 'Klarna gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
28
  $this->icon = wc_stripe ()->assets_url ( 'img/klarna.svg' );
29
- $this->order_button_text = __ ( 'Klarna', 'woo-stripe-payment' );
30
  parent::__construct ();
31
  $this->template_name = 'klarna.php';
32
  }
@@ -91,14 +91,29 @@ class WC_Payment_Gateway_Stripe_Klarna extends WC_Payment_Gateway_Stripe_Local_P
91
  // this might be an update checkout request. If so, update the source if it exists
92
  if (is_ajax () && ( $order_id = absint ( WC ()->session->get ( 'order_awaiting_payment' ) ) )) {
93
  $order = wc_get_order ( $order_id );
94
- $source_id = $order->get_meta ( WC_Stripe_Constants::SOURCE_ID, true );
95
- $this->gateway->update_source ( $source_id, $this->get_update_source_args ( $order ) );
 
96
  }
97
  parent::payment_fields ();
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  private function get_update_source_args($order) {
101
- $args = $this->get_source_args ( $order );
102
  unset ( $args[ 'type' ], $args[ 'currency' ], $args[ 'statement_descriptor' ], $args[ 'redirect' ], $args[ 'klarna' ][ 'product' ], $args[ 'klarna' ][ 'locale' ] );
103
  return $args;
104
  }
@@ -109,21 +124,31 @@ class WC_Payment_Gateway_Stripe_Klarna extends WC_Payment_Gateway_Stripe_Local_P
109
  *
110
  * @see WC_Payment_Gateway_Stripe_Local_Payment::get_source_args()
111
  */
112
- public function get_source_args($order) {
 
 
 
 
 
 
 
 
 
 
113
  $args = array_merge_recursive ( parent::get_source_args ( $order ), [
114
  'klarna' => [ 'product' => 'payment',
115
- 'purchase_country' => $order->get_billing_country (),
116
- 'first_name' => $order->get_billing_first_name (),
117
- 'last_name' => $order->get_billing_last_name ()
118
  ],
119
  'owner' => [
120
  'address' => [
121
- 'city' => $order->get_billing_city (),
122
- 'country' => $order->get_billing_country (),
123
- 'line1' => $order->get_billing_address_1 (),
124
- 'line2' => $order->get_billing_address_2 (),
125
- 'postal_code' => $order->get_billing_postcode (),
126
- 'state' => $order->get_billing_state ()
127
  ]
128
  ]
129
  ] );
@@ -134,15 +159,15 @@ class WC_Payment_Gateway_Stripe_Klarna extends WC_Payment_Gateway_Stripe_Local_P
134
  }
135
 
136
  if ($order->get_shipping_address_1 ()) {
137
- $args[ 'klarna' ][ 'shipping_first_name' ] = $order->get_shipping_first_name ();
138
- $args[ 'klarna' ][ 'shipping_last_name' ] = $order->get_shipping_last_name ();
139
  $args[ 'source_order' ][ 'shipping' ][ 'address' ] = [
140
- 'city' => $order->get_billing_city (),
141
- 'country' => $order->get_shipping_country (),
142
- 'line1' => $order->get_shipping_address_1 (),
143
- 'line2' => $order->get_shipping_address_2 (),
144
- 'postal_code' => $order->get_shipping_postcode (),
145
- 'state' => $order->get_shipping_state ()
146
  ];
147
  }
148
 
@@ -212,6 +237,9 @@ class WC_Payment_Gateway_Stripe_Klarna extends WC_Payment_Gateway_Stripe_Local_P
212
  * @see WC_Payment_Gateway_Stripe_Local_Payment::get_source_redirect_url()
213
  */
214
  public function get_source_redirect_url($source, $order) {
 
 
 
215
  return '#local_payment=klarna&redirect=' . $this->get_local_payment_return_url ( $order ) . '&encoded_source=' . base64_encode ( wp_json_encode ( $source ) );
216
  }
217
 
@@ -230,4 +258,20 @@ class WC_Payment_Gateway_Stripe_Klarna extends WC_Payment_Gateway_Stripe_Local_P
230
  'pay_over_time' => __ ( 'Pay Over Time', 'woo-stripe-payment' )
231
  ] );
232
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  }
26
  $this->method_title = __ ( 'Klarna', 'woo-stripe-payment' );
27
  $this->method_description = __ ( 'Klarna gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
28
  $this->icon = wc_stripe ()->assets_url ( 'img/klarna.svg' );
29
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'Klarna', 'woo-stripe-payment' ) );
30
  parent::__construct ();
31
  $this->template_name = 'klarna.php';
32
  }
91
  // this might be an update checkout request. If so, update the source if it exists
92
  if (is_ajax () && ( $order_id = absint ( WC ()->session->get ( 'order_awaiting_payment' ) ) )) {
93
  $order = wc_get_order ( $order_id );
94
+ if (( $source_id = $order->get_meta ( WC_Stripe_Constants::SOURCE_ID, true ) )) {
95
+ $this->payment_object->get_gateway ()->update_source ( $source_id, $this->get_update_source_args ( $order ) );
96
+ }
97
  }
98
  parent::payment_fields ();
99
  }
100
 
101
+ public function get_local_payment_settings() {
102
+ return wp_parse_args ( [
103
+ 'payment_categories' => [
104
+ 'title' => __ ( 'Payment Categories', 'woo-stripe-payment' ),
105
+ 'type' => 'multiselect',
106
+ 'class' => 'wc-enhanced-select',
107
+ 'options' => $this->get_payment_categories (),
108
+ 'default' => array_keys ( $this->get_payment_categories () ),
109
+ 'desc_tip' => true,
110
+ 'description' => __ ( 'Thes are the payment categories that will be displayed on the checkout page if they are supported. Note, depending on the customer\'s billing country, not all enabled options may show.', 'woo-stripe-payment' )
111
+ ]
112
+ ], parent::get_local_payment_settings () );
113
+ }
114
+
115
  private function get_update_source_args($order) {
116
+ $args = $this->get_source_args ( $order, true );
117
  unset ( $args[ 'type' ], $args[ 'currency' ], $args[ 'statement_descriptor' ], $args[ 'redirect' ], $args[ 'klarna' ][ 'product' ], $args[ 'klarna' ][ 'locale' ] );
118
  return $args;
119
  }
124
  *
125
  * @see WC_Payment_Gateway_Stripe_Local_Payment::get_source_args()
126
  */
127
+ public function get_source_args($order, $update = false) {
128
+ if ($update) {
129
+ /*
130
+ * Use customer if this is an update since customer object has been updated
131
+ * with all checkout form data in the update_order_review process.
132
+ */
133
+ $object = WC ()->customer;
134
+ } else {
135
+ $object = $order;
136
+ }
137
+
138
  $args = array_merge_recursive ( parent::get_source_args ( $order ), [
139
  'klarna' => [ 'product' => 'payment',
140
+ 'purchase_country' => $object->get_billing_country (),
141
+ 'first_name' => $object->get_billing_first_name (),
142
+ 'last_name' => $object->get_billing_last_name ()
143
  ],
144
  'owner' => [
145
  'address' => [
146
+ 'city' => $object->get_billing_city (),
147
+ 'country' => $object->get_billing_country (),
148
+ 'line1' => $object->get_billing_address_1 (),
149
+ 'line2' => $object->get_billing_address_2 (),
150
+ 'postal_code' => $object->get_billing_postcode (),
151
+ 'state' => $object->get_billing_state ()
152
  ]
153
  ]
154
  ] );
159
  }
160
 
161
  if ($order->get_shipping_address_1 ()) {
162
+ $args[ 'klarna' ][ 'shipping_first_name' ] = $object->get_shipping_first_name ();
163
+ $args[ 'klarna' ][ 'shipping_last_name' ] = $object->get_shipping_last_name ();
164
  $args[ 'source_order' ][ 'shipping' ][ 'address' ] = [
165
+ 'city' => $object->get_billing_city (),
166
+ 'country' => $object->get_shipping_country (),
167
+ 'line1' => $object->get_shipping_address_1 (),
168
+ 'line2' => $object->get_shipping_address_2 (),
169
+ 'postal_code' => $object->get_shipping_postcode (),
170
+ 'state' => $object->get_shipping_state ()
171
  ];
172
  }
173
 
237
  * @see WC_Payment_Gateway_Stripe_Local_Payment::get_source_redirect_url()
238
  */
239
  public function get_source_redirect_url($source, $order) {
240
+ $klarna_categories = explode ( ',', $source[ 'klarna' ][ 'payment_method_categories' ] );
241
+ $klarna_categories = array_intersect ( $klarna_categories, $this->get_option ( 'payment_categories' ) );
242
+ $source[ 'klarna' ][ 'payment_method_categories' ] = implode ( $klarna_categories, ',' );
243
  return '#local_payment=klarna&redirect=' . $this->get_local_payment_return_url ( $order ) . '&encoded_source=' . base64_encode ( wp_json_encode ( $source ) );
244
  }
245
 
258
  'pay_over_time' => __ ( 'Pay Over Time', 'woo-stripe-payment' )
259
  ] );
260
  }
261
+
262
+ /**
263
+ *
264
+ * {@inheritDoc}
265
+ *
266
+ * @see WC_Payment_Gateway_Stripe_Local_Payment::get_payment_description()
267
+ */
268
+ public function get_payment_description() {
269
+ return '<p>' . sprintf ( __ ( 'Click %shere%s for Klarna test payment methods.', 'woo-stripe-payment' ), '<a target="_blank" href="https://stripe.com/docs/sources/klarna#testing-klarna-payments">', '</a>' ) . '</p>' . parent::get_payment_description ();
270
+ }
271
+
272
+ public function get_localized_params() {
273
+ $params = parent::get_localized_params ();
274
+ $params[ 'messages' ][ 'klarna_error' ] = __ ( 'Your purchase is not approved.', 'woo-stripe-payment' );
275
+ return $params;
276
+ }
277
  }
includes/gateways/class-wc-payment-gateway-stripe-multibanco.php CHANGED
@@ -27,7 +27,7 @@ class WC_Payment_Gateway_Stripe_Multibanco extends WC_Payment_Gateway_Stripe_Loc
27
  $this->method_title = __ ( 'EPS', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'Multibanco gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/multibanco.svg' );
30
- $this->order_button_text = __ ( 'Multibanco', 'woo-stripe-payment' );
31
  parent::__construct ();
32
  }
33
  }
27
  $this->method_title = __ ( 'EPS', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'Multibanco gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/multibanco.svg' );
30
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'Multibanco', 'woo-stripe-payment' ) );
31
  parent::__construct ();
32
  }
33
  }
includes/gateways/class-wc-payment-gateway-stripe-p24.php CHANGED
@@ -27,7 +27,7 @@ class WC_Payment_Gateway_Stripe_P24 extends WC_Payment_Gateway_Stripe_Local_Paym
27
  $this->method_title = __ ( 'Przelewy24', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'P24 gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/p24.svg' );
30
- $this->order_button_text = __ ( 'P24', 'woo-stripe-payment' );
31
  parent::__construct ();
32
  }
33
  }
27
  $this->method_title = __ ( 'Przelewy24', 'woo-stripe-payment' );
28
  $this->method_description = __ ( 'P24 gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
29
  $this->icon = wc_stripe ()->assets_url ( 'img/p24.svg' );
30
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'P24', 'woo-stripe-payment' ) );
31
  parent::__construct ();
32
  }
33
  }
includes/gateways/class-wc-payment-gateway-stripe-sepa.php CHANGED
@@ -26,7 +26,7 @@ class WC_Payment_Gateway_Stripe_Sepa extends WC_Payment_Gateway_Stripe_Local_Pay
26
  $this->method_title = __ ( 'Sepa', 'woo-stripe-payment' );
27
  $this->method_description = __ ( 'Sepa gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
28
  $this->icon = wc_stripe ()->assets_url ( 'img/sepa.svg' );
29
- $this->order_button_text = __ ( 'SEPA', 'woo-stripe-payment' );
30
  parent::__construct ();
31
 
32
  $this->local_payment_description = sprintf ( __ ( 'By providing your IBAN and confirming this payment, you are
26
  $this->method_title = __ ( 'Sepa', 'woo-stripe-payment' );
27
  $this->method_description = __ ( 'Sepa gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
28
  $this->icon = wc_stripe ()->assets_url ( 'img/sepa.svg' );
29
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'SEPA', 'woo-stripe-payment' ) );
30
  parent::__construct ();
31
 
32
  $this->local_payment_description = sprintf ( __ ( 'By providing your IBAN and confirming this payment, you are
includes/gateways/class-wc-payment-gateway-stripe-sofort.php CHANGED
@@ -29,7 +29,7 @@ class WC_Payment_Gateway_Stripe_Sofort extends WC_Payment_Gateway_Stripe_Local_P
29
  $this->method_title = __ ( 'Sofort', 'woo-stripe-payment' );
30
  $this->method_description = __ ( 'Sofort gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
31
  $this->icon = wc_stripe ()->assets_url ( 'img/sofort.svg' );
32
- $this->order_button_text = __ ( 'SOFORT', 'woo-stripe-payment' );
33
  parent::__construct ();
34
  }
35
 
29
  $this->method_title = __ ( 'Sofort', 'woo-stripe-payment' );
30
  $this->method_description = __ ( 'Sofort gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
31
  $this->icon = wc_stripe ()->assets_url ( 'img/sofort.svg' );
32
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'SOFORT', 'woo-stripe-payment' ) );
33
  parent::__construct ();
34
  }
35
 
includes/gateways/class-wc-payment-gateway-stripe-wechat.php CHANGED
@@ -28,7 +28,7 @@ class WC_Payment_Gateway_Stripe_WeChat extends WC_Payment_Gateway_Stripe_Local_P
28
  $this->method_title = __ ( 'WeChat', 'woo-stripe-payment' );
29
  $this->method_description = __ ( 'WeChat gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
30
  $this->icon = wc_stripe ()->assets_url ( 'img/wechat.svg' );
31
- $this->order_button_text = __ ( 'WeChat', 'woo-stripe-payment' );
32
  parent::__construct ();
33
  }
34
 
28
  $this->method_title = __ ( 'WeChat', 'woo-stripe-payment' );
29
  $this->method_description = __ ( 'WeChat gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
30
  $this->icon = wc_stripe ()->assets_url ( 'img/wechat.svg' );
31
+ $this->order_button_text = $this->get_order_button_text ( __ ( 'WeChat', 'woo-stripe-payment' ) );
32
  parent::__construct ();
33
  }
34
 
includes/wc-stripe-functions.php CHANGED
@@ -1141,4 +1141,18 @@ function wc_stripe_get_currencies() {
1141
  'PYG' => 0, 'RWF' => 0, 'UGX' => 0, 'VND' => 0,
1142
  'VUV' => 0, 'XAF' => 0, 'XOF' => 0, 'XPF' => 0
1143
  ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1144
  }
1141
  'PYG' => 0, 'RWF' => 0, 'UGX' => 0, 'VND' => 0,
1142
  'VUV' => 0, 'XAF' => 0, 'XOF' => 0, 'XPF' => 0
1143
  ] );
1144
+ }
1145
+
1146
+ /**
1147
+ * Function that triggers a filter on the order id.
1148
+ * Allows 3rd parties to
1149
+ * convert the order_id from the metadata of the Stripe object.
1150
+ *
1151
+ * @since 3.1.3
1152
+ * @package Stripe/Functions
1153
+ * @param int $order_id
1154
+ * @param \Stripe\ApiResource $object
1155
+ */
1156
+ function wc_stripe_filter_order_id($order_id, $object) {
1157
+ return apply_filters ( 'wc_stripe_filter_order_id', $order_id, $object );
1158
  }
includes/wc-stripe-webhook-functions.php CHANGED
@@ -11,7 +11,7 @@ defined ( 'ABSPATH' ) || exit ();
11
  * @param WP_REST_Request $request
12
  */
13
  function wc_stripe_process_source_chargeable($source, $request) {
14
- $order = wc_get_order ( $source->metadata[ 'order_id' ] );
15
  if (! $order) {
16
  wc_stripe_log_error ( sprintf ( 'Could not create a charge for source %s. No order ID was found in your Wordpress database.', $source->id ) );
17
  return;
11
  * @param WP_REST_Request $request
12
  */
13
  function wc_stripe_process_source_chargeable($source, $request) {
14
+ $order = wc_get_order ( wc_stripe_filter_order_id ( $source->metadata[ 'order_id' ], $source ) );
15
  if (! $order) {
16
  wc_stripe_log_error ( sprintf ( 'Could not create a charge for source %s. No order ID was found in your Wordpress database.', $source->id ) );
17
  return;
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.4
6
  Requires PHP: 5.4
7
- Stable tag: 3.1.2
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -57,6 +57,12 @@ If you're site is not loading over https, then Stripe won't render the Payment R
57
  8. Edit payment gateways on the product page
58
 
59
  == Changelog ==
 
 
 
 
 
 
60
  = 3.1.2 =
61
  * Added - Merchants can now control which payment buttons appear for each product and their positioning
62
  * Added - VAT tax display for Apple Pay, GPay, Payment Request
4
  Requires at least: 3.0.1
5
  Tested up to: 5.4
6
  Requires PHP: 5.4
7
+ Stable tag: 3.1.3
8
  Copyright: Payment Plugins
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
57
  8. Edit payment gateways on the product page
58
 
59
  == Changelog ==
60
+ = 3.1.3 =
61
+ * Added - WC 4.1.1 support
62
+ * Added - Klarna payment categories option
63
+ * Added - Order ID filter added
64
+ * Added - Local payment button filter so text on buttons can be changed
65
+ * Update - Webhook controller returns 401 for failed signature
66
  = 3.1.2 =
67
  * Added - Merchants can now control which payment buttons appear for each product and their positioning
68
  * Added - VAT tax display for Apple Pay, GPay, Payment Request
stripe-payments.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: Stripe For WooCommerce
4
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
5
  * Description: Accept credit cards, Google Pay, & Apple Pay, ACH, Klarna and more using Stripe.
6
- * Version: 3.1.2
7
  * Author: Payment Plugins, support@paymentplugins.com
8
  * Text Domain: woo-stripe-payment
9
  * Domain Path: /i18n/languages/
10
  * Tested up to: 5.4
11
  * WC requires at least: 3.0.0
12
- * WC tested up to: 4.1.0
13
  */
14
  defined ( 'ABSPATH' ) || exit ();
15
 
3
  * Plugin Name: Stripe For WooCommerce
4
  * Plugin URI: https://docs.paymentplugins.com/wc-stripe/config/
5
  * Description: Accept credit cards, Google Pay, & Apple Pay, ACH, Klarna and more using Stripe.
6
+ * Version: 3.1.3
7
  * Author: Payment Plugins, support@paymentplugins.com
8
  * Text Domain: woo-stripe-payment
9
  * Domain Path: /i18n/languages/
10
  * Tested up to: 5.4
11
  * WC requires at least: 3.0.0
12
+ * WC tested up to: 4.1.1
13
  */
14
  defined ( 'ABSPATH' ) || exit ();
15
 
templates/checkout/klarna.php CHANGED
@@ -4,17 +4,20 @@
4
  *
5
  * @var WC_Payment_Gateway_Stripe_Klarna $gateway
6
  */
 
7
  ?>
8
  <div id="wc_stripe_local_payment_<?php echo $gateway->id?>" style="display: none">
9
  <ul class="stripe-klarna-categories">
10
  <?php foreach ($gateway->get_payment_categories() as $category => $label):?>
11
- <li id="klarna-category-<?php echo $category?>" style="display:none">
12
- <input type="radio" id="klarna_<?php echo $category?>"
13
- class="wc-stripe-klarna-category" name="klarna_category"
14
- value="<?php echo $category?>" />
15
- <label for="klarna_<?php echo $category?>" class="wc-stripe-label-klarna-category"><?php echo $label?></label>
16
- <div id="klarna-instance-<?php echo $category?>" class="klarna-instance-<?php echo $category?>" style="display: none"></div>
17
- </li>
 
 
18
  <?php endforeach;?>
19
  </ul>
20
  </div>
4
  *
5
  * @var WC_Payment_Gateway_Stripe_Klarna $gateway
6
  */
7
+ $payment_options = $gateway->get_option('payment_categories');
8
  ?>
9
  <div id="wc_stripe_local_payment_<?php echo $gateway->id?>" style="display: none">
10
  <ul class="stripe-klarna-categories">
11
  <?php foreach ($gateway->get_payment_categories() as $category => $label):?>
12
+ <?php if(in_array($category, $payment_options)):?>
13
+ <li id="klarna-category-<?php echo $category?>" style="display:none">
14
+ <input type="radio" id="klarna_<?php echo $category?>"
15
+ class="wc-stripe-klarna-category" name="klarna_category"
16
+ value="<?php echo $category?>" />
17
+ <label for="klarna_<?php echo $category?>" class="wc-stripe-label-klarna-category"><?php echo $label?></label>
18
+ <div id="klarna-instance-<?php echo $category?>" class="klarna-instance-<?php echo $category?>" style="display: none"></div>
19
+ </li>
20
+ <?php endif;?>
21
  <?php endforeach;?>
22
  </ul>
23
  </div>