WooCommerce Square - Version 2.5.1

Version Description

  • 2021.05.18 =
  • Fix - Pay for Order and Add Payment Method forms sometimes not working when choosing another payment method other than Square. PR#618
Download this release

Release Info

Developer automattic
Plugin Icon 128x128 WooCommerce Square
Version 2.5.1
Comparing to
See all releases

Code changes from version 2.5.0 to 2.5.1

assets/js/frontend/wc-square.js CHANGED
@@ -137,9 +137,15 @@ jQuery( document ).ready( ( $ ) => {
137
  // handle saved payment methods.
138
  this.handle_saved_payment_methods();
139
 
 
 
140
  // validate payment data before order is submitted.
141
  // but only when one of our payment gateways is selected.
142
- this.form.on( 'submit', () => ( $( '#order_review input[name=payment_method]:checked' ).val() === this.id ) && this.validate_payment_data() );
 
 
 
 
143
  }
144
 
145
  /**
@@ -148,9 +154,15 @@ jQuery( document ).ready( ( $ ) => {
148
  handle_add_payment_method_page() {
149
  this.set_payment_fields();
150
 
 
 
151
  // validate payment data before order is submitted.
152
  // but only when one of our payment gateways is selected.
153
- this.form.on( 'submit', () => ( $( '#add_payment_method input[name=payment_method]:checked' ).val() === this.id ) && this.validate_payment_data() );
 
 
 
 
154
  }
155
 
156
  /**
137
  // handle saved payment methods.
138
  this.handle_saved_payment_methods();
139
 
140
+ const self = this;
141
+
142
  // validate payment data before order is submitted.
143
  // but only when one of our payment gateways is selected.
144
+ this.form.on( 'submit', function() {
145
+ if ( $( '#order_review input[name=payment_method]:checked' ).val() === self.id ) {
146
+ return self.validate_payment_data();
147
+ }
148
+ } );
149
  }
150
 
151
  /**
154
  handle_add_payment_method_page() {
155
  this.set_payment_fields();
156
 
157
+ const self = this;
158
+
159
  // validate payment data before order is submitted.
160
  // but only when one of our payment gateways is selected.
161
+ this.form.on( 'submit', function() {
162
+ if ( $( '#add_payment_method input[name=payment_method]:checked' ).val() === self.id ) {
163
+ return self.validate_payment_data();
164
+ }
165
+ } );
166
  }
167
 
168
  /**
assets/js/frontend/wc-square.min.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&Symbol.iterator in Object(iter))return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i]}return arr2}function _iterableToArrayLimit(arr,i){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(arr)))return;var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}jQuery(document).ready(function($){var WC_Square_Payment_Form_Handler=function(){function WC_Square_Payment_Form_Handler(args){var _this=this;_classCallCheck(this,WC_Square_Payment_Form_Handler);this.id=args.id;this.id_dasherized=args.id_dasherized;this.csc_required=args.csc_required;this.enabled_card_types=args.enabled_card_types;this.square_card_types=args.square_card_types;this.ajax_log_nonce=args.ajax_log_nonce;this.ajax_url=args.ajax_url;this.application_id=args.application_id;this.currency_code=args.currency_code;this.general_error=args.general_error;this.input_styles=args.input_styles;this.is_3ds_enabled=args.is_3d_secure_enabled;this.is_add_payment_method_page=args.is_add_payment_method_page;this.is_checkout_registration_enabled=args.is_checkout_registration_enabled;this.is_user_logged_in=args.is_user_logged_in;this.location_id=args.location_id;this.logging_enabled=args.logging_enabled;this.ajax_wc_checkout_validate_nonce=args.ajax_wc_checkout_validate_nonce;this.is_manual_order_payment=args.is_manual_order_payment;if($("form.checkout").length){this.form=$("form.checkout");this.handle_checkout_page()}else if($("form#order_review").length){this.form=$("form#order_review");this.handle_pay_page()}else if($("form#add_payment_method").length){this.form=$("form#add_payment_method");this.handle_add_payment_method_page()}else{this.log("No payment form found!");return}this.params=window.sv_wc_payment_gateway_payment_form_params;$(document.body).on("checkout_error",function(){$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("")});$(document.body).on("click","#payment_method_".concat(this.id),function(){if(_this.payment_form){_this.log("Recalculating payment form size");_this.payment_form.recalculateSize()}})}_createClass(WC_Square_Payment_Form_Handler,[{key:"handle_checkout_page",value:function handle_checkout_page(){var _this2=this;$(document.body).on("updated_checkout",function(){return _this2.set_payment_fields()});$(document.body).on("updated_checkout",function(){return _this2.handle_saved_payment_methods()});this.form.on("checkout_place_order_".concat(this.id),function(){return _this2.validate_payment_data()})}},{key:"handle_saved_payment_methods",value:function handle_saved_payment_methods(){var id_dasherized=this.id_dasherized;var form_handler=this;var $new_payment_method_selection=$("div.js-wc-".concat(id_dasherized,"-new-payment-method-form"));$("input.js-wc-".concat(this.id_dasherized,"-payment-token")).on("change",function(){var tokenized_payment_method_selected=$("input.js-wc-".concat(id_dasherized,"-payment-token:checked")).val();if(tokenized_payment_method_selected){$new_payment_method_selection.slideUp(200)}else{$new_payment_method_selection.slideDown(200)}}).trigger("change");$("input#createaccount").on("change",function(e){if($(e.target).is(":checked")){form_handler.show_save_payment_checkbox(id_dasherized)}else{form_handler.hide_save_payment_checkbox(id_dasherized)}});if(!$("input#createaccount").is(":checked")){$("input#createaccount").trigger("change")}if(!this.is_user_logged_in&&!this.is_checkout_registration_enabled){this.hide_save_payment_checkbox(id_dasherized)}}},{key:"handle_pay_page",value:function handle_pay_page(){var _this3=this;this.set_payment_fields();this.handle_saved_payment_methods();this.form.on("submit",function(){return $("#order_review input[name=payment_method]:checked").val()===_this3.id&&_this3.validate_payment_data()})}},{key:"handle_add_payment_method_page",value:function handle_add_payment_method_page(){var _this4=this;this.set_payment_fields();this.form.on("submit",function(){return $("#add_payment_method input[name=payment_method]:checked").val()===_this4.id&&_this4.validate_payment_data()})}},{key:"set_payment_fields",value:function set_payment_fields(){if(!$("#wc-".concat(this.id_dasherized,"-account-number-hosted")).length){return}if($("#wc-".concat(this.id_dasherized,"-account-number-hosted")).is("iframe")){this.log("Re-adding payment form");for(var _i=0,_Object$entries=Object.entries(this.form_fields);_i<_Object$entries.length;_i++){var _Object$entries$_i=_slicedToArray(_Object$entries[_i],2),_=_Object$entries$_i[0],field=_Object$entries$_i[1];$(field.attr("id")).replaceWith(field)}this.handle_form_loaded()}else{if(this.payment_form){this.log("Destroying payment form");this.payment_form.destroy();this.payment_form=null}this.log("Building payment form");this.payment_form=new SqPaymentForm(this.get_form_params());this.payment_form.build()}}},{key:"get_form_params",value:function get_form_params(){var _this5=this;this.form_fields={card_number:$("#wc-".concat(this.id_dasherized,"-account-number-hosted")),expiration:$("#wc-".concat(this.id_dasherized,"-expiry-hosted")),csc:$("#wc-".concat(this.id_dasherized,"-csc-hosted")),postal_code:$("#wc-".concat(this.id_dasherized,"-postal-code-hosted"))};return{applicationId:this.application_id,locationId:this.location_id,cardNumber:{elementId:this.form_fields.card_number.attr("id"),placeholder:this.form_fields.card_number.data("placeholder")},expirationDate:{elementId:this.form_fields.expiration.attr("id"),placeholder:this.form_fields.expiration.data("placeholder")},cvv:{elementId:this.form_fields.csc.attr("id"),placeholder:this.form_fields.csc.data("placeholder")},postalCode:{elementId:this.form_fields.postal_code.attr("id"),placeholder:this.form_fields.postal_code.data("placeholder")},inputClass:"wc-".concat(this.id_dasherized,"-payment-field"),inputStyles:this.input_styles,callbacks:{inputEventReceived:function inputEventReceived(e){return _this5.handle_input_event(e)},cardNonceResponseReceived:function cardNonceResponseReceived(errors,nonce,cardData){return _this5.handle_card_nonce_response(errors,nonce,cardData)},unsupportedBrowserDetected:function unsupportedBrowserDetected(){return _this5.handle_unsupported_browser()},paymentFormLoaded:function paymentFormLoaded(){return _this5.handle_form_loaded()}}}}},{key:"handle_form_loaded",value:function handle_form_loaded(){this.log("Payment form loaded");this.payment_form.setPostalCode($("#billing_postcode").val());if($("form.checkout").length||$("#billing_postcode").val()){$(".wc-square-credit-card-card-postal-code-parent").addClass("hidden")}}},{key:"handle_input_event",value:function handle_input_event(e){var $input=$("#"+e.elementId);if(e.eventType==="cardBrandChanged"){this.handle_card_brand_change(e.cardBrand,$input)}}},{key:"handle_card_brand_change",value:function handle_card_brand_change(brand,$input){this.log("Card brand changed to ".concat(brand));$input.attr("class",function(i,c){return c.replace(/(^|\s)card-type-\S+/g,"")});var card_class="plain";if(null===brand||"unknown"===brand){brand=""}if(null!==this.square_card_types[brand]){brand=this.square_card_types[brand]}if(brand&&!this.enabled_card_types.includes(brand)){card_class="invalid"}else{card_class=brand}$("input[name=wc-".concat(this.id_dasherized,"-card-type]")).val(brand);$input.addClass("card-type-".concat(card_class))}},{key:"validate_payment_data",value:function validate_payment_data(){if(this.form.is(".processing")){return false}if(this.has_nonce()){this.log("Payment nonce present, placing order");return true}var tokenized_card_id=this.get_tokenized_payment_method_id();if(tokenized_card_id){if(!this.is_3ds_enabled){return true}if(this.has_verification_token()){this.log("Tokenized payment verification token present, placing order");return true}this.log("Requesting verification token for tokenized payment");this.block_ui();this.payment_form.verifyBuyer(tokenized_card_id,this.get_verification_details(),this.handle_verify_buyer_response.bind(this));return false}this.log("Requesting payment nonce");this.block_ui();this.payment_form.requestCardNonce();return false}},{key:"get_tokenized_payment_method_id",value:function get_tokenized_payment_method_id(){return $(".payment_method_".concat(this.id)).find(".js-wc-square-credit-card-payment-token:checked").val()}},{key:"handle_card_nonce_response",value:function handle_card_nonce_response(errors,nonce,cardData){if(errors){return this.handle_errors(errors)}if(!nonce){var message="Nonce is missing from the Square response";this.log(message,"error");this.log_data(message,"response");return this.handle_errors()}this.log("Card data received");this.log(cardData);this.log_data(cardData,"response");if(cardData.last_4){$("input[name=wc-".concat(this.id_dasherized,"-last-four]")).val(cardData.last_4)}if(cardData.exp_month){$("input[name=wc-".concat(this.id_dasherized,"-exp-month]")).val(cardData.exp_month)}if(cardData.exp_year){$("input[name=wc-".concat(this.id_dasherized,"-exp-year]")).val(cardData.exp_year)}if(cardData.billing_postal_code){$("input[name=wc-".concat(this.id_dasherized,"-payment-postcode]")).val(cardData.billing_postal_code)}$("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val(nonce);if(this.is_3ds_enabled){this.log("Verifying buyer");this.payment_form.verifyBuyer(nonce,this.get_verification_details(),this.handle_verify_buyer_response.bind(this));return}this.form.trigger("submit")}},{key:"handle_verify_buyer_response",value:function handle_verify_buyer_response(errors,verification_result){if(errors){$(errors).each(function(index,error){if(!error.field){error.field="none"}});return this.handle_errors(errors)}if(!verification_result||!verification_result.token){var message="Verification token is missing from the Square response";this.log(message,"error");this.log_data(message,"response");return this.handle_errors()}this.log("Verification result received");this.log(verification_result);$("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val(verification_result.token);this.form.trigger("submit")}},{key:"get_verification_details",value:function get_verification_details(){var verification_details={billingContact:{familyName:$("#billing_last_name").val()||"",givenName:$("#billing_first_name").val()||"",email:$("#billing_email").val()||"",country:$("#billing_country").val()||"",region:$("#billing_state").val()||"",city:$("#billing_city").val()||"",postalCode:$("#billing_postcode").val()||"",phone:$("#billing_phone").val()||"",addressLines:[$("#billing_address_1").val()||"",$("#billing_address_2").val()||""]},intent:this.get_intent()};if("CHARGE"===verification_details.intent){verification_details.amount=this.get_amount();verification_details.currencyCode=this.currency_code}this.log(verification_details);return verification_details}},{key:"get_intent",value:function get_intent(){var $save_method_input=$("#wc-square-credit-card-tokenize-payment-method");var save_payment_method;if($save_method_input.is("input:checkbox")){save_payment_method=$save_method_input.is(":checked")}else{save_payment_method="true"===$save_method_input.val()}if(!this.get_tokenized_payment_method_id()&&save_payment_method){return"STORE"}return"CHARGE"}},{key:"get_amount",value:function get_amount(){return $("input[name=wc-".concat(this.id_dasherized,"-amount]")).val()}},{key:"handle_unsupported_browser",value:function handle_unsupported_browser(){}},{key:"handle_errors",value:function handle_errors(){var _this6=this;var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;this.log("Error getting payment data","error");$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("");var messages=[];if(errors){var field_order=["none","cardNumber","expirationDate","cvv","postalCode"];if(errors.length>=1){errors.sort(function(a,b){return field_order.indexOf(a.field)-field_order.indexOf(b.field)})}$(errors).each(function(index,error){if("UNSUPPORTED_CARD_BRAND"===error.type||"VALIDATION_ERROR"===error.type){return messages.push(error.message.replace(/CVV/,"CSC"))}return _this6.log_data(errors,"response")})}if(messages.length===0){messages.push(this.general_error)}if(!this.is_add_payment_method_page&&!this.is_manual_order_payment){this.render_checkout_errors(messages)}else{this.render_errors(messages)}this.unblock_ui()}},{key:"render_errors",value:function render_errors(errors){$(".woocommerce-error, .woocommerce-message").remove();this.form.prepend("<ul class=\"woocommerce-error\"><li>"+errors.join("</li><li>")+"</li></ul>");this.form.removeClass("processing").unblock();this.form.find(".input-text, select").trigger("blur");$("html, body").animate({scrollTop:this.form.offset().top-100},1000)}},{key:"block_ui",value:function block_ui(){this.form.block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}},{key:"unblock_ui",value:function unblock_ui(){return this.form.unblock()}},{key:"hide_save_payment_checkbox",value:function hide_save_payment_checkbox(id_dasherized){var $parent_row=$("input.js-wc-".concat(id_dasherized,"-tokenize-payment-method")).closest("p.form-row");$parent_row.hide();$parent_row.next().hide()}},{key:"show_save_payment_checkbox",value:function show_save_payment_checkbox(id_dasherized){var $parent_row=$("input.js-wc-".concat(id_dasherized,"-tokenize-payment-method")).closest("p.form-row");$parent_row.slideDown();$parent_row.next().show()}},{key:"has_nonce",value:function has_nonce(){return $("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val()}},{key:"has_verification_token",value:function has_verification_token(){return $("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val()}},{key:"log_data",value:function log_data(data,type){if(!this.logging_enabled){return}var ajax_data={action:"wc_"+this.id+"_log_js_data",security:this.ajax_log_nonce,type:type,data:data};$.ajax({url:this.ajax_url,data:ajax_data})}},{key:"log",value:function log(message){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"notice";if(!this.logging_enabled){return}if("error"===type){console.error("Square Error: "+message)}else{console.log("Square: "+message)}}},{key:"render_checkout_errors",value:function render_checkout_errors(square_errors){var _this7=this;var ajax_url=wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%",this.id+"_checkout_handler");var square_handler=this;var form_data=this.form.serializeArray();form_data.push({name:"wc_"+this.id+"_checkout_validate_nonce",value:this.ajax_wc_checkout_validate_nonce});return $.ajax({url:ajax_url,method:"post",cache:false,data:form_data,complete:function complete(response){var result=response.responseJSON;if(result.hasOwnProperty("result")&&"failure"===result.result){$(result.messages).map(function(message){var errors=[];$(message).children("li").each(function(){errors.push($(_this7).text().trim())});return square_errors.unshift.apply(square_errors,errors)})}else if(result.hasOwnProperty("success")&&!result.success){square_errors.unshift.apply(square_errors,_toConsumableArray(result.data.messages))}square_handler.render_errors(square_errors)}})}}]);return WC_Square_Payment_Form_Handler}();window.WC_Square_Payment_Form_Handler=WC_Square_Payment_Form_Handler});
2
  //# sourceMappingURL=wc-square.min.js.map
1
+ "use strict";function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&Symbol.iterator in Object(iter))return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i]}return arr2}function _iterableToArrayLimit(arr,i){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(arr)))return;var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}jQuery(document).ready(function($){var WC_Square_Payment_Form_Handler=function(){function WC_Square_Payment_Form_Handler(args){var _this=this;_classCallCheck(this,WC_Square_Payment_Form_Handler);this.id=args.id;this.id_dasherized=args.id_dasherized;this.csc_required=args.csc_required;this.enabled_card_types=args.enabled_card_types;this.square_card_types=args.square_card_types;this.ajax_log_nonce=args.ajax_log_nonce;this.ajax_url=args.ajax_url;this.application_id=args.application_id;this.currency_code=args.currency_code;this.general_error=args.general_error;this.input_styles=args.input_styles;this.is_3ds_enabled=args.is_3d_secure_enabled;this.is_add_payment_method_page=args.is_add_payment_method_page;this.is_checkout_registration_enabled=args.is_checkout_registration_enabled;this.is_user_logged_in=args.is_user_logged_in;this.location_id=args.location_id;this.logging_enabled=args.logging_enabled;this.ajax_wc_checkout_validate_nonce=args.ajax_wc_checkout_validate_nonce;this.is_manual_order_payment=args.is_manual_order_payment;if($("form.checkout").length){this.form=$("form.checkout");this.handle_checkout_page()}else if($("form#order_review").length){this.form=$("form#order_review");this.handle_pay_page()}else if($("form#add_payment_method").length){this.form=$("form#add_payment_method");this.handle_add_payment_method_page()}else{this.log("No payment form found!");return}this.params=window.sv_wc_payment_gateway_payment_form_params;$(document.body).on("checkout_error",function(){$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("")});$(document.body).on("click","#payment_method_".concat(this.id),function(){if(_this.payment_form){_this.log("Recalculating payment form size");_this.payment_form.recalculateSize()}})}_createClass(WC_Square_Payment_Form_Handler,[{key:"handle_checkout_page",value:function handle_checkout_page(){var _this2=this;$(document.body).on("updated_checkout",function(){return _this2.set_payment_fields()});$(document.body).on("updated_checkout",function(){return _this2.handle_saved_payment_methods()});this.form.on("checkout_place_order_".concat(this.id),function(){return _this2.validate_payment_data()})}},{key:"handle_saved_payment_methods",value:function handle_saved_payment_methods(){var id_dasherized=this.id_dasherized;var form_handler=this;var $new_payment_method_selection=$("div.js-wc-".concat(id_dasherized,"-new-payment-method-form"));$("input.js-wc-".concat(this.id_dasherized,"-payment-token")).on("change",function(){var tokenized_payment_method_selected=$("input.js-wc-".concat(id_dasherized,"-payment-token:checked")).val();if(tokenized_payment_method_selected){$new_payment_method_selection.slideUp(200)}else{$new_payment_method_selection.slideDown(200)}}).trigger("change");$("input#createaccount").on("change",function(e){if($(e.target).is(":checked")){form_handler.show_save_payment_checkbox(id_dasherized)}else{form_handler.hide_save_payment_checkbox(id_dasherized)}});if(!$("input#createaccount").is(":checked")){$("input#createaccount").trigger("change")}if(!this.is_user_logged_in&&!this.is_checkout_registration_enabled){this.hide_save_payment_checkbox(id_dasherized)}}},{key:"handle_pay_page",value:function handle_pay_page(){this.set_payment_fields();this.handle_saved_payment_methods();var self=this;this.form.on("submit",function(){if($("#order_review input[name=payment_method]:checked").val()===self.id){return self.validate_payment_data()}})}},{key:"handle_add_payment_method_page",value:function handle_add_payment_method_page(){this.set_payment_fields();var self=this;this.form.on("submit",function(){if($("#add_payment_method input[name=payment_method]:checked").val()===self.id){return self.validate_payment_data()}})}},{key:"set_payment_fields",value:function set_payment_fields(){if(!$("#wc-".concat(this.id_dasherized,"-account-number-hosted")).length){return}if($("#wc-".concat(this.id_dasherized,"-account-number-hosted")).is("iframe")){this.log("Re-adding payment form");for(var _i=0,_Object$entries=Object.entries(this.form_fields);_i<_Object$entries.length;_i++){var _Object$entries$_i=_slicedToArray(_Object$entries[_i],2),_=_Object$entries$_i[0],field=_Object$entries$_i[1];$(field.attr("id")).replaceWith(field)}this.handle_form_loaded()}else{if(this.payment_form){this.log("Destroying payment form");this.payment_form.destroy();this.payment_form=null}this.log("Building payment form");this.payment_form=new SqPaymentForm(this.get_form_params());this.payment_form.build()}}},{key:"get_form_params",value:function get_form_params(){var _this3=this;this.form_fields={card_number:$("#wc-".concat(this.id_dasherized,"-account-number-hosted")),expiration:$("#wc-".concat(this.id_dasherized,"-expiry-hosted")),csc:$("#wc-".concat(this.id_dasherized,"-csc-hosted")),postal_code:$("#wc-".concat(this.id_dasherized,"-postal-code-hosted"))};return{applicationId:this.application_id,locationId:this.location_id,cardNumber:{elementId:this.form_fields.card_number.attr("id"),placeholder:this.form_fields.card_number.data("placeholder")},expirationDate:{elementId:this.form_fields.expiration.attr("id"),placeholder:this.form_fields.expiration.data("placeholder")},cvv:{elementId:this.form_fields.csc.attr("id"),placeholder:this.form_fields.csc.data("placeholder")},postalCode:{elementId:this.form_fields.postal_code.attr("id"),placeholder:this.form_fields.postal_code.data("placeholder")},inputClass:"wc-".concat(this.id_dasherized,"-payment-field"),inputStyles:this.input_styles,callbacks:{inputEventReceived:function inputEventReceived(e){return _this3.handle_input_event(e)},cardNonceResponseReceived:function cardNonceResponseReceived(errors,nonce,cardData){return _this3.handle_card_nonce_response(errors,nonce,cardData)},unsupportedBrowserDetected:function unsupportedBrowserDetected(){return _this3.handle_unsupported_browser()},paymentFormLoaded:function paymentFormLoaded(){return _this3.handle_form_loaded()}}}}},{key:"handle_form_loaded",value:function handle_form_loaded(){this.log("Payment form loaded");this.payment_form.setPostalCode($("#billing_postcode").val());if($("form.checkout").length||$("#billing_postcode").val()){$(".wc-square-credit-card-card-postal-code-parent").addClass("hidden")}}},{key:"handle_input_event",value:function handle_input_event(e){var $input=$("#"+e.elementId);if(e.eventType==="cardBrandChanged"){this.handle_card_brand_change(e.cardBrand,$input)}}},{key:"handle_card_brand_change",value:function handle_card_brand_change(brand,$input){this.log("Card brand changed to ".concat(brand));$input.attr("class",function(i,c){return c.replace(/(^|\s)card-type-\S+/g,"")});var card_class="plain";if(null===brand||"unknown"===brand){brand=""}if(null!==this.square_card_types[brand]){brand=this.square_card_types[brand]}if(brand&&!this.enabled_card_types.includes(brand)){card_class="invalid"}else{card_class=brand}$("input[name=wc-".concat(this.id_dasherized,"-card-type]")).val(brand);$input.addClass("card-type-".concat(card_class))}},{key:"validate_payment_data",value:function validate_payment_data(){if(this.form.is(".processing")){return false}if(this.has_nonce()){this.log("Payment nonce present, placing order");return true}var tokenized_card_id=this.get_tokenized_payment_method_id();if(tokenized_card_id){if(!this.is_3ds_enabled){return true}if(this.has_verification_token()){this.log("Tokenized payment verification token present, placing order");return true}this.log("Requesting verification token for tokenized payment");this.block_ui();this.payment_form.verifyBuyer(tokenized_card_id,this.get_verification_details(),this.handle_verify_buyer_response.bind(this));return false}this.log("Requesting payment nonce");this.block_ui();this.payment_form.requestCardNonce();return false}},{key:"get_tokenized_payment_method_id",value:function get_tokenized_payment_method_id(){return $(".payment_method_".concat(this.id)).find(".js-wc-square-credit-card-payment-token:checked").val()}},{key:"handle_card_nonce_response",value:function handle_card_nonce_response(errors,nonce,cardData){if(errors){return this.handle_errors(errors)}if(!nonce){var message="Nonce is missing from the Square response";this.log(message,"error");this.log_data(message,"response");return this.handle_errors()}this.log("Card data received");this.log(cardData);this.log_data(cardData,"response");if(cardData.last_4){$("input[name=wc-".concat(this.id_dasherized,"-last-four]")).val(cardData.last_4)}if(cardData.exp_month){$("input[name=wc-".concat(this.id_dasherized,"-exp-month]")).val(cardData.exp_month)}if(cardData.exp_year){$("input[name=wc-".concat(this.id_dasherized,"-exp-year]")).val(cardData.exp_year)}if(cardData.billing_postal_code){$("input[name=wc-".concat(this.id_dasherized,"-payment-postcode]")).val(cardData.billing_postal_code)}$("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val(nonce);if(this.is_3ds_enabled){this.log("Verifying buyer");this.payment_form.verifyBuyer(nonce,this.get_verification_details(),this.handle_verify_buyer_response.bind(this));return}this.form.trigger("submit")}},{key:"handle_verify_buyer_response",value:function handle_verify_buyer_response(errors,verification_result){if(errors){$(errors).each(function(index,error){if(!error.field){error.field="none"}});return this.handle_errors(errors)}if(!verification_result||!verification_result.token){var message="Verification token is missing from the Square response";this.log(message,"error");this.log_data(message,"response");return this.handle_errors()}this.log("Verification result received");this.log(verification_result);$("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val(verification_result.token);this.form.trigger("submit")}},{key:"get_verification_details",value:function get_verification_details(){var verification_details={billingContact:{familyName:$("#billing_last_name").val()||"",givenName:$("#billing_first_name").val()||"",email:$("#billing_email").val()||"",country:$("#billing_country").val()||"",region:$("#billing_state").val()||"",city:$("#billing_city").val()||"",postalCode:$("#billing_postcode").val()||"",phone:$("#billing_phone").val()||"",addressLines:[$("#billing_address_1").val()||"",$("#billing_address_2").val()||""]},intent:this.get_intent()};if("CHARGE"===verification_details.intent){verification_details.amount=this.get_amount();verification_details.currencyCode=this.currency_code}this.log(verification_details);return verification_details}},{key:"get_intent",value:function get_intent(){var $save_method_input=$("#wc-square-credit-card-tokenize-payment-method");var save_payment_method;if($save_method_input.is("input:checkbox")){save_payment_method=$save_method_input.is(":checked")}else{save_payment_method="true"===$save_method_input.val()}if(!this.get_tokenized_payment_method_id()&&save_payment_method){return"STORE"}return"CHARGE"}},{key:"get_amount",value:function get_amount(){return $("input[name=wc-".concat(this.id_dasherized,"-amount]")).val()}},{key:"handle_unsupported_browser",value:function handle_unsupported_browser(){}},{key:"handle_errors",value:function handle_errors(){var _this4=this;var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;this.log("Error getting payment data","error");$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("");var messages=[];if(errors){var field_order=["none","cardNumber","expirationDate","cvv","postalCode"];if(errors.length>=1){errors.sort(function(a,b){return field_order.indexOf(a.field)-field_order.indexOf(b.field)})}$(errors).each(function(index,error){if("UNSUPPORTED_CARD_BRAND"===error.type||"VALIDATION_ERROR"===error.type){return messages.push(error.message.replace(/CVV/,"CSC"))}return _this4.log_data(errors,"response")})}if(messages.length===0){messages.push(this.general_error)}if(!this.is_add_payment_method_page&&!this.is_manual_order_payment){this.render_checkout_errors(messages)}else{this.render_errors(messages)}this.unblock_ui()}},{key:"render_errors",value:function render_errors(errors){$(".woocommerce-error, .woocommerce-message").remove();this.form.prepend("<ul class=\"woocommerce-error\"><li>"+errors.join("</li><li>")+"</li></ul>");this.form.removeClass("processing").unblock();this.form.find(".input-text, select").trigger("blur");$("html, body").animate({scrollTop:this.form.offset().top-100},1000)}},{key:"block_ui",value:function block_ui(){this.form.block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}},{key:"unblock_ui",value:function unblock_ui(){return this.form.unblock()}},{key:"hide_save_payment_checkbox",value:function hide_save_payment_checkbox(id_dasherized){var $parent_row=$("input.js-wc-".concat(id_dasherized,"-tokenize-payment-method")).closest("p.form-row");$parent_row.hide();$parent_row.next().hide()}},{key:"show_save_payment_checkbox",value:function show_save_payment_checkbox(id_dasherized){var $parent_row=$("input.js-wc-".concat(id_dasherized,"-tokenize-payment-method")).closest("p.form-row");$parent_row.slideDown();$parent_row.next().show()}},{key:"has_nonce",value:function has_nonce(){return $("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val()}},{key:"has_verification_token",value:function has_verification_token(){return $("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val()}},{key:"log_data",value:function log_data(data,type){if(!this.logging_enabled){return}var ajax_data={action:"wc_"+this.id+"_log_js_data",security:this.ajax_log_nonce,type:type,data:data};$.ajax({url:this.ajax_url,data:ajax_data})}},{key:"log",value:function log(message){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"notice";if(!this.logging_enabled){return}if("error"===type){console.error("Square Error: "+message)}else{console.log("Square: "+message)}}},{key:"render_checkout_errors",value:function render_checkout_errors(square_errors){var _this5=this;var ajax_url=wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%",this.id+"_checkout_handler");var square_handler=this;var form_data=this.form.serializeArray();form_data.push({name:"wc_"+this.id+"_checkout_validate_nonce",value:this.ajax_wc_checkout_validate_nonce});return $.ajax({url:ajax_url,method:"post",cache:false,data:form_data,complete:function complete(response){var result=response.responseJSON;if(result.hasOwnProperty("result")&&"failure"===result.result){$(result.messages).map(function(message){var errors=[];$(message).children("li").each(function(){errors.push($(_this5).text().trim())});return square_errors.unshift.apply(square_errors,errors)})}else if(result.hasOwnProperty("success")&&!result.success){square_errors.unshift.apply(square_errors,_toConsumableArray(result.data.messages))}square_handler.render_errors(square_errors)}})}}]);return WC_Square_Payment_Form_Handler}();window.WC_Square_Payment_Form_Handler=WC_Square_Payment_Form_Handler});
2
  //# sourceMappingURL=wc-square.min.js.map
assets/js/frontend/wc-square.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["wc-square.js"],"names":["jQuery","document","ready","$","WC_Square_Payment_Form_Handler","args","id","id_dasherized","csc_required","enabled_card_types","square_card_types","ajax_log_nonce","ajax_url","application_id","currency_code","general_error","input_styles","is_3ds_enabled","is_3d_secure_enabled","is_add_payment_method_page","is_checkout_registration_enabled","is_user_logged_in","location_id","logging_enabled","ajax_wc_checkout_validate_nonce","is_manual_order_payment","length","form","handle_checkout_page","handle_pay_page","handle_add_payment_method_page","log","params","window","sv_wc_payment_gateway_payment_form_params","body","on","val","payment_form","recalculateSize","set_payment_fields","handle_saved_payment_methods","validate_payment_data","form_handler","$new_payment_method_selection","tokenized_payment_method_selected","slideUp","slideDown","trigger","e","target","is","show_save_payment_checkbox","hide_save_payment_checkbox","Object","entries","form_fields","_","field","attr","replaceWith","handle_form_loaded","destroy","SqPaymentForm","get_form_params","build","card_number","expiration","csc","postal_code","applicationId","locationId","cardNumber","elementId","placeholder","data","expirationDate","cvv","postalCode","inputClass","inputStyles","callbacks","inputEventReceived","handle_input_event","cardNonceResponseReceived","errors","nonce","cardData","handle_card_nonce_response","unsupportedBrowserDetected","handle_unsupported_browser","paymentFormLoaded","setPostalCode","addClass","$input","eventType","handle_card_brand_change","cardBrand","brand","i","c","replace","card_class","includes","has_nonce","tokenized_card_id","get_tokenized_payment_method_id","has_verification_token","block_ui","verifyBuyer","get_verification_details","handle_verify_buyer_response","bind","requestCardNonce","find","handle_errors","message","log_data","last_4","exp_month","exp_year","billing_postal_code","verification_result","each","index","error","token","verification_details","billingContact","familyName","givenName","email","country","region","city","phone","addressLines","intent","get_intent","amount","get_amount","currencyCode","$save_method_input","save_payment_method","messages","field_order","sort","a","b","indexOf","type","push","render_checkout_errors","render_errors","unblock_ui","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","$parent_row","closest","hide","next","show","ajax_data","action","security","ajax","url","console","square_errors","wc_cart_fragments_params","wc_ajax_url","toString","square_handler","form_data","serializeArray","name","value","method","cache","complete","response","result","responseJSON","hasOwnProperty","map","children","text","trim","unshift","success"],"mappings":"q8EAOAA,MAAM,CAAEC,QAAF,CAAN,CAAmBC,KAAnB,CAA0B,SAAEC,CAAF,CAAS,IAM5BC,CAAAA,8BAN4B,YAcjC,wCAAaC,IAAb,CAAoB,qEACnB,KAAKC,EAAL,CAAUD,IAAI,CAACC,EAAf,CACA,KAAKC,aAAL,CAAqBF,IAAI,CAACE,aAA1B,CACA,KAAKC,YAAL,CAAoBH,IAAI,CAACG,YAAzB,CACA,KAAKC,kBAAL,CAA0BJ,IAAI,CAACI,kBAA/B,CACA,KAAKC,iBAAL,CAAyBL,IAAI,CAACK,iBAA9B,CACA,KAAKC,cAAL,CAAsBN,IAAI,CAACM,cAA3B,CACA,KAAKC,QAAL,CAAgBP,IAAI,CAACO,QAArB,CACA,KAAKC,cAAL,CAAsBR,IAAI,CAACQ,cAA3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K,IAAF,CAAQ,CACdC,GAAG,CAAErK,QADS,CAEdgL,MAAM,CAAE,MAFM,CAGdC,KAAK,CAAE,KAHO,CAIdlH,IAAI,CAAE6G,SAJQ,CAKdM,QAAQ,CAAE,kBAAEC,QAAF,CAAgB,CACzB,GAAMC,CAAAA,MAAM,CAAGD,QAAQ,CAACE,YAAxB,CAIA,GAAKD,MAAM,CAACE,cAAP,CAAuB,QAAvB,GAAqC,YAAcF,MAAM,CAACA,MAA/D,CAAwE,CACvE7L,CAAC,CAAE6L,MAAM,CAAChD,QAAT,CAAD,CAAqBmD,GAArB,CAA0B,SAAE/E,OAAF,CAAe,CACxC,GAAM/B,CAAAA,MAAM,CAAG,EAAf,CAEAlF,CAAC,CAAEiH,OAAF,CAAD,CAAagF,QAAb,CAAuB,IAAvB,EAA8BzE,IAA9B,CAAoC,UAAM,CACzCtC,MAAM,CAACkE,IAAP,CAAapJ,CAAC,CAAE,MAAF,CAAD,CAAUkM,IAAV,GAAiBC,IAAjB,EAAb,CACA,CAFD,EAIA,MAAOnB,CAAAA,aAAa,CAACoB,OAAd,OAAApB,aAAa,CAAa9F,MAAb,CACpB,CARD,CAWA,CAZD,IAYO,IAAK2G,MAAM,CAACE,cAAP,CAAuB,SAAvB,GAAsC,CAAEF,MAAM,CAACQ,OAApD,CAA8D,CACpErB,aAAa,CAACoB,OAAd,OAAApB,aAAa,oBAAaa,MAAM,CAACrH,IAAP,CAAYqE,QAAzB,EACb,CAEDuC,cAAc,CAAC9B,aAAf,CAA8B0B,aAA9B,CACA,CA3Ba,CAAR,CA6BP,CArwBgC,6CAwwBlClJ,MAAM,CAAC7B,8BAAP,CAAwCA,8BACxC,CAzwBD","sourcesContent":["/* global wc_cart_fragments_params */\n\n/**\n * WooCommerce Square Payment Form handler.\n *\n * @since 2.0.0\n */\njQuery( document ).ready( ( $ ) => {\n\t/**\n\t * Square Credit Card Payment Form Handler class.\n\t *\n\t * @since 2.0.0\n\t */\n\tclass WC_Square_Payment_Form_Handler {\n\t\t/**\n\t\t * Setup handler.\n\t\t *\n\t\t * @since 2.3.2-1\n\t\t *\n\t\t * @param {Object} args\n\t\t */\n\t\tconstructor( args ) {\n\t\t\tthis.id = args.id;\n\t\t\tthis.id_dasherized = args.id_dasherized;\n\t\t\tthis.csc_required = args.csc_required;\n\t\t\tthis.enabled_card_types = args.enabled_card_types;\n\t\t\tthis.square_card_types = args.square_card_types;\n\t\t\tthis.ajax_log_nonce = args.ajax_log_nonce;\n\t\t\tthis.ajax_url = args.ajax_url;\n\t\t\tthis.application_id = args.application_id;\n\t\t\tthis.currency_code = args.currency_code;\n\t\t\tthis.general_error = args.general_error;\n\t\t\tthis.input_styles = args.input_styles;\n\t\t\tthis.is_3ds_enabled = args.is_3d_secure_enabled;\n\t\t\tthis.is_add_payment_method_page = args.is_add_payment_method_page;\n\t\t\tthis.is_checkout_registration_enabled = args.is_checkout_registration_enabled;\n\t\t\tthis.is_user_logged_in = args.is_user_logged_in;\n\t\t\tthis.location_id = args.location_id;\n\t\t\tthis.logging_enabled = args.logging_enabled;\n\t\t\tthis.ajax_wc_checkout_validate_nonce = args.ajax_wc_checkout_validate_nonce;\n\t\t\tthis.is_manual_order_payment = args.is_manual_order_payment;\n\n\t\t\tif ( $( 'form.checkout' ).length ) {\n\t\t\t\tthis.form = $( 'form.checkout' );\n\t\t\t\tthis.handle_checkout_page();\n\t\t\t} else if ( $( 'form#order_review' ).length ) {\n\t\t\t\tthis.form = $( 'form#order_review' );\n\t\t\t\tthis.handle_pay_page();\n\t\t\t} else if ( $( 'form#add_payment_method' ).length ) {\n\t\t\t\tthis.form = $( 'form#add_payment_method' );\n\t\t\t\tthis.handle_add_payment_method_page();\n\t\t\t} else {\n\t\t\t\tthis.log( 'No payment form found!' );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// localized error messages.\n\t\t\tthis.params = window.sv_wc_payment_gateway_payment_form_params;\n\n\t\t\t// unblock the UI and clear any payment nonces when a server-side error occurs.\n\t\t\t$( document.body ).on( 'checkout_error', () => {\n\t\t\t\t$( 'input[name=wc-square-credit-card-payment-nonce]' ).val( '' );\n\t\t\t\t$( 'input[name=wc-square-credit-card-buyer-verification-token]' ).val( '' );\n\t\t\t} );\n\n\t\t\t$( document.body ).on( 'click', `#payment_method_${ this.id }`, () => {\n\t\t\t\tif ( this.payment_form ) {\n\t\t\t\t\tthis.log( 'Recalculating payment form size' );\n\t\t\t\t\tthis.payment_form.recalculateSize();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the checkout page.\n\t\t */\n\t\thandle_checkout_page() {\n\t\t\t// updated payment fields jQuery object on each checkout update (prevents stale data).\n\t\t\t$( document.body ).on( 'updated_checkout', () => this.set_payment_fields() );\n\n\t\t\t// handle saved payment methods note on the checkout page.\n\t\t\t// this is bound to `updated_checkout` so it fires even when other parts of the checkout are changed.\n\t\t\t$( document.body ).on( 'updated_checkout', () => this.handle_saved_payment_methods() );\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\tthis.form.on( `checkout_place_order_${ this.id }`, () => this.validate_payment_data() );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle associated actions for saved payment methods.\n\t\t */\n\t\thandle_saved_payment_methods() {\n\t\t\t// make available inside change events.\n\t\t\tconst id_dasherized = this.id_dasherized;\n\t\t\tconst form_handler = this;\n\t\t\tconst $new_payment_method_selection = $( `div.js-wc-${ id_dasherized }-new-payment-method-form` );\n\n\t\t\t// show/hide the saved payment methods when a saved payment method is de-selected/selected.\n\t\t\t$( `input.js-wc-${ this.id_dasherized }-payment-token` ).on( 'change', () => {\n\t\t\t\tconst tokenized_payment_method_selected = $( `input.js-wc-${ id_dasherized }-payment-token:checked` ).val();\n\n\t\t\t\tif ( tokenized_payment_method_selected ) {\n\t\t\t\t\t// using an existing tokenized payment method, hide the 'new method' fields.\n\t\t\t\t\t$new_payment_method_selection.slideUp( 200 );\n\t\t\t\t} else {\n\t\t\t\t\t// use new payment method, display the 'new method' fields.\n\t\t\t\t\t$new_payment_method_selection.slideDown( 200 );\n\t\t\t\t}\n\t\t\t} ).trigger( 'change' );\n\n\t\t\t// display the 'save payment method' option for guest checkouts if the 'create account' option is checked\n\t\t\t// but only hide the input if there is a 'create account' checkbox (some themes just display the password).\n\t\t\t$( 'input#createaccount' ).on( 'change', ( e ) => {\n\t\t\t\tif ( $( e.target ).is( ':checked' ) ) {\n\t\t\t\t\tform_handler.show_save_payment_checkbox( id_dasherized );\n\t\t\t\t} else {\n\t\t\t\t\tform_handler.hide_save_payment_checkbox( id_dasherized );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tif ( ! $( 'input#createaccount' ).is( ':checked' ) ) {\n\t\t\t\t$( 'input#createaccount' ).trigger( 'change' );\n\t\t\t}\n\n\t\t\t// hide the 'save payment method' when account creation is not enabled and customer is not logged in.\n\t\t\tif ( ! this.is_user_logged_in && ! this.is_checkout_registration_enabled ) {\n\t\t\t\tthis.hide_save_payment_checkbox( id_dasherized );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the Order > Pay page.\n\t\t */\n\t\thandle_pay_page() {\n\t\t\tthis.set_payment_fields();\n\n\t\t\t// handle saved payment methods.\n\t\t\tthis.handle_saved_payment_methods();\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\t// but only when one of our payment gateways is selected.\n\t\t\tthis.form.on( 'submit', () => ( $( '#order_review input[name=payment_method]:checked' ).val() === this.id ) && this.validate_payment_data() );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the Add Payment Method page.\n\t\t */\n\t\thandle_add_payment_method_page() {\n\t\t\tthis.set_payment_fields();\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\t// but only when one of our payment gateways is selected.\n\t\t\tthis.form.on( 'submit', () => ( $( '#add_payment_method input[name=payment_method]:checked' ).val() === this.id ) && this.validate_payment_data() );\n\t\t}\n\n\t\t/**\n\t\t * Sets up the Square payment fields.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tset_payment_fields() {\n\t\t\tif ( ! $( `#wc-${ this.id_dasherized }-account-number-hosted` ).length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( $( `#wc-${ this.id_dasherized }-account-number-hosted` ).is( 'iframe' ) ) {\n\t\t\t\tthis.log( 'Re-adding payment form' );\n\n\t\t\t\tfor ( const [ _, field ] of Object.entries( this.form_fields ) ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\t$( field.attr( 'id' ) ).replaceWith( field );\n\t\t\t\t}\n\n\t\t\t\tthis.handle_form_loaded();\n\t\t\t} else {\n\t\t\t\tif ( this.payment_form ) {\n\t\t\t\t\tthis.log( 'Destroying payment form' );\n\t\t\t\t\tthis.payment_form.destroy();\n\t\t\t\t\tthis.payment_form = null;\n\t\t\t\t}\n\n\t\t\t\tthis.log( 'Building payment form' );\n\n\t\t\t\tthis.payment_form = new SqPaymentForm( this.get_form_params() ); // eslint-disable-line no-undef\n\n\t\t\t\tthis.payment_form.build();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Gets the Square payment form params.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @return {Object} Form params.\n\t\t */\n\t\tget_form_params() {\n\t\t\tthis.form_fields = {\n\t\t\t\tcard_number: $( `#wc-${ this.id_dasherized }-account-number-hosted` ),\n\t\t\t\texpiration: $( `#wc-${ this.id_dasherized }-expiry-hosted` ),\n\t\t\t\tcsc: $( `#wc-${ this.id_dasherized }-csc-hosted` ),\n\t\t\t\tpostal_code: $( `#wc-${ this.id_dasherized }-postal-code-hosted` ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tapplicationId: this.application_id,\n\t\t\t\tlocationId: this.location_id,\n\t\t\t\tcardNumber: {\n\t\t\t\t\telementId: this.form_fields.card_number.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.card_number.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\texpirationDate: {\n\t\t\t\t\telementId: this.form_fields.expiration.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.expiration.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tcvv: {\n\t\t\t\t\telementId: this.form_fields.csc.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.csc.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tpostalCode: {\n\t\t\t\t\telementId: this.form_fields.postal_code.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.postal_code.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tinputClass: `wc-${ this.id_dasherized }-payment-field`,\n\t\t\t\tinputStyles: this.input_styles,\n\t\t\t\tcallbacks: {\n\t\t\t\t\tinputEventReceived: ( e ) => this.handle_input_event( e ),\n\t\t\t\t\tcardNonceResponseReceived: ( errors, nonce, cardData ) => this.handle_card_nonce_response( errors, nonce, cardData ),\n\t\t\t\t\tunsupportedBrowserDetected: () => this.handle_unsupported_browser(),\n\t\t\t\t\tpaymentFormLoaded: () => this.handle_form_loaded(),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Handles when the payment form is fully loaded.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\thandle_form_loaded() {\n\t\t\tthis.log( 'Payment form loaded' );\n\n\t\t\tthis.payment_form.setPostalCode( $( '#billing_postcode' ).val() );\n\n\t\t\t// hide the postcode field on the checkout page or if it already has a value.\n\t\t\tif ( $( 'form.checkout' ).length || $( '#billing_postcode' ).val() ) {\n\t\t\t\t$( '.wc-square-credit-card-card-postal-code-parent' ).addClass( 'hidden' );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Handles payment form input changes.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object} e\n\t\t */\n\t\thandle_input_event( e ) {\n\t\t\tconst $input = $( '#' + e.elementId );\n\n\t\t\tif ( e.eventType === 'cardBrandChanged' ) {\n\t\t\t\tthis.handle_card_brand_change( e.cardBrand, $input );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Handles card number brand changes.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {string} brand\n\t\t * @param {Object} $input\n\t\t */\n\t\thandle_card_brand_change( brand, $input ) {\n\t\t\tthis.log( `Card brand changed to ${ brand }` );\n\n\t\t\t// clear any existing card type class\n\t\t\t$input.attr( 'class', ( i, c ) => {\n\t\t\t\treturn c.replace( /(^|\\s)card-type-\\S+/g, '' );\n\t\t\t} );\n\n\t\t\tlet card_class = 'plain';\n\n\t\t\tif ( null === brand || 'unknown' === brand ) {\n\t\t\t\tbrand = '';\n\t\t\t}\n\n\t\t\tif ( null !== this.square_card_types[ brand ] ) {\n\t\t\t\tbrand = this.square_card_types[ brand ];\n\t\t\t}\n\n\t\t\tif ( brand && ! this.enabled_card_types.includes( brand ) ) {\n\t\t\t\tcard_class = 'invalid';\n\t\t\t} else {\n\t\t\t\tcard_class = brand;\n\t\t\t}\n\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-card-type]` ).val( brand );\n\n\t\t\t$input.addClass( `card-type-${ card_class }` );\n\t\t}\n\n\t\t/**\n\t\t * Used to request a card nonce and submit the form.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tvalidate_payment_data() {\n\t\t\tif ( this.form.is( '.processing' ) ) {\n\t\t\t\t// bail when already processing.\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// let through if nonce is already present - nonce is only present on non-tokenized payments.\n\t\t\tif ( this.has_nonce() ) {\n\t\t\t\tthis.log( 'Payment nonce present, placing order' );\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst tokenized_card_id = this.get_tokenized_payment_method_id();\n\n\t\t\tif ( tokenized_card_id ) {\n\t\t\t\tif ( ! this.is_3ds_enabled ) {\n\t\t\t\t\t// if 3DS is disabled and paying with a saved method, no further validation needed.\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif ( this.has_verification_token() ) {\n\t\t\t\t\tthis.log( 'Tokenized payment verification token present, placing order' );\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tthis.log( 'Requesting verification token for tokenized payment' );\n\n\t\t\t\tthis.block_ui();\n\t\t\t\tthis.payment_form.verifyBuyer( tokenized_card_id, this.get_verification_details(), this.handle_verify_buyer_response.bind( this ) );\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis.log( 'Requesting payment nonce' );\n\t\t\tthis.block_ui();\n\t\t\tthis.payment_form.requestCardNonce();\n\t\t\treturn false;\n\t\t}\n\n\t\t/**\n\t\t * Gets the selected tokenized payment method ID, if there is one.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} Tokenized payment method ID.\n\t\t */\n\t\tget_tokenized_payment_method_id() {\n\t\t\treturn $( `.payment_method_${ this.id }` ).find( '.js-wc-square-credit-card-payment-token:checked' ).val();\n\t\t}\n\n\t\t/**\n\t\t * Handles the Square payment form card nonce response.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @param {Object} errors Validation errors, if any.\n\t\t * @param {string} nonce Payment nonce.\n\t\t * @param {Object} cardData Non-confidential info about the card used.\n\t\t */\n\t\thandle_card_nonce_response( errors, nonce, cardData ) {\n\t\t\t// if we have real errors to display from Square.\n\t\t\tif ( errors ) {\n\t\t\t\treturn this.handle_errors( errors );\n\t\t\t}\n\n\t\t\t// no errors, but also no payment data.\n\t\t\tif ( ! nonce ) {\n\t\t\t\tconst message = 'Nonce is missing from the Square response';\n\n\t\t\t\tthis.log( message, 'error' );\n\t\t\t\tthis.log_data( message, 'response' );\n\t\t\t\treturn this.handle_errors();\n\t\t\t}\n\n\t\t\t// if we made it this far, we have payment data.\n\t\t\tthis.log( 'Card data received' );\n\t\t\tthis.log( cardData );\n\t\t\tthis.log_data( cardData, 'response' );\n\n\t\t\tif ( cardData.last_4 ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-last-four]` ).val( cardData.last_4 );\n\t\t\t}\n\n\t\t\tif ( cardData.exp_month ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-exp-month]` ).val( cardData.exp_month );\n\t\t\t}\n\n\t\t\tif ( cardData.exp_year ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-exp-year]` ).val( cardData.exp_year );\n\t\t\t}\n\n\t\t\tif ( cardData.billing_postal_code ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-payment-postcode]` ).val( cardData.billing_postal_code );\n\t\t\t}\n\n\t\t\t// payment nonce data.\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-payment-nonce]` ).val( nonce );\n\n\t\t\t// if 3ds is enabled, we need to verify the buyer and record the verification token before continuing.\n\t\t\tif ( this.is_3ds_enabled ) {\n\t\t\t\tthis.log( 'Verifying buyer' );\n\n\t\t\t\tthis.payment_form.verifyBuyer( nonce, this.get_verification_details(), this.handle_verify_buyer_response.bind( this ) );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// now that we have a nonce, resubmit the form.\n\t\t\tthis.form.trigger( 'submit' );\n\t\t}\n\n\t\t/**\n\t\t * Handles the response from a call to verifyBuyer()\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @param {Object} errors Verification errors, if any.\n\t\t * @param {Object} verification_result Results of verification.\n\t\t */\n\t\thandle_verify_buyer_response( errors, verification_result ) {\n\t\t\tif ( errors ) {\n\t\t\t\t$( errors ).each( ( index, error ) => {\n\t\t\t\t\tif ( ! error.field ) {\n\t\t\t\t\t\terror.field = 'none';\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn this.handle_errors( errors );\n\t\t\t}\n\n\t\t\t// no errors, but also no verification token.\n\t\t\tif ( ! verification_result || ! verification_result.token ) {\n\t\t\t\tconst message = 'Verification token is missing from the Square response';\n\n\t\t\t\tthis.log( message, 'error' );\n\t\t\t\tthis.log_data( message, 'response' );\n\n\t\t\t\treturn this.handle_errors();\n\t\t\t}\n\n\t\t\tthis.log( 'Verification result received' );\n\t\t\tthis.log( verification_result );\n\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-buyer-verification-token]` ).val( verification_result.token );\n\n\t\t\tthis.form.trigger( 'submit' );\n\t\t}\n\n\t\t/**\n\t\t * Gets a verification details object to be used in verifyBuyer()\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {Object} Verification details object.\n\t\t */\n\t\tget_verification_details() {\n\t\t\tconst verification_details = {\n\t\t\t\tbillingContact: {\n\t\t\t\t\tfamilyName: $( '#billing_last_name' ).val() || '',\n\t\t\t\t\tgivenName: $( '#billing_first_name' ).val() || '',\n\t\t\t\t\temail: $( '#billing_email' ).val() || '',\n\t\t\t\t\tcountry: $( '#billing_country' ).val() || '',\n\t\t\t\t\tregion: $( '#billing_state' ).val() || '',\n\t\t\t\t\tcity: $( '#billing_city' ).val() || '',\n\t\t\t\t\tpostalCode: $( '#billing_postcode' ).val() || '',\n\t\t\t\t\tphone: $( '#billing_phone' ).val() || '',\n\t\t\t\t\taddressLines: [ $( '#billing_address_1' ).val() || '', $( '#billing_address_2' ).val() || '' ],\n\t\t\t\t},\n\t\t\t\tintent: this.get_intent(),\n\t\t\t};\n\n\t\t\tif ( 'CHARGE' === verification_details.intent ) {\n\t\t\t\tverification_details.amount = this.get_amount();\n\t\t\t\tverification_details.currencyCode = this.currency_code;\n\t\t\t}\n\n\t\t\tthis.log( verification_details );\n\n\t\t\treturn verification_details;\n\t\t}\n\n\t\t/**\n\t\t * Gets the intent of this processing - either 'CHARGE' or 'STORE'\n\t\t *\n\t\t * The gateway stores cards before processing a payment, so this checks whether the customer checked \"save method\"\n\t\t * at checkout, and isn't otherwise using a saved method already.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} {'CHARGE'|'STORE'}\n\t\t */\n\t\tget_intent() {\n\t\t\tconst $save_method_input = $( '#wc-square-credit-card-tokenize-payment-method' );\n\n\t\t\tlet save_payment_method;\n\n\t\t\tif ( $save_method_input.is( 'input:checkbox' ) ) {\n\t\t\t\tsave_payment_method = $save_method_input.is( ':checked' );\n\t\t\t} else {\n\t\t\t\tsave_payment_method = 'true' === $save_method_input.val();\n\t\t\t}\n\n\t\t\tif ( ! this.get_tokenized_payment_method_id() && save_payment_method ) {\n\t\t\t\treturn 'STORE';\n\t\t\t}\n\n\t\t\treturn 'CHARGE';\n\t\t}\n\n\t\t/**\n\t\t * Gets the amount of this payment.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} Payment amount.\n\t\t */\n\t\tget_amount() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-amount]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Handles unsupported browsers.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\thandle_unsupported_browser() {}\n\n\t\t/**\n\t\t * Handle error data.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object|null} errors\n\t\t */\n\t\thandle_errors( errors = null ) {\n\t\t\tthis.log( 'Error getting payment data', 'error' );\n\n\t\t\t// clear any previous nonces\n\t\t\t$( 'input[name=wc-square-credit-card-payment-nonce]' ).val( '' );\n\t\t\t$( 'input[name=wc-square-credit-card-buyer-verification-token]' ).val( '' );\n\n\t\t\tconst messages = [];\n\n\t\t\tif ( errors ) {\n\t\t\t\tconst field_order = [ 'none', 'cardNumber', 'expirationDate', 'cvv', 'postalCode' ];\n\n\t\t\t\tif ( errors.length >= 1 ) {\n\t\t\t\t\t// sort based on the field order without the brackets around a.field and b.field.\n\t\t\t\t\t// the precedence is different and gives different results.\n\t\t\t\t\terrors.sort( ( a, b ) => {\n\t\t\t\t\t\treturn field_order.indexOf( a.field ) - field_order.indexOf( b.field );\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t$( errors ).each( ( index, error ) => {\n\t\t\t\t\t// only display the errors that can be helped by the customer.\n\t\t\t\t\tif ( 'UNSUPPORTED_CARD_BRAND' === error.type || 'VALIDATION_ERROR' === error.type ) {\n\t\t\t\t\t\t// To avoid confusion between CSC used in the frontend and CVV that is used in the error message.\n\t\t\t\t\t\treturn messages.push( error.message.replace( /CVV/, 'CSC' ) );\n\t\t\t\t\t}\n\n\t\t\t\t\t// otherwise, log more serious errors to the debug log.\n\t\t\t\t\treturn this.log_data( errors, 'response' );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// if no specific messages are set, display a general error.\n\t\t\tif ( messages.length === 0 ) {\n\t\t\t\tmessages.push( this.general_error );\n\t\t\t}\n\n\t\t\t// Conditionally process error rendering.\n\t\t\tif ( ! this.is_add_payment_method_page && ! this.is_manual_order_payment ) {\n\t\t\t\tthis.render_checkout_errors( messages );\n\t\t\t} else {\n\t\t\t\tthis.render_errors( messages );\n\t\t\t}\n\n\t\t\tthis.unblock_ui();\n\t\t}\n\n\t\t/**\n\t\t * Public: Render any new errors and bring them into the viewport.\n\t\t *\n\t\t * @param {Array} errors\n\t\t */\n\t\trender_errors( errors ) {\n\t\t\t// hide and remove any previous errors.\n\t\t\t$( '.woocommerce-error, .woocommerce-message' ).remove();\n\n\t\t\t// add errors.\n\t\t\tthis.form.prepend( '<ul class=\"woocommerce-error\"><li>' + errors.join( '</li><li>' ) + '</li></ul>' );\n\n\t\t\t// unblock UI\n\t\t\tthis.form.removeClass( 'processing' ).unblock();\n\t\t\tthis.form.find( '.input-text, select' ).trigger( 'blur' );\n\n\t\t\t// scroll to top\n\t\t\t$( 'html, body' ).animate( {\n\t\t\t\tscrollTop: this.form.offset().top - 100,\n\t\t\t}, 1000 );\n\t\t}\n\n\t\t/**\n\t\t * Blocks the payment form UI.\n\t\t *\n\t\t * @since 3.0.0\n\t\t */\n\t\tblock_ui() {\n\t\t\tthis.form.block( {\n\t\t\t\tmessage: null,\n\t\t\t\toverlayCSS: {\n\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\topacity: 0.6,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Unblocks the payment form UI.\n\t\t *\n\t\t * @since 3.0.0\n\t\t */\n\t\tunblock_ui() {\n\t\t\treturn this.form.unblock();\n\t\t}\n\n\t\t/**\n\t\t * Hides save payment method checkbox.\n\t\t *\n\t\t * @since 2.1.2\n\t\t *\n\t\t * @param {string} id_dasherized\n\t\t */\n\t\thide_save_payment_checkbox( id_dasherized ) {\n\t\t\tconst $parent_row = $( `input.js-wc-${ id_dasherized }-tokenize-payment-method` ).closest( 'p.form-row' );\n\n\t\t\t$parent_row.hide();\n\t\t\t$parent_row.next().hide();\n\t\t}\n\n\t\t/**\n\t\t * Shows save payment method checkbox.\n\t\t *\n\t\t * @since 2.1.2\n\t\t *\n\t\t * @param {string} id_dasherized\n\t\t */\n\t\tshow_save_payment_checkbox( id_dasherized ) {\n\t\t\tconst $parent_row = $( `input.js-wc-${ id_dasherized }-tokenize-payment-method` ).closest( 'p.form-row' );\n\n\t\t\t$parent_row.slideDown();\n\t\t\t$parent_row.next().show();\n\t\t}\n\n\t\t/**\n\t\t * Determines if a nonce is present in the hidden input.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @return {boolean} True if nonce is present, otherwise false.\n\t\t */\n\t\thas_nonce() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-payment-nonce]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Determines if a verification token is present in the hidden input.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {boolean} True if verification token is present, otherwise false.\n\t\t */\n\t\thas_verification_token() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-buyer-verification-token]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Logs data to the debug log via AJAX.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object} data Request data.\n\t\t * @param {string} type Data type.\n\t\t */\n\t\tlog_data( data, type ) {\n\t\t\t// if logging is disabled, bail.\n\t\t\tif ( ! this.logging_enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst ajax_data = {\n\t\t\t\taction: 'wc_' + this.id + '_log_js_data',\n\t\t\t\tsecurity: this.ajax_log_nonce,\n\t\t\t\ttype,\n\t\t\t\tdata,\n\t\t\t};\n\n\t\t\t$.ajax( {\n\t\t\t\turl: this.ajax_url,\n\t\t\t\tdata: ajax_data,\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Logs any messages or errors to the console.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {string} message\n\t\t * @param {string} type Data type.\n\t\t */\n\t\tlog( message, type = 'notice' ) {\n\t\t\t// if logging is disabled, bail.\n\t\t\tif ( ! this.logging_enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( 'error' === type ) {\n\t\t\t\tconsole.error( 'Square Error: ' + message );\n\t\t\t} else {\n\t\t\t\tconsole.log( 'Square: ' + message );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * AJAX validate WooCommerce form data.\n\t\t *\n\t\t * Triggered only if errors are present on Square payment form.\n\t\t *\n\t\t * @since 2.2\n\t\t *\n\t\t * @param {Array} square_errors Square validation errors.\n\t\t */\n\t\trender_checkout_errors( square_errors ) {\n\t\t\tconst ajax_url = wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', this.id + '_checkout_handler' );\n\t\t\tconst square_handler = this;\n\n\t\t\tconst form_data = this.form.serializeArray();\n\n\t\t\t// Add action field to data for nonce verification.\n\t\t\tform_data.push( {\n\t\t\t\tname: 'wc_' + this.id + '_checkout_validate_nonce',\n\t\t\t\tvalue: this.ajax_wc_checkout_validate_nonce,\n\t\t\t} );\n\n\t\t\treturn $.ajax( {\n\t\t\t\turl: ajax_url,\n\t\t\t\tmethod: 'post',\n\t\t\t\tcache: false,\n\t\t\t\tdata: form_data,\n\t\t\t\tcomplete: ( response ) => {\n\t\t\t\t\tconst result = response.responseJSON;\n\n\t\t\t\t\t// If validation is not triggered and WooCommerce returns failure.\n\t\t\t\t\t// Temporary workaround to fix problems when user email is invalid.\n\t\t\t\t\tif ( result.hasOwnProperty( 'result' ) && 'failure' === result.result ) {\n\t\t\t\t\t\t$( result.messages ).map( ( message ) => {\n\t\t\t\t\t\t\tconst errors = [];\n\n\t\t\t\t\t\t\t$( message ).children( 'li' ).each( () => {\n\t\t\t\t\t\t\t\terrors.push( $( this ).text().trim() );\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\treturn square_errors.unshift( ...errors );\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t// If validation is complete and WooCommerce returns validaiton errors.\n\t\t\t\t\t} else if ( result.hasOwnProperty( 'success' ) && ! result.success ) {\n\t\t\t\t\t\tsquare_errors.unshift( ...result.data.messages );\n\t\t\t\t\t}\n\n\t\t\t\t\tsquare_handler.render_errors( square_errors );\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}\n\n\twindow.WC_Square_Payment_Form_Handler = WC_Square_Payment_Form_Handler;\n} );\n"],"file":"wc-square.min.js"}
1
+ {"version":3,"sources":["wc-square.js"],"names":["jQuery","document","ready","$","WC_Square_Payment_Form_Handler","args","id","id_dasherized","csc_required","enabled_card_types","square_card_types","ajax_log_nonce","ajax_url","application_id","currency_code","general_error","input_styles","is_3ds_enabled","is_3d_secure_enabled","is_add_payment_method_page","is_checkout_registration_enabled","is_user_logged_in","location_id","logging_enabled","ajax_wc_checkout_validate_nonce","is_manual_order_payment","length","form","handle_checkout_page","handle_pay_page","handle_add_payment_method_page","log","params","window","sv_wc_payment_gateway_payment_form_params","body","on","val","payment_form","recalculateSize","set_payment_fields","handle_saved_payment_methods","validate_payment_data","form_handler","$new_payment_method_selection","tokenized_payment_method_selected","slideUp","slideDown","trigger","e","target","is","show_save_payment_checkbox","hide_save_payment_checkbox","self","Object","entries","form_fields","_","field","attr","replaceWith","handle_form_loaded","destroy","SqPaymentForm","get_form_params","build","card_number","expiration","csc","postal_code","applicationId","locationId","cardNumber","elementId","placeholder","data","expirationDate","cvv","postalCode","inputClass","inputStyles","callbacks","inputEventReceived","handle_input_event","cardNonceResponseReceived","errors","nonce","cardData","handle_card_nonce_response","unsupportedBrowserDetected","handle_unsupported_browser","paymentFormLoaded","setPostalCode","addClass","$input","eventType","handle_card_brand_change","cardBrand","brand","i","c","replace","card_class","includes","has_nonce","tokenized_card_id","get_tokenized_payment_method_id","has_verification_token","block_ui","verifyBuyer","get_verification_details","handle_verify_buyer_response","bind","requestCardNonce","find","handle_errors","message","log_data","last_4","exp_month","exp_year","billing_postal_code","verification_result","each","index","error","token","verification_details","billingContact","familyName","givenName","email","country","region","city","phone","addressLines","intent","get_intent","amount","get_amount","currencyCode","$save_method_input","save_payment_method","messages","field_order","sort","a","b","indexOf","type","push","render_checkout_errors","render_errors","unblock_ui","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","$parent_row","closest","hide","next","show","ajax_data","action","security","ajax","url","console","square_errors","wc_cart_fragments_params","wc_ajax_url","toString","square_handler","form_data","serializeArray","name","value","method","cache","complete","response","result","responseJSON","hasOwnProperty","map","children","text","trim","unshift","success"],"mappings":"q8EAOAA,MAAM,CAAEC,QAAF,CAAN,CAAmBC,KAAnB,CAA0B,SAAEC,CAAF,CAAS,IAM5BC,CAAAA,8BAN4B,YAcjC,wCAAaC,IAAb,CAAoB,qEACnB,KAAKC,EAAL,CAAUD,IAAI,CAACC,EAAf,CACA,KAAKC,aAAL,CAAqBF,IAAI,CAACE,aAA1B,CACA,KAAKC,YAAL,CAAoBH,IAAI,CAACG,YAAzB,CACA,KAAKC,kBAAL,CAA0BJ,IAAI,CAACI,kBAA/B,CACA,KAAKC,iBAAL,CAAyBL,IAAI,CAACK,iBAA9B,CACA,KAAKC,cAAL,CAAsBN,IAAI,CAACM,cAA3B,CACA,KAAKC,QAAL,CAAgBP,IAAI,CAACO,QAArB,CACA,KAAKC,cAAL,CAAsBR,IAAI,CAACQ,cAA3B,CACA,KAAKC,aAAL,CAAqBT,IAAI,CAACS,aAA1B,CACA,KAAKC,aAAL,CAAq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CAAE,KAAKpK,+BAFG,CAAhB,EAKA,MAAOrB,CAAAA,CAAC,CAAC8K,IAAF,CAAQ,CACdC,GAAG,CAAEtK,QADS,CAEdiL,MAAM,CAAE,MAFM,CAGdC,KAAK,CAAE,KAHO,CAIdlH,IAAI,CAAE6G,SAJQ,CAKdM,QAAQ,CAAE,kBAAEC,QAAF,CAAgB,CACzB,GAAMC,CAAAA,MAAM,CAAGD,QAAQ,CAACE,YAAxB,CAIA,GAAKD,MAAM,CAACE,cAAP,CAAuB,QAAvB,GAAqC,YAAcF,MAAM,CAACA,MAA/D,CAAwE,CACvE9L,CAAC,CAAE8L,MAAM,CAAChD,QAAT,CAAD,CAAqBmD,GAArB,CAA0B,SAAE/E,OAAF,CAAe,CACxC,GAAM/B,CAAAA,MAAM,CAAG,EAAf,CAEAnF,CAAC,CAAEkH,OAAF,CAAD,CAAagF,QAAb,CAAuB,IAAvB,EAA8BzE,IAA9B,CAAoC,UAAM,CACzCtC,MAAM,CAACkE,IAAP,CAAarJ,CAAC,CAAE,MAAF,CAAD,CAAUmM,IAAV,GAAiBC,IAAjB,EAAb,CACA,CAFD,EAIA,MAAOnB,CAAAA,aAAa,CAACoB,OAAd,OAAApB,aAAa,CAAa9F,MAAb,CACpB,CARD,CAWA,CAZD,IAYO,IAAK2G,MAAM,CAACE,cAAP,CAAuB,SAAvB,GAAsC,CAAEF,MAAM,CAACQ,OAApD,CAA8D,CACpErB,aAAa,CAACoB,OAAd,OAAApB,aAAa,oBAAaa,MAAM,CAACrH,IAAP,CAAYqE,QAAzB,EACb,CAEDuC,cAAc,CAAC9B,aAAf,CAA8B0B,aAA9B,CACA,CA3Ba,CAAR,CA6BP,CAjxBgC,6CAoxBlCnJ,MAAM,CAAC7B,8BAAP,CAAwCA,8BACxC,CArxBD","sourcesContent":["/* global wc_cart_fragments_params */\n\n/**\n * WooCommerce Square Payment Form handler.\n *\n * @since 2.0.0\n */\njQuery( document ).ready( ( $ ) => {\n\t/**\n\t * Square Credit Card Payment Form Handler class.\n\t *\n\t * @since 2.0.0\n\t */\n\tclass WC_Square_Payment_Form_Handler {\n\t\t/**\n\t\t * Setup handler.\n\t\t *\n\t\t * @since 2.3.2-1\n\t\t *\n\t\t * @param {Object} args\n\t\t */\n\t\tconstructor( args ) {\n\t\t\tthis.id = args.id;\n\t\t\tthis.id_dasherized = args.id_dasherized;\n\t\t\tthis.csc_required = args.csc_required;\n\t\t\tthis.enabled_card_types = args.enabled_card_types;\n\t\t\tthis.square_card_types = args.square_card_types;\n\t\t\tthis.ajax_log_nonce = args.ajax_log_nonce;\n\t\t\tthis.ajax_url = args.ajax_url;\n\t\t\tthis.application_id = args.application_id;\n\t\t\tthis.currency_code = args.currency_code;\n\t\t\tthis.general_error = args.general_error;\n\t\t\tthis.input_styles = args.input_styles;\n\t\t\tthis.is_3ds_enabled = args.is_3d_secure_enabled;\n\t\t\tthis.is_add_payment_method_page = args.is_add_payment_method_page;\n\t\t\tthis.is_checkout_registration_enabled = args.is_checkout_registration_enabled;\n\t\t\tthis.is_user_logged_in = args.is_user_logged_in;\n\t\t\tthis.location_id = args.location_id;\n\t\t\tthis.logging_enabled = args.logging_enabled;\n\t\t\tthis.ajax_wc_checkout_validate_nonce = args.ajax_wc_checkout_validate_nonce;\n\t\t\tthis.is_manual_order_payment = args.is_manual_order_payment;\n\n\t\t\tif ( $( 'form.checkout' ).length ) {\n\t\t\t\tthis.form = $( 'form.checkout' );\n\t\t\t\tthis.handle_checkout_page();\n\t\t\t} else if ( $( 'form#order_review' ).length ) {\n\t\t\t\tthis.form = $( 'form#order_review' );\n\t\t\t\tthis.handle_pay_page();\n\t\t\t} else if ( $( 'form#add_payment_method' ).length ) {\n\t\t\t\tthis.form = $( 'form#add_payment_method' );\n\t\t\t\tthis.handle_add_payment_method_page();\n\t\t\t} else {\n\t\t\t\tthis.log( 'No payment form found!' );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// localized error messages.\n\t\t\tthis.params = window.sv_wc_payment_gateway_payment_form_params;\n\n\t\t\t// unblock the UI and clear any payment nonces when a server-side error occurs.\n\t\t\t$( document.body ).on( 'checkout_error', () => {\n\t\t\t\t$( 'input[name=wc-square-credit-card-payment-nonce]' ).val( '' );\n\t\t\t\t$( 'input[name=wc-square-credit-card-buyer-verification-token]' ).val( '' );\n\t\t\t} );\n\n\t\t\t$( document.body ).on( 'click', `#payment_method_${ this.id }`, () => {\n\t\t\t\tif ( this.payment_form ) {\n\t\t\t\t\tthis.log( 'Recalculating payment form size' );\n\t\t\t\t\tthis.payment_form.recalculateSize();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the checkout page.\n\t\t */\n\t\thandle_checkout_page() {\n\t\t\t// updated payment fields jQuery object on each checkout update (prevents stale data).\n\t\t\t$( document.body ).on( 'updated_checkout', () => this.set_payment_fields() );\n\n\t\t\t// handle saved payment methods note on the checkout page.\n\t\t\t// this is bound to `updated_checkout` so it fires even when other parts of the checkout are changed.\n\t\t\t$( document.body ).on( 'updated_checkout', () => this.handle_saved_payment_methods() );\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\tthis.form.on( `checkout_place_order_${ this.id }`, () => this.validate_payment_data() );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle associated actions for saved payment methods.\n\t\t */\n\t\thandle_saved_payment_methods() {\n\t\t\t// make available inside change events.\n\t\t\tconst id_dasherized = this.id_dasherized;\n\t\t\tconst form_handler = this;\n\t\t\tconst $new_payment_method_selection = $( `div.js-wc-${ id_dasherized }-new-payment-method-form` );\n\n\t\t\t// show/hide the saved payment methods when a saved payment method is de-selected/selected.\n\t\t\t$( `input.js-wc-${ this.id_dasherized }-payment-token` ).on( 'change', () => {\n\t\t\t\tconst tokenized_payment_method_selected = $( `input.js-wc-${ id_dasherized }-payment-token:checked` ).val();\n\n\t\t\t\tif ( tokenized_payment_method_selected ) {\n\t\t\t\t\t// using an existing tokenized payment method, hide the 'new method' fields.\n\t\t\t\t\t$new_payment_method_selection.slideUp( 200 );\n\t\t\t\t} else {\n\t\t\t\t\t// use new payment method, display the 'new method' fields.\n\t\t\t\t\t$new_payment_method_selection.slideDown( 200 );\n\t\t\t\t}\n\t\t\t} ).trigger( 'change' );\n\n\t\t\t// display the 'save payment method' option for guest checkouts if the 'create account' option is checked\n\t\t\t// but only hide the input if there is a 'create account' checkbox (some themes just display the password).\n\t\t\t$( 'input#createaccount' ).on( 'change', ( e ) => {\n\t\t\t\tif ( $( e.target ).is( ':checked' ) ) {\n\t\t\t\t\tform_handler.show_save_payment_checkbox( id_dasherized );\n\t\t\t\t} else {\n\t\t\t\t\tform_handler.hide_save_payment_checkbox( id_dasherized );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tif ( ! $( 'input#createaccount' ).is( ':checked' ) ) {\n\t\t\t\t$( 'input#createaccount' ).trigger( 'change' );\n\t\t\t}\n\n\t\t\t// hide the 'save payment method' when account creation is not enabled and customer is not logged in.\n\t\t\tif ( ! this.is_user_logged_in && ! this.is_checkout_registration_enabled ) {\n\t\t\t\tthis.hide_save_payment_checkbox( id_dasherized );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the Order > Pay page.\n\t\t */\n\t\thandle_pay_page() {\n\t\t\tthis.set_payment_fields();\n\n\t\t\t// handle saved payment methods.\n\t\t\tthis.handle_saved_payment_methods();\n\n\t\t\tconst self = this;\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\t// but only when one of our payment gateways is selected.\n\t\t\tthis.form.on( 'submit', function() {\n\t\t\t\tif ( $( '#order_review input[name=payment_method]:checked' ).val() === self.id ) {\n\t\t\t\t\treturn self.validate_payment_data();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Public: Handle required actions on the Add Payment Method page.\n\t\t */\n\t\thandle_add_payment_method_page() {\n\t\t\tthis.set_payment_fields();\n\n\t\t\tconst self = this;\n\n\t\t\t// validate payment data before order is submitted.\n\t\t\t// but only when one of our payment gateways is selected.\n\t\t\tthis.form.on( 'submit', function() {\n\t\t\t\tif ( $( '#add_payment_method input[name=payment_method]:checked' ).val() === self.id ) {\n\t\t\t\t\treturn self.validate_payment_data();\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Sets up the Square payment fields.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tset_payment_fields() {\n\t\t\tif ( ! $( `#wc-${ this.id_dasherized }-account-number-hosted` ).length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( $( `#wc-${ this.id_dasherized }-account-number-hosted` ).is( 'iframe' ) ) {\n\t\t\t\tthis.log( 'Re-adding payment form' );\n\n\t\t\t\tfor ( const [ _, field ] of Object.entries( this.form_fields ) ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\t$( field.attr( 'id' ) ).replaceWith( field );\n\t\t\t\t}\n\n\t\t\t\tthis.handle_form_loaded();\n\t\t\t} else {\n\t\t\t\tif ( this.payment_form ) {\n\t\t\t\t\tthis.log( 'Destroying payment form' );\n\t\t\t\t\tthis.payment_form.destroy();\n\t\t\t\t\tthis.payment_form = null;\n\t\t\t\t}\n\n\t\t\t\tthis.log( 'Building payment form' );\n\n\t\t\t\tthis.payment_form = new SqPaymentForm( this.get_form_params() ); // eslint-disable-line no-undef\n\n\t\t\t\tthis.payment_form.build();\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Gets the Square payment form params.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @return {Object} Form params.\n\t\t */\n\t\tget_form_params() {\n\t\t\tthis.form_fields = {\n\t\t\t\tcard_number: $( `#wc-${ this.id_dasherized }-account-number-hosted` ),\n\t\t\t\texpiration: $( `#wc-${ this.id_dasherized }-expiry-hosted` ),\n\t\t\t\tcsc: $( `#wc-${ this.id_dasherized }-csc-hosted` ),\n\t\t\t\tpostal_code: $( `#wc-${ this.id_dasherized }-postal-code-hosted` ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tapplicationId: this.application_id,\n\t\t\t\tlocationId: this.location_id,\n\t\t\t\tcardNumber: {\n\t\t\t\t\telementId: this.form_fields.card_number.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.card_number.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\texpirationDate: {\n\t\t\t\t\telementId: this.form_fields.expiration.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.expiration.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tcvv: {\n\t\t\t\t\telementId: this.form_fields.csc.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.csc.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tpostalCode: {\n\t\t\t\t\telementId: this.form_fields.postal_code.attr( 'id' ),\n\t\t\t\t\tplaceholder: this.form_fields.postal_code.data( 'placeholder' ),\n\t\t\t\t},\n\t\t\t\tinputClass: `wc-${ this.id_dasherized }-payment-field`,\n\t\t\t\tinputStyles: this.input_styles,\n\t\t\t\tcallbacks: {\n\t\t\t\t\tinputEventReceived: ( e ) => this.handle_input_event( e ),\n\t\t\t\t\tcardNonceResponseReceived: ( errors, nonce, cardData ) => this.handle_card_nonce_response( errors, nonce, cardData ),\n\t\t\t\t\tunsupportedBrowserDetected: () => this.handle_unsupported_browser(),\n\t\t\t\t\tpaymentFormLoaded: () => this.handle_form_loaded(),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Handles when the payment form is fully loaded.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\thandle_form_loaded() {\n\t\t\tthis.log( 'Payment form loaded' );\n\n\t\t\tthis.payment_form.setPostalCode( $( '#billing_postcode' ).val() );\n\n\t\t\t// hide the postcode field on the checkout page or if it already has a value.\n\t\t\tif ( $( 'form.checkout' ).length || $( '#billing_postcode' ).val() ) {\n\t\t\t\t$( '.wc-square-credit-card-card-postal-code-parent' ).addClass( 'hidden' );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Handles payment form input changes.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object} e\n\t\t */\n\t\thandle_input_event( e ) {\n\t\t\tconst $input = $( '#' + e.elementId );\n\n\t\t\tif ( e.eventType === 'cardBrandChanged' ) {\n\t\t\t\tthis.handle_card_brand_change( e.cardBrand, $input );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Handles card number brand changes.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {string} brand\n\t\t * @param {Object} $input\n\t\t */\n\t\thandle_card_brand_change( brand, $input ) {\n\t\t\tthis.log( `Card brand changed to ${ brand }` );\n\n\t\t\t// clear any existing card type class\n\t\t\t$input.attr( 'class', ( i, c ) => {\n\t\t\t\treturn c.replace( /(^|\\s)card-type-\\S+/g, '' );\n\t\t\t} );\n\n\t\t\tlet card_class = 'plain';\n\n\t\t\tif ( null === brand || 'unknown' === brand ) {\n\t\t\t\tbrand = '';\n\t\t\t}\n\n\t\t\tif ( null !== this.square_card_types[ brand ] ) {\n\t\t\t\tbrand = this.square_card_types[ brand ];\n\t\t\t}\n\n\t\t\tif ( brand && ! this.enabled_card_types.includes( brand ) ) {\n\t\t\t\tcard_class = 'invalid';\n\t\t\t} else {\n\t\t\t\tcard_class = brand;\n\t\t\t}\n\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-card-type]` ).val( brand );\n\n\t\t\t$input.addClass( `card-type-${ card_class }` );\n\t\t}\n\n\t\t/**\n\t\t * Used to request a card nonce and submit the form.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\tvalidate_payment_data() {\n\t\t\tif ( this.form.is( '.processing' ) ) {\n\t\t\t\t// bail when already processing.\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// let through if nonce is already present - nonce is only present on non-tokenized payments.\n\t\t\tif ( this.has_nonce() ) {\n\t\t\t\tthis.log( 'Payment nonce present, placing order' );\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst tokenized_card_id = this.get_tokenized_payment_method_id();\n\n\t\t\tif ( tokenized_card_id ) {\n\t\t\t\tif ( ! this.is_3ds_enabled ) {\n\t\t\t\t\t// if 3DS is disabled and paying with a saved method, no further validation needed.\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif ( this.has_verification_token() ) {\n\t\t\t\t\tthis.log( 'Tokenized payment verification token present, placing order' );\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tthis.log( 'Requesting verification token for tokenized payment' );\n\n\t\t\t\tthis.block_ui();\n\t\t\t\tthis.payment_form.verifyBuyer( tokenized_card_id, this.get_verification_details(), this.handle_verify_buyer_response.bind( this ) );\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis.log( 'Requesting payment nonce' );\n\t\t\tthis.block_ui();\n\t\t\tthis.payment_form.requestCardNonce();\n\t\t\treturn false;\n\t\t}\n\n\t\t/**\n\t\t * Gets the selected tokenized payment method ID, if there is one.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} Tokenized payment method ID.\n\t\t */\n\t\tget_tokenized_payment_method_id() {\n\t\t\treturn $( `.payment_method_${ this.id }` ).find( '.js-wc-square-credit-card-payment-token:checked' ).val();\n\t\t}\n\n\t\t/**\n\t\t * Handles the Square payment form card nonce response.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @param {Object} errors Validation errors, if any.\n\t\t * @param {string} nonce Payment nonce.\n\t\t * @param {Object} cardData Non-confidential info about the card used.\n\t\t */\n\t\thandle_card_nonce_response( errors, nonce, cardData ) {\n\t\t\t// if we have real errors to display from Square.\n\t\t\tif ( errors ) {\n\t\t\t\treturn this.handle_errors( errors );\n\t\t\t}\n\n\t\t\t// no errors, but also no payment data.\n\t\t\tif ( ! nonce ) {\n\t\t\t\tconst message = 'Nonce is missing from the Square response';\n\n\t\t\t\tthis.log( message, 'error' );\n\t\t\t\tthis.log_data( message, 'response' );\n\t\t\t\treturn this.handle_errors();\n\t\t\t}\n\n\t\t\t// if we made it this far, we have payment data.\n\t\t\tthis.log( 'Card data received' );\n\t\t\tthis.log( cardData );\n\t\t\tthis.log_data( cardData, 'response' );\n\n\t\t\tif ( cardData.last_4 ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-last-four]` ).val( cardData.last_4 );\n\t\t\t}\n\n\t\t\tif ( cardData.exp_month ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-exp-month]` ).val( cardData.exp_month );\n\t\t\t}\n\n\t\t\tif ( cardData.exp_year ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-exp-year]` ).val( cardData.exp_year );\n\t\t\t}\n\n\t\t\tif ( cardData.billing_postal_code ) {\n\t\t\t\t$( `input[name=wc-${ this.id_dasherized }-payment-postcode]` ).val( cardData.billing_postal_code );\n\t\t\t}\n\n\t\t\t// payment nonce data.\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-payment-nonce]` ).val( nonce );\n\n\t\t\t// if 3ds is enabled, we need to verify the buyer and record the verification token before continuing.\n\t\t\tif ( this.is_3ds_enabled ) {\n\t\t\t\tthis.log( 'Verifying buyer' );\n\n\t\t\t\tthis.payment_form.verifyBuyer( nonce, this.get_verification_details(), this.handle_verify_buyer_response.bind( this ) );\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// now that we have a nonce, resubmit the form.\n\t\t\tthis.form.trigger( 'submit' );\n\t\t}\n\n\t\t/**\n\t\t * Handles the response from a call to verifyBuyer()\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @param {Object} errors Verification errors, if any.\n\t\t * @param {Object} verification_result Results of verification.\n\t\t */\n\t\thandle_verify_buyer_response( errors, verification_result ) {\n\t\t\tif ( errors ) {\n\t\t\t\t$( errors ).each( ( index, error ) => {\n\t\t\t\t\tif ( ! error.field ) {\n\t\t\t\t\t\terror.field = 'none';\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn this.handle_errors( errors );\n\t\t\t}\n\n\t\t\t// no errors, but also no verification token.\n\t\t\tif ( ! verification_result || ! verification_result.token ) {\n\t\t\t\tconst message = 'Verification token is missing from the Square response';\n\n\t\t\t\tthis.log( message, 'error' );\n\t\t\t\tthis.log_data( message, 'response' );\n\n\t\t\t\treturn this.handle_errors();\n\t\t\t}\n\n\t\t\tthis.log( 'Verification result received' );\n\t\t\tthis.log( verification_result );\n\n\t\t\t$( `input[name=wc-${ this.id_dasherized }-buyer-verification-token]` ).val( verification_result.token );\n\n\t\t\tthis.form.trigger( 'submit' );\n\t\t}\n\n\t\t/**\n\t\t * Gets a verification details object to be used in verifyBuyer()\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {Object} Verification details object.\n\t\t */\n\t\tget_verification_details() {\n\t\t\tconst verification_details = {\n\t\t\t\tbillingContact: {\n\t\t\t\t\tfamilyName: $( '#billing_last_name' ).val() || '',\n\t\t\t\t\tgivenName: $( '#billing_first_name' ).val() || '',\n\t\t\t\t\temail: $( '#billing_email' ).val() || '',\n\t\t\t\t\tcountry: $( '#billing_country' ).val() || '',\n\t\t\t\t\tregion: $( '#billing_state' ).val() || '',\n\t\t\t\t\tcity: $( '#billing_city' ).val() || '',\n\t\t\t\t\tpostalCode: $( '#billing_postcode' ).val() || '',\n\t\t\t\t\tphone: $( '#billing_phone' ).val() || '',\n\t\t\t\t\taddressLines: [ $( '#billing_address_1' ).val() || '', $( '#billing_address_2' ).val() || '' ],\n\t\t\t\t},\n\t\t\t\tintent: this.get_intent(),\n\t\t\t};\n\n\t\t\tif ( 'CHARGE' === verification_details.intent ) {\n\t\t\t\tverification_details.amount = this.get_amount();\n\t\t\t\tverification_details.currencyCode = this.currency_code;\n\t\t\t}\n\n\t\t\tthis.log( verification_details );\n\n\t\t\treturn verification_details;\n\t\t}\n\n\t\t/**\n\t\t * Gets the intent of this processing - either 'CHARGE' or 'STORE'\n\t\t *\n\t\t * The gateway stores cards before processing a payment, so this checks whether the customer checked \"save method\"\n\t\t * at checkout, and isn't otherwise using a saved method already.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} {'CHARGE'|'STORE'}\n\t\t */\n\t\tget_intent() {\n\t\t\tconst $save_method_input = $( '#wc-square-credit-card-tokenize-payment-method' );\n\n\t\t\tlet save_payment_method;\n\n\t\t\tif ( $save_method_input.is( 'input:checkbox' ) ) {\n\t\t\t\tsave_payment_method = $save_method_input.is( ':checked' );\n\t\t\t} else {\n\t\t\t\tsave_payment_method = 'true' === $save_method_input.val();\n\t\t\t}\n\n\t\t\tif ( ! this.get_tokenized_payment_method_id() && save_payment_method ) {\n\t\t\t\treturn 'STORE';\n\t\t\t}\n\n\t\t\treturn 'CHARGE';\n\t\t}\n\n\t\t/**\n\t\t * Gets the amount of this payment.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {string} Payment amount.\n\t\t */\n\t\tget_amount() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-amount]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Handles unsupported browsers.\n\t\t *\n\t\t * @since 2.0.0\n\t\t */\n\t\thandle_unsupported_browser() {}\n\n\t\t/**\n\t\t * Handle error data.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object|null} errors\n\t\t */\n\t\thandle_errors( errors = null ) {\n\t\t\tthis.log( 'Error getting payment data', 'error' );\n\n\t\t\t// clear any previous nonces\n\t\t\t$( 'input[name=wc-square-credit-card-payment-nonce]' ).val( '' );\n\t\t\t$( 'input[name=wc-square-credit-card-buyer-verification-token]' ).val( '' );\n\n\t\t\tconst messages = [];\n\n\t\t\tif ( errors ) {\n\t\t\t\tconst field_order = [ 'none', 'cardNumber', 'expirationDate', 'cvv', 'postalCode' ];\n\n\t\t\t\tif ( errors.length >= 1 ) {\n\t\t\t\t\t// sort based on the field order without the brackets around a.field and b.field.\n\t\t\t\t\t// the precedence is different and gives different results.\n\t\t\t\t\terrors.sort( ( a, b ) => {\n\t\t\t\t\t\treturn field_order.indexOf( a.field ) - field_order.indexOf( b.field );\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t$( errors ).each( ( index, error ) => {\n\t\t\t\t\t// only display the errors that can be helped by the customer.\n\t\t\t\t\tif ( 'UNSUPPORTED_CARD_BRAND' === error.type || 'VALIDATION_ERROR' === error.type ) {\n\t\t\t\t\t\t// To avoid confusion between CSC used in the frontend and CVV that is used in the error message.\n\t\t\t\t\t\treturn messages.push( error.message.replace( /CVV/, 'CSC' ) );\n\t\t\t\t\t}\n\n\t\t\t\t\t// otherwise, log more serious errors to the debug log.\n\t\t\t\t\treturn this.log_data( errors, 'response' );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t// if no specific messages are set, display a general error.\n\t\t\tif ( messages.length === 0 ) {\n\t\t\t\tmessages.push( this.general_error );\n\t\t\t}\n\n\t\t\t// Conditionally process error rendering.\n\t\t\tif ( ! this.is_add_payment_method_page && ! this.is_manual_order_payment ) {\n\t\t\t\tthis.render_checkout_errors( messages );\n\t\t\t} else {\n\t\t\t\tthis.render_errors( messages );\n\t\t\t}\n\n\t\t\tthis.unblock_ui();\n\t\t}\n\n\t\t/**\n\t\t * Public: Render any new errors and bring them into the viewport.\n\t\t *\n\t\t * @param {Array} errors\n\t\t */\n\t\trender_errors( errors ) {\n\t\t\t// hide and remove any previous errors.\n\t\t\t$( '.woocommerce-error, .woocommerce-message' ).remove();\n\n\t\t\t// add errors.\n\t\t\tthis.form.prepend( '<ul class=\"woocommerce-error\"><li>' + errors.join( '</li><li>' ) + '</li></ul>' );\n\n\t\t\t// unblock UI\n\t\t\tthis.form.removeClass( 'processing' ).unblock();\n\t\t\tthis.form.find( '.input-text, select' ).trigger( 'blur' );\n\n\t\t\t// scroll to top\n\t\t\t$( 'html, body' ).animate( {\n\t\t\t\tscrollTop: this.form.offset().top - 100,\n\t\t\t}, 1000 );\n\t\t}\n\n\t\t/**\n\t\t * Blocks the payment form UI.\n\t\t *\n\t\t * @since 3.0.0\n\t\t */\n\t\tblock_ui() {\n\t\t\tthis.form.block( {\n\t\t\t\tmessage: null,\n\t\t\t\toverlayCSS: {\n\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\topacity: 0.6,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Unblocks the payment form UI.\n\t\t *\n\t\t * @since 3.0.0\n\t\t */\n\t\tunblock_ui() {\n\t\t\treturn this.form.unblock();\n\t\t}\n\n\t\t/**\n\t\t * Hides save payment method checkbox.\n\t\t *\n\t\t * @since 2.1.2\n\t\t *\n\t\t * @param {string} id_dasherized\n\t\t */\n\t\thide_save_payment_checkbox( id_dasherized ) {\n\t\t\tconst $parent_row = $( `input.js-wc-${ id_dasherized }-tokenize-payment-method` ).closest( 'p.form-row' );\n\n\t\t\t$parent_row.hide();\n\t\t\t$parent_row.next().hide();\n\t\t}\n\n\t\t/**\n\t\t * Shows save payment method checkbox.\n\t\t *\n\t\t * @since 2.1.2\n\t\t *\n\t\t * @param {string} id_dasherized\n\t\t */\n\t\tshow_save_payment_checkbox( id_dasherized ) {\n\t\t\tconst $parent_row = $( `input.js-wc-${ id_dasherized }-tokenize-payment-method` ).closest( 'p.form-row' );\n\n\t\t\t$parent_row.slideDown();\n\t\t\t$parent_row.next().show();\n\t\t}\n\n\t\t/**\n\t\t * Determines if a nonce is present in the hidden input.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @return {boolean} True if nonce is present, otherwise false.\n\t\t */\n\t\thas_nonce() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-payment-nonce]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Determines if a verification token is present in the hidden input.\n\t\t *\n\t\t * @since 2.1.0\n\t\t *\n\t\t * @return {boolean} True if verification token is present, otherwise false.\n\t\t */\n\t\thas_verification_token() {\n\t\t\treturn $( `input[name=wc-${ this.id_dasherized }-buyer-verification-token]` ).val();\n\t\t}\n\n\t\t/**\n\t\t * Logs data to the debug log via AJAX.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {Object} data Request data.\n\t\t * @param {string} type Data type.\n\t\t */\n\t\tlog_data( data, type ) {\n\t\t\t// if logging is disabled, bail.\n\t\t\tif ( ! this.logging_enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst ajax_data = {\n\t\t\t\taction: 'wc_' + this.id + '_log_js_data',\n\t\t\t\tsecurity: this.ajax_log_nonce,\n\t\t\t\ttype,\n\t\t\t\tdata,\n\t\t\t};\n\n\t\t\t$.ajax( {\n\t\t\t\turl: this.ajax_url,\n\t\t\t\tdata: ajax_data,\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Logs any messages or errors to the console.\n\t\t *\n\t\t * @since 2.0.0\n\t\t *\n\t\t * @param {string} message\n\t\t * @param {string} type Data type.\n\t\t */\n\t\tlog( message, type = 'notice' ) {\n\t\t\t// if logging is disabled, bail.\n\t\t\tif ( ! this.logging_enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( 'error' === type ) {\n\t\t\t\tconsole.error( 'Square Error: ' + message );\n\t\t\t} else {\n\t\t\t\tconsole.log( 'Square: ' + message );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * AJAX validate WooCommerce form data.\n\t\t *\n\t\t * Triggered only if errors are present on Square payment form.\n\t\t *\n\t\t * @since 2.2\n\t\t *\n\t\t * @param {Array} square_errors Square validation errors.\n\t\t */\n\t\trender_checkout_errors( square_errors ) {\n\t\t\tconst ajax_url = wc_cart_fragments_params.wc_ajax_url.toString().replace( '%%endpoint%%', this.id + '_checkout_handler' );\n\t\t\tconst square_handler = this;\n\n\t\t\tconst form_data = this.form.serializeArray();\n\n\t\t\t// Add action field to data for nonce verification.\n\t\t\tform_data.push( {\n\t\t\t\tname: 'wc_' + this.id + '_checkout_validate_nonce',\n\t\t\t\tvalue: this.ajax_wc_checkout_validate_nonce,\n\t\t\t} );\n\n\t\t\treturn $.ajax( {\n\t\t\t\turl: ajax_url,\n\t\t\t\tmethod: 'post',\n\t\t\t\tcache: false,\n\t\t\t\tdata: form_data,\n\t\t\t\tcomplete: ( response ) => {\n\t\t\t\t\tconst result = response.responseJSON;\n\n\t\t\t\t\t// If validation is not triggered and WooCommerce returns failure.\n\t\t\t\t\t// Temporary workaround to fix problems when user email is invalid.\n\t\t\t\t\tif ( result.hasOwnProperty( 'result' ) && 'failure' === result.result ) {\n\t\t\t\t\t\t$( result.messages ).map( ( message ) => {\n\t\t\t\t\t\t\tconst errors = [];\n\n\t\t\t\t\t\t\t$( message ).children( 'li' ).each( () => {\n\t\t\t\t\t\t\t\terrors.push( $( this ).text().trim() );\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\treturn square_errors.unshift( ...errors );\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t// If validation is complete and WooCommerce returns validaiton errors.\n\t\t\t\t\t} else if ( result.hasOwnProperty( 'success' ) && ! result.success ) {\n\t\t\t\t\t\tsquare_errors.unshift( ...result.data.messages );\n\t\t\t\t\t}\n\n\t\t\t\t\tsquare_handler.render_errors( square_errors );\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}\n\n\twindow.WC_Square_Payment_Form_Handler = WC_Square_Payment_Form_Handler;\n} );\n"],"file":"wc-square.min.js"}
i18n/languages/woocommerce-square.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce Square 2.5.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-square\n"
8
- "POT-Creation-Date: 2021-05-13 04:26:05+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Square 2.5.1\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-square\n"
8
+ "POT-Creation-Date: 2021-05-18 04:58:33+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
includes/Plugin.php CHANGED
@@ -42,7 +42,7 @@ class Plugin extends Framework\SV_WC_Payment_Gateway_Plugin {
42
 
43
 
44
  /** plugin version number */
45
- const VERSION = '2.5.0';
46
 
47
  /** plugin ID */
48
  const PLUGIN_ID = 'square';
42
 
43
 
44
  /** plugin version number */
45
+ const VERSION = '2.5.1';
46
 
47
  /** plugin ID */
48
  const PLUGIN_ID = 'square';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: credit card, square, woocommerce, inventory sync
4
  Requires at least: 4.6
5
  Tested up to: 5.7
6
  Requires PHP: 5.6
7
- Stable tag: 2.5.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -71,6 +71,9 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
71
  2. The payment gateway settings.
72
 
73
  == Changelog ==
 
 
 
74
  = 2.5.0 - 2021.05.13 =
75
  * New - Add support for WooCommerce Checkout blocks. PR#604
76
  * New - Add support for Square stores located in Ireland. PR#609
4
  Requires at least: 4.6
5
  Tested up to: 5.7
6
  Requires PHP: 5.6
7
+ Stable tag: 2.5.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
71
  2. The payment gateway settings.
72
 
73
  == Changelog ==
74
+ = 2.5.1 - 2021.05.18 =
75
+ * Fix - Pay for Order and Add Payment Method forms sometimes not working when choosing another payment method other than Square. PR#618
76
+
77
  = 2.5.0 - 2021.05.13 =
78
  * New - Add support for WooCommerce Checkout blocks. PR#604
79
  * New - Add support for Square stores located in Ireland. PR#609
woocommerce-square.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
- * Version: 2.5.0
5
  * Plugin URI: https://woocommerce.com/products/square/
6
  * Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
7
  * Author: WooCommerce
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
+ * Version: 2.5.1
5
  * Plugin URI: https://woocommerce.com/products/square/
6
  * Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
7
  * Author: WooCommerce