WooCommerce Square - Version 2.1.2

Version Description

  • 2020.04.29 =
  • Fix - INTENT_MISMATCH errors when guest customers save a card and registration is disabled.
  • Fix - Improve checkout compatibility with password managers such as 1Password. This also avoids payment for reload on address change.
  • Fix - Pass valid address values even if checkout fields are not present.
  • Tweak - Sandbox mode can be turned on in the settings, no more need for setting the constant.
  • Tweak - Change location URL to refer to our docs.
Download this release

Release Info

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

Code changes from version 2.1.1 to 2.1.2

assets/js/frontend/wc-square.coffee CHANGED
@@ -25,16 +25,18 @@ jQuery( document ).ready ( $ ) ->
25
@enabled_card_types = args.enabled_card_types
26
@square_card_types = args.square_card_types
27
28
- @ajax_log_nonce = args.ajax_log_nonce
29
- @ajax_url = args.ajax_url
30
- @application_id = args.application_id
31
- @currency_code = args.currency_code
32
- @general_error = args.general_error
33
- @input_styles = args.input_styles
34
- @is_3ds_enabled = args.is_3d_secure_enabled
35
- @is_add_payment_method_page = args.is_add_payment_method_page
36
- @location_id = args.location_id
37
- @logging_enabled = args.logging_enabled
38
39
# which payment form?
40
if $( 'form.checkout' ).length
@@ -96,6 +98,7 @@ jQuery( document ).ready ( $ ) ->
96
97
# make available inside change events
98
id_dasherized = @id_dasherized
99
100
$new_payment_method_selection = $( "div.js-wc-#{ id_dasherized }-new-payment-method-form" )
101
@@ -116,19 +119,19 @@ jQuery( document ).ready ( $ ) ->
116
.change()
117
118
# display the 'save payment method' option for guest checkouts if the 'create account' option is checked
119
- # but only hide the input if there is a 'create account' checkbox (some themes just display the password)
120
$( 'input#createaccount' ).change ->
121
- $parent_row = $( "input.js-wc-#{ id_dasherized }-tokenize-payment-method" ).closest( 'p.form-row' )
122
-
123
if $( this ).is( ':checked' )
124
- $parent_row.slideDown()
125
- $parent_row.next().show()
126
else
127
- $parent_row.hide()
128
- $parent_row.next().hide()
129
130
$( 'input#createaccount' ).change() unless $( 'input#createaccount' ).is( ':checked' )
131
132
133
# Public: Handle required actions on the Order > Pay page
134
#
@@ -168,15 +171,20 @@ jQuery( document ).ready ( $ ) ->
168
169
if @payment_form
170
171
- this.log 'Destroying payment form'
172
173
- @payment_form.destroy()
174
175
- this.log 'Building payment form'
176
177
- @payment_form = new SqPaymentForm( this.get_form_params() )
178
179
- @payment_form.build()
180
181
182
# Gets the Square payment form params.
@@ -186,29 +194,31 @@ jQuery( document ).ready ( $ ) ->
186
# @return Object
187
get_form_params: =>
188
189
- $card_number = $( "#wc-#{@id_dasherized}-account-number-hosted" )
190
- $expiration = $( "#wc-#{@id_dasherized}-expiry-hosted" )
191
- $csc = $( "#wc-#{@id_dasherized}-csc-hosted" )
192
- $postal_code = $( "#wc-#{@id_dasherized}-postal-code-hosted" )
193
194
return {
195
applicationId: @application_id,
196
locationId: @location_id,
197
cardNumber: {
198
- elementId: $card_number.attr( 'id' )
199
- placeholder: $card_number.data( 'placeholder' )
200
}
201
expirationDate: {
202
- elementId: $expiration.attr( 'id' )
203
- placeholder: $expiration.data( 'placeholder' )
204
}
205
cvv: {
206
- elementId: $csc.attr( 'id' )
207
- placeholder: $csc.data( 'placeholder' )
208
}
209
postalCode: {
210
- elementId: $postal_code.attr( 'id' )
211
- placeholder: $postal_code.data( 'placeholder' )
212
}
213
inputClass: "wc-#{@id_dasherized}-payment-field"
214
inputStyles: @input_styles
@@ -411,17 +421,17 @@ jQuery( document ).ready ( $ ) ->
411
412
verification_details = {
413
billingContact: {
414
- familyName: $( '#billing_last_name' ).val()
415
- givenName: $( '#billing_first_name' ).val()
416
- email: $( '#billing_email' ).val()
417
- country: $( '#billing_country' ).val()
418
- region: $( '#billing_state' ).val()
419
- city: $( '#billing_city' ).val()
420
- postalCode: $( '#billing_postcode' ).val()
421
- phone: $( '#billing_phone' ).val()
422
addressLines: [
423
- $( '#billing_address_1' ).val(),
424
- $( '#billing_address_2' ).val()
425
]
426
}
427
intent: this.get_intent()
@@ -540,6 +550,23 @@ jQuery( document ).ready ( $ ) ->
540
unblock_ui: -> @form.unblock()
541
542
543
# Determines if a nonce is present in the hidden input.
544
#
545
# @since 2.0.0
25
@enabled_card_types = args.enabled_card_types
26
@square_card_types = args.square_card_types
27
28
+ @ajax_log_nonce = args.ajax_log_nonce
29
+ @ajax_url = args.ajax_url
30
+ @application_id = args.application_id
31
+ @currency_code = args.currency_code
32
+ @general_error = args.general_error
33
+ @input_styles = args.input_styles
34
+ @is_3ds_enabled = args.is_3d_secure_enabled
35
+ @is_add_payment_method_page = args.is_add_payment_method_page
36
+ @is_checkout_registration_enabled = args.is_checkout_registration_enabled
37
+ @is_user_logged_in = args.is_user_logged_in
38
+ @location_id = args.location_id
39
+ @logging_enabled = args.logging_enabled
40
41
# which payment form?
42
if $( 'form.checkout' ).length
98
99
# make available inside change events
100
id_dasherized = @id_dasherized
101
+ form_handler = @
102
103
$new_payment_method_selection = $( "div.js-wc-#{ id_dasherized }-new-payment-method-form" )
104
119
.change()
120
121
# display the 'save payment method' option for guest checkouts if the 'create account' option is checked
122
+ # but only hide the input if there is a 'create account' checkbox (some themes just display the password)
123
$( 'input#createaccount' ).change ->
124
if $( this ).is( ':checked' )
125
+ form_handler.show_save_payment_checkbox id_dasherized
126
else
127
+ form_handler.hide_save_payment_checkbox id_dasherized
128
129
$( 'input#createaccount' ).change() unless $( 'input#createaccount' ).is( ':checked' )
130
131
+ # hide the 'save payment method' when account creation is not enabled and customer is not logged in
132
+ if not @is_user_logged_in and not @is_checkout_registration_enabled
133
+ @hide_save_payment_checkbox id_dasherized
134
+
135
136
# Public: Handle required actions on the Order > Pay page
137
#
171
172
if @payment_form
173
174
+ this.log 'Re-adding payment form'
175
+
176
+ for _, field of @form_fields
177
+ $( field.attr( 'id' ) ).replaceWith( field )
178
179
+ this.handle_form_loaded()
180
181
+ else
182
+
183
+ this.log 'Building payment form'
184
185
+ @payment_form = new SqPaymentForm( this.get_form_params() )
186
187
+ @payment_form.build()
188
189
190
# Gets the Square payment form params.
194
# @return Object
195
get_form_params: =>
196
197
+ @form_fields = {
198
+ card_number: $( "#wc-#{@id_dasherized}-account-number-hosted" )
199
+ expiration: $( "#wc-#{@id_dasherized}-expiry-hosted" )
200
+ csc: $( "#wc-#{@id_dasherized}-csc-hosted" )
201
+ postal_code: $( "#wc-#{@id_dasherized}-postal-code-hosted" )
202
+ }
203
204
return {
205
applicationId: @application_id,
206
locationId: @location_id,
207
cardNumber: {
208
+ elementId: @form_fields.card_number.attr( 'id' )
209
+ placeholder: @form_fields.card_number.data( 'placeholder' )
210
}
211
expirationDate: {
212
+ elementId: @form_fields.expiration.attr( 'id' )
213
+ placeholder: @form_fields.expiration.data( 'placeholder' )
214
}
215
cvv: {
216
+ elementId: @form_fields.csc.attr( 'id' )
217
+ placeholder: @form_fields.csc.data( 'placeholder' )
218
}
219
postalCode: {
220
+ elementId: @form_fields.postal_code.attr( 'id' )
221
+ placeholder: @form_fields.postal_code.data( 'placeholder' )
222
}
223
inputClass: "wc-#{@id_dasherized}-payment-field"
224
inputStyles: @input_styles
421
422
verification_details = {
423
billingContact: {
424
+ familyName: $( '#billing_last_name' ).val() ? ''
425
+ givenName: $( '#billing_first_name' ).val() ? ''
426
+ email: $( '#billing_email' ).val() ? ''
427
+ country: $( '#billing_country' ).val() ? ''
428
+ region: $( '#billing_state' ).val() ? ''
429
+ city: $( '#billing_city' ).val() ? ''
430
+ postalCode: $( '#billing_postcode' ).val() ? ''
431
+ phone: $( '#billing_phone' ).val() ? ''
432
addressLines: [
433
+ $( '#billing_address_1' ).val() ? '',
434
+ $( '#billing_address_2' ).val() ? ''
435
]
436
}
437
intent: this.get_intent()
550
unblock_ui: -> @form.unblock()
551
552
553
+ # Hides save payment method checkbox
554
+ #
555
+ # @since 2.1.2
556
+ hide_save_payment_checkbox: ( id_dasherized ) ->
557
+ $parent_row = $( "input.js-wc-#{ id_dasherized }-tokenize-payment-method" ).closest( 'p.form-row' )
558
+ $parent_row.hide()
559
+ $parent_row.next().hide()
560
+
561
+
562
+ # Shows save payment method checkbox
563
+ #
564
+ # @since 2.1.2
565
+ show_save_payment_checkbox: ( id_dasherized ) ->
566
+ $parent_row = $( "input.js-wc-#{ id_dasherized }-tokenize-payment-method" ).closest( 'p.form-row' )
567
+ $parent_row.slideDown()
568
+ $parent_row.next().show()
569
+
570
# Determines if a nonce is present in the hidden input.
571
#
572
# @since 2.0.0
assets/js/frontend/wc-square.min.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();(function(){var e=[].indexOf;jQuery(document).ready(function(t){return window.WC_Square_Payment_Form_Handler=function(){function n(e){if(_classCallCheck(this,n),this.set_payment_fields=this.set_payment_fields.bind(this),this.get_form_params=this.get_form_params.bind(this),this.handle_input_event=this.handle_input_event.bind(this),this.handle_verify_buyer_response=this.handle_verify_buyer_response.bind(this),this.id=e.id,this.id_dasherized=e.id_dasherized,this.csc_required=e.csc_required,this.enabled_card_types=e.enabled_card_types,this.square_card_types=e.square_card_types,this.ajax_log_nonce=e.ajax_log_nonce,this.ajax_url=e.ajax_url,this.application_id=e.application_id,this.currency_code=e.currency_code,this.general_error=e.general_error,this.input_styles=e.input_styles,this.is_3ds_enabled=e.is_3d_secure_enabled,this.is_add_payment_method_page=e.is_add_payment_method_page,this.location_id=e.location_id,this.logging_enabled=e.logging_enabled,t("form.checkout").length)this.form=t("form.checkout"),this.handle_checkout_page();else if(t("form#order_review").length)this.form=t("form#order_review"),this.handle_pay_page();else{if(!t("form#add_payment_method").length)return void this.log("No payment form found!");this.form=t("form#add_payment_method"),this.handle_add_payment_method_page()}this.params=window.sv_wc_payment_gateway_payment_form_params,t(document.body).on("checkout_error",function(){return t("input[name=wc-square-credit-card-payment-nonce]").val(""),t("input[name=wc-square-credit-card-buyer-verification-token]").val("")}),t(document.body).on("click","#payment_method_"+this.id,function(){if(this.payment_form)return this.log("Recalculating payment form size"),this.payment_form.recalculateSize()})}return _createClass(n,[{key:"handle_checkout_page",value:function(){var e=this;return t(document.body).on("updated_checkout",function(){return e.set_payment_fields()}),t(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),this.form.on("checkout_place_order_"+this.id,function(){return e.validate_payment_data()})}},{key:"handle_saved_payment_methods",value:function(){var e,n;if(n=this.id_dasherized,e=t("div.js-wc-"+n+"-new-payment-method-form"),t("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return t("input.js-wc-"+n+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),t("input#createaccount").change(function(){var e;return e=t("input.js-wc-"+n+"-tokenize-payment-method").closest("p.form-row"),t(this).is(":checked")?(e.slideDown(),e.next().show()):(e.hide(),e.next().hide())}),!t("input#createaccount").is(":checked"))return t("input#createaccount").change()}},{key:"handle_pay_page",value:function(){var e=this;return this.set_payment_fields(),this.handle_saved_payment_methods(),this.form.submit(function(){if(t("#order_review input[name=payment_method]:checked").val()===e.id)return e.validate_payment_data()})}},{key:"handle_add_payment_method_page",value:function(){var e=this;return this.set_payment_fields(),this.form.submit(function(){if(t("#add_payment_method input[name=payment_method]:checked").val()===e.id)return e.validate_payment_data()})}},{key:"set_payment_fields",value:function(){return this.payment_form&&(this.log("Destroying payment form"),this.payment_form.destroy()),this.log("Building payment form"),this.payment_form=new SqPaymentForm(this.get_form_params()),this.payment_form.build()}},{key:"get_form_params",value:function(){var e,n,i,a,r=this;return e=t("#wc-"+this.id_dasherized+"-account-number-hosted"),i=t("#wc-"+this.id_dasherized+"-expiry-hosted"),n=t("#wc-"+this.id_dasherized+"-csc-hosted"),a=t("#wc-"+this.id_dasherized+"-postal-code-hosted"),{applicationId:this.application_id,locationId:this.location_id,cardNumber:{elementId:e.attr("id"),placeholder:e.data("placeholder")},expirationDate:{elementId:i.attr("id"),placeholder:i.data("placeholder")},cvv:{elementId:n.attr("id"),placeholder:n.data("placeholder")},postalCode:{elementId:a.attr("id"),placeholder:a.data("placeholder")},inputClass:"wc-"+this.id_dasherized+"-payment-field",inputStyles:this.input_styles,callbacks:{inputEventReceived:function(e){return r.handle_input_event(e)},cardNonceResponseReceived:function(e,t,n){return r.handle_card_nonce_response(e,t,n)},unsupportedBrowserDetected:function(){return r.handle_unsupported_browser()},paymentFormLoaded:function(){return r.handle_form_loaded()}}}}},{key:"handle_form_loaded",value:function(){if(this.log("Payment form loaded"),this.payment_form.setPostalCode(t("#billing_postcode").val()),t("form.checkout").length||t("#billing_postcode").val())return t(".wc-square-credit-card-card-postal-code-parent").addClass("hidden")}},{key:"handle_input_event",value:function(e){var n;if(n=t("#"+e.elementId),"cardBrandChanged"===e.eventType)return this.handle_card_brand_change(e.cardBrand,n)}},{key:"handle_card_brand_change",value:function(n,i){var a;return this.log("Card brand changed to "+n),i.attr("class",function(e,t){return t.replace(/(^|\s)card-type-\S+/g,"")}),a="plain",null!=n&&"unknown"!==n||(n=""),null!=this.square_card_types[n]&&(n=this.square_card_types[n]),a=n&&e.call(this.enabled_card_types,n)<0?"invalid":n,t("input[name=wc-"+this.id_dasherized+"-card-type]").val(n),i.addClass("card-type-"+a)}},{key:"validate_payment_data",value:function(){var e;return!this.form.is(".processing")&&(this.has_nonce()?(this.log("Payment nonce present, placing order"),!0):(e=this.get_tokenized_payment_method_id())?!this.is_3ds_enabled||(this.has_verification_token()?(this.log("Tokenized payment verification token present, placing order"),!0):(this.log("Requesting verification token for tokenized payment"),this.block_ui(),this.payment_form.verifyBuyer(e,this.get_verification_details(),this.handle_verify_buyer_response),!1)):(this.log("Requesting payment nonce"),this.block_ui(),this.payment_form.requestCardNonce(),!1))}},{key:"get_tokenized_payment_method_id",value:function(){return t(".payment_method_"+this.id).find(".js-wc-square-credit-card-payment-token:checked").val()}},{key:"handle_card_nonce_response",value:function(e,n,i){var a;return e?this.handle_errors(e):n?(this.log("Card data received"),this.log(i),this.log_data(i,"response"),i.last_4&&t("input[name=wc-"+this.id_dasherized+"-last-four]").val(i.last_4),i.exp_month&&t("input[name=wc-"+this.id_dasherized+"-exp-month]").val(i.exp_month),i.exp_year&&t("input[name=wc-"+this.id_dasherized+"-exp-year]").val(i.exp_year),i.billing_postal_code&&t("input[name=wc-square-credit-card-payment-postcode]").val(i.billing_postal_code),t("input[name=wc-"+this.id_dasherized+"-payment-nonce]").val(n),this.is_3ds_enabled?(this.log("Verifying buyer"),void this.payment_form.verifyBuyer(n,this.get_verification_details(),this.handle_verify_buyer_response)):this.form.submit()):(a="Nonce is missing from the Square response",this.log(a,"error"),this.log_data(a,"response"),this.handle_errors())}},{key:"handle_verify_buyer_response",value:function(e,n){var i;return e?this.handle_errors(e):n&&n.token?(this.log("Verification result received"),this.log(n),t("input[name=wc-"+this.id_dasherized+"-buyer-verification-token]").val(n.token),this.form.submit()):(i="Verification token is missing from the Square response",this.log(i,"error"),this.log_data(i,"response"),this.handle_errors())}},{key:"get_verification_details",value:function(){var e;return"CHARGE"===(e={billingContact:{familyName:t("#billing_last_name").val(),givenName:t("#billing_first_name").val(),email:t("#billing_email").val(),country:t("#billing_country").val(),region:t("#billing_state").val(),city:t("#billing_city").val(),postalCode:t("#billing_postcode").val(),phone:t("#billing_phone").val(),addressLines:[t("#billing_address_1").val(),t("#billing_address_2").val()]},intent:this.get_intent()}).intent&&(e.amount=this.get_amount(),e.currencyCode=this.currency_code),this.log(e),e}},{key:"get_intent",value:function(){var e,n;return e=t("#wc-square-credit-card-tokenize-payment-method"),n=e.is("input:checkbox")?e.is(":checked"):"true"===e.val(),!this.get_tokenized_payment_method_id()&&n?"STORE":"CHARGE"}},{key:"get_amount",value:function(){return t("input[name=wc-"+this.id_dasherized+"-amount]").val()}},{key:"handle_unsupported_browser",value:function(){}},{key:"handle_errors",value:function(){var e,n=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.log("Error getting payment data","error"),t("input[name=wc-square-credit-card-payment-nonce]").val(""),t("input[name=wc-square-credit-card-buyer-verification-token]").val(""),e=[],i&&(console.error(i),t(i).each(function(t,a){var r;return"UNSUPPORTED_CARD_BRAND"===(r=a.type)||"VALIDATION_ERROR"===r?e.push(a.message):n.log_data(i,"response")})),0===e.length&&e.push(this.general_error),this.render_errors(e),this.unblock_ui()}},{key:"render_errors",value:function(e){return t(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<ul class="woocommerce-error"><li>'+e.join("</li><li>")+"</li></ul>"),this.form.removeClass("processing").unblock(),this.form.find(".input-text, select").blur(),t("html, body").animate({scrollTop:this.form.offset().top-100},1e3)}},{key:"block_ui",value:function(){return this.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.form.unblock()}},{key:"has_nonce",value:function(){return t("input[name=wc-"+this.id_dasherized+"-payment-nonce]").val()}},{key:"has_verification_token",value:function(){return t("input[name=wc-"+this.id_dasherized+"-buyer-verification-token]").val()}},{key:"log_data",value:function(e,n){var i;if(this.logging_enabled)return i={action:"wc_"+this.id+"_log_js_data",security:this.ajax_log_nonce,type:n,data:e},t.ajax({url:this.ajax_url,data:i})}},{key:"log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notice";if(this.logging_enabled)return"error"===t?console.error("Square Error: "+e):console.log("Square: "+e)}}]),n}()})}).call(void 0);
2
//# sourceMappingURL=wc-square.min.js.map
1
+ "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();(function(){var e=[].indexOf;jQuery(document).ready(function(t){return window.WC_Square_Payment_Form_Handler=function(){function n(e){if(_classCallCheck(this,n),this.set_payment_fields=this.set_payment_fields.bind(this),this.get_form_params=this.get_form_params.bind(this),this.handle_input_event=this.handle_input_event.bind(this),this.handle_verify_buyer_response=this.handle_verify_buyer_response.bind(this),this.id=e.id,this.id_dasherized=e.id_dasherized,this.csc_required=e.csc_required,this.enabled_card_types=e.enabled_card_types,this.square_card_types=e.square_card_types,this.ajax_log_nonce=e.ajax_log_nonce,this.ajax_url=e.ajax_url,this.application_id=e.application_id,this.currency_code=e.currency_code,this.general_error=e.general_error,this.input_styles=e.input_styles,this.is_3ds_enabled=e.is_3d_secure_enabled,this.is_add_payment_method_page=e.is_add_payment_method_page,this.is_checkout_registration_enabled=e.is_checkout_registration_enabled,this.is_user_logged_in=e.is_user_logged_in,this.location_id=e.location_id,this.logging_enabled=e.logging_enabled,t("form.checkout").length)this.form=t("form.checkout"),this.handle_checkout_page();else if(t("form#order_review").length)this.form=t("form#order_review"),this.handle_pay_page();else{if(!t("form#add_payment_method").length)return void this.log("No payment form found!");this.form=t("form#add_payment_method"),this.handle_add_payment_method_page()}this.params=window.sv_wc_payment_gateway_payment_form_params,t(document.body).on("checkout_error",function(){return t("input[name=wc-square-credit-card-payment-nonce]").val(""),t("input[name=wc-square-credit-card-buyer-verification-token]").val("")}),t(document.body).on("click","#payment_method_"+this.id,function(){if(this.payment_form)return this.log("Recalculating payment form size"),this.payment_form.recalculateSize()})}return _createClass(n,[{key:"handle_checkout_page",value:function(){var e=this;return t(document.body).on("updated_checkout",function(){return e.set_payment_fields()}),t(document.body).on("updated_checkout",function(){return e.handle_saved_payment_methods()}),this.form.on("checkout_place_order_"+this.id,function(){return e.validate_payment_data()})}},{key:"handle_saved_payment_methods",value:function(){var e,n,i;if(i=this.id_dasherized,n=this,e=t("div.js-wc-"+i+"-new-payment-method-form"),t("input.js-wc-"+this.id_dasherized+"-payment-token").change(function(){return t("input.js-wc-"+i+"-payment-token:checked").val()?e.slideUp(200):e.slideDown(200)}).change(),t("input#createaccount").change(function(){return t(this).is(":checked")?n.show_save_payment_checkbox(i):n.hide_save_payment_checkbox(i)}),t("input#createaccount").is(":checked")||t("input#createaccount").change(),!this.is_user_logged_in&&!this.is_checkout_registration_enabled)return this.hide_save_payment_checkbox(i)}},{key:"handle_pay_page",value:function(){var e=this;return this.set_payment_fields(),this.handle_saved_payment_methods(),this.form.submit(function(){if(t("#order_review input[name=payment_method]:checked").val()===e.id)return e.validate_payment_data()})}},{key:"handle_add_payment_method_page",value:function(){var e=this;return this.set_payment_fields(),this.form.submit(function(){if(t("#add_payment_method input[name=payment_method]:checked").val()===e.id)return e.validate_payment_data()})}},{key:"set_payment_fields",value:function(){var e,n,i;if(this.payment_form){this.log("Re-adding payment form"),i=this.form_fields;for(e in i)n=i[e],t(n.attr("id")).replaceWith(n);return this.handle_form_loaded()}return this.log("Building payment form"),this.payment_form=new SqPaymentForm(this.get_form_params()),this.payment_form.build()}},{key:"get_form_params",value:function(){var e=this;return this.form_fields={card_number:t("#wc-"+this.id_dasherized+"-account-number-hosted"),expiration:t("#wc-"+this.id_dasherized+"-expiry-hosted"),csc:t("#wc-"+this.id_dasherized+"-csc-hosted"),postal_code:t("#wc-"+this.id_dasherized+"-postal-code-hosted")},{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-"+this.id_dasherized+"-payment-field",inputStyles:this.input_styles,callbacks:{inputEventReceived:function(t){return e.handle_input_event(t)},cardNonceResponseReceived:function(t,n,i){return e.handle_card_nonce_response(t,n,i)},unsupportedBrowserDetected:function(){return e.handle_unsupported_browser()},paymentFormLoaded:function(){return e.handle_form_loaded()}}}}},{key:"handle_form_loaded",value:function(){if(this.log("Payment form loaded"),this.payment_form.setPostalCode(t("#billing_postcode").val()),t("form.checkout").length||t("#billing_postcode").val())return t(".wc-square-credit-card-card-postal-code-parent").addClass("hidden")}},{key:"handle_input_event",value:function(e){var n;if(n=t("#"+e.elementId),"cardBrandChanged"===e.eventType)return this.handle_card_brand_change(e.cardBrand,n)}},{key:"handle_card_brand_change",value:function(n,i){var a;return this.log("Card brand changed to "+n),i.attr("class",function(e,t){return t.replace(/(^|\s)card-type-\S+/g,"")}),a="plain",null!=n&&"unknown"!==n||(n=""),null!=this.square_card_types[n]&&(n=this.square_card_types[n]),a=n&&e.call(this.enabled_card_types,n)<0?"invalid":n,t("input[name=wc-"+this.id_dasherized+"-card-type]").val(n),i.addClass("card-type-"+a)}},{key:"validate_payment_data",value:function(){var e;return!this.form.is(".processing")&&(this.has_nonce()?(this.log("Payment nonce present, placing order"),!0):(e=this.get_tokenized_payment_method_id())?!this.is_3ds_enabled||(this.has_verification_token()?(this.log("Tokenized payment verification token present, placing order"),!0):(this.log("Requesting verification token for tokenized payment"),this.block_ui(),this.payment_form.verifyBuyer(e,this.get_verification_details(),this.handle_verify_buyer_response),!1)):(this.log("Requesting payment nonce"),this.block_ui(),this.payment_form.requestCardNonce(),!1))}},{key:"get_tokenized_payment_method_id",value:function(){return t(".payment_method_"+this.id).find(".js-wc-square-credit-card-payment-token:checked").val()}},{key:"handle_card_nonce_response",value:function(e,n,i){var a;return e?this.handle_errors(e):n?(this.log("Card data received"),this.log(i),this.log_data(i,"response"),i.last_4&&t("input[name=wc-"+this.id_dasherized+"-last-four]").val(i.last_4),i.exp_month&&t("input[name=wc-"+this.id_dasherized+"-exp-month]").val(i.exp_month),i.exp_year&&t("input[name=wc-"+this.id_dasherized+"-exp-year]").val(i.exp_year),i.billing_postal_code&&t("input[name=wc-square-credit-card-payment-postcode]").val(i.billing_postal_code),t("input[name=wc-"+this.id_dasherized+"-payment-nonce]").val(n),this.is_3ds_enabled?(this.log("Verifying buyer"),void this.payment_form.verifyBuyer(n,this.get_verification_details(),this.handle_verify_buyer_response)):this.form.submit()):(a="Nonce is missing from the Square response",this.log(a,"error"),this.log_data(a,"response"),this.handle_errors())}},{key:"handle_verify_buyer_response",value:function(e,n){var i;return e?this.handle_errors(e):n&&n.token?(this.log("Verification result received"),this.log(n),t("input[name=wc-"+this.id_dasherized+"-buyer-verification-token]").val(n.token),this.form.submit()):(i="Verification token is missing from the Square response",this.log(i,"error"),this.log_data(i,"response"),this.handle_errors())}},{key:"get_verification_details",value:function(){var e,n,i,a,r,o,s,d,l,_,c;return"CHARGE"===(c={billingContact:{familyName:null!=(e=t("#billing_last_name").val())?e:"",givenName:null!=(n=t("#billing_first_name").val())?n:"",email:null!=(i=t("#billing_email").val())?i:"",country:null!=(a=t("#billing_country").val())?a:"",region:null!=(r=t("#billing_state").val())?r:"",city:null!=(o=t("#billing_city").val())?o:"",postalCode:null!=(s=t("#billing_postcode").val())?s:"",phone:null!=(d=t("#billing_phone").val())?d:"",addressLines:[null!=(l=t("#billing_address_1").val())?l:"",null!=(_=t("#billing_address_2").val())?_:""]},intent:this.get_intent()}).intent&&(c.amount=this.get_amount(),c.currencyCode=this.currency_code),this.log(c),c}},{key:"get_intent",value:function(){var e,n;return e=t("#wc-square-credit-card-tokenize-payment-method"),n=e.is("input:checkbox")?e.is(":checked"):"true"===e.val(),!this.get_tokenized_payment_method_id()&&n?"STORE":"CHARGE"}},{key:"get_amount",value:function(){return t("input[name=wc-"+this.id_dasherized+"-amount]").val()}},{key:"handle_unsupported_browser",value:function(){}},{key:"handle_errors",value:function(){var e,n=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.log("Error getting payment data","error"),t("input[name=wc-square-credit-card-payment-nonce]").val(""),t("input[name=wc-square-credit-card-buyer-verification-token]").val(""),e=[],i&&(console.error(i),t(i).each(function(t,a){var r;return"UNSUPPORTED_CARD_BRAND"===(r=a.type)||"VALIDATION_ERROR"===r?e.push(a.message):n.log_data(i,"response")})),0===e.length&&e.push(this.general_error),this.render_errors(e),this.unblock_ui()}},{key:"render_errors",value:function(e){return t(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('<ul class="woocommerce-error"><li>'+e.join("</li><li>")+"</li></ul>"),this.form.removeClass("processing").unblock(),this.form.find(".input-text, select").blur(),t("html, body").animate({scrollTop:this.form.offset().top-100},1e3)}},{key:"block_ui",value:function(){return this.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.form.unblock()}},{key:"hide_save_payment_checkbox",value:function(e){var n;return(n=t("input.js-wc-"+e+"-tokenize-payment-method").closest("p.form-row")).hide(),n.next().hide()}},{key:"show_save_payment_checkbox",value:function(e){var n;return(n=t("input.js-wc-"+e+"-tokenize-payment-method").closest("p.form-row")).slideDown(),n.next().show()}},{key:"has_nonce",value:function(){return t("input[name=wc-"+this.id_dasherized+"-payment-nonce]").val()}},{key:"has_verification_token",value:function(){return t("input[name=wc-"+this.id_dasherized+"-buyer-verification-token]").val()}},{key:"log_data",value:function(e,n){var i;if(this.logging_enabled)return i={action:"wc_"+this.id+"_log_js_data",security:this.ajax_log_nonce,type:n,data:e},t.ajax({url:this.ajax_url,data:i})}},{key:"log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notice";if(this.logging_enabled)return"error"===t?console.error("Square Error: "+e):console.log("Square: "+e)}}]),n}()})}).call(void 0);
2
//# sourceMappingURL=wc-square.min.js.map
assets/js/frontend/wc-square.min.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["wc-square.min.js"],"names":["_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","protoProps","staticProps","prototype","indexOf","jQuery","document","ready","quot;,"window","WC_Square_Payment_Form_Handler","args","this","set_payment_fields","bind","get_form_params","handle_input_event","handle_verify_buyer_response","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","location_id","logging_enabled","form","handle_checkout_page","handle_pay_page","log","handle_add_payment_method_page","params","body","on","val","payment_form","recalculateSize","value","_this","handle_saved_payment_methods","validate_payment_data","$new_payment_method_selection","change","slideUp","slideDown","$parent_row","closest","is","next","show","hide","_this2","submit","_this3","destroy","SqPaymentForm","build","$card_number","$csc","$expiration","$postal_code","_this4","applicationId","locationId","cardNumber","elementId","attr","placeholder","data","expirationDate","cvv","postalCode","inputClass","inputStyles","callbacks","inputEventReceived","event","cardNonceResponseReceived","errors","nonce","cardData","handle_card_nonce_response","unsupportedBrowserDetected","handle_unsupported_browser","paymentFormLoaded","handle_form_loaded","setPostalCode","addClass","$input","eventType","handle_card_brand_change","cardBrand","brand","card_class","c","replace","call","tokenized_card_id","has_nonce","get_tokenized_payment_method_id","has_verification_token","block_ui","verifyBuyer","get_verification_details","requestCardNonce","find","message","handle_errors","log_data","last_4","exp_month","exp_year","billing_postal_code","verification_result","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","_this5","arguments","undefined","console","error","each","index","ref","type","push","render_errors","unblock_ui","remove","prepend","join","removeClass","unblock","blur","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","ajax_data","action","security","ajax","url"],"mappings":"AAAA,aAIA,SAASA,gBAAgBC,EAAUC,GAAe,KAAMD,aAAoBC,GAAgB,MAAM,IAAIC,UAAU,qCAFhH,IAAIC,aAAe,WAAc,SAASC,EAAiBC,EAAQC,GAAS,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CAAE,IAAIE,EAAaH,EAAMC,GAAIE,EAAWC,WAAaD,EAAWC,aAAc,EAAOD,EAAWE,cAAe,EAAU,UAAWF,IAAYA,EAAWG,UAAW,GAAMC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAAiB,OAAO,SAAUR,EAAae,EAAYC,GAAiJ,OAA9HD,GAAY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iBAAmB/B,GAEjC8B,QAAQ3G,IAAI,WAAa6E,OAK/BxG,EApoBsC,OAuoBhD8F,UAAKuC","file":"wc-square.min.js"}
1
+ {"version":3,"sources":["wc-square.min.js"],"names":["_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","protoProps","staticProps","prototype","indexOf","jQuery","document","ready","quot;,"window","WC_Square_Payment_Form_Handler","args","this","set_payment_fields","bind","get_form_params","handle_input_event","handle_verify_buyer_response","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","form","handle_checkout_page","handle_pay_page","log","handle_add_payment_method_page","params","body","on","val","payment_form","recalculateSize","value","_this","handle_saved_payment_methods","validate_payment_data","$new_payment_method_selection","form_handler","change","slideUp","slideDown","is","show_save_payment_checkbox","hide_save_payment_checkbox","_this2","submit","_this3","_","field","ref","form_fields","attr","replaceWith","handle_form_loaded","SqPaymentForm","build","_this4","card_number","expiration","csc","postal_code","applicationId","locationId","cardNumber","elementId","placeholder","data","expirationDate","cvv","postalCode","inputClass","inputStyles","callbacks","inputEventReceived","event","cardNonceResponseReceived","errors","nonce","cardData","handle_card_nonce_response","unsupportedBrowserDetected","handle_unsupported_browser","paymentFormLoaded","setPostalCode","addClass","$input","eventType","handle_card_brand_change","cardBrand","brand","card_class","c","replace","call","tokenized_card_id","has_nonce","get_tokenized_payment_method_id","has_verification_token","block_ui","verifyBuyer","get_verification_details","requestCardNonce","find","message","handle_errors","log_data","last_4","exp_month","exp_year","billing_postal_code","verification_result","token","ref1","ref2","ref3","ref4","ref5","ref6","ref7","ref8","ref9","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","_this5","arguments","undefined","console","error","each","index","type","push","render_errors","unblock_ui","remove","prepend","join","removeClass","unblock","blur","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","$parent_row","closest","hide","next","show","ajax_data","action","security","ajax","url"],"mappings":"AAAA,aAIA,SAASA,gBAAgBC,EAAUC,GAAe,KAAMD,aAAoBC,GAAgB,MAAM,IAAIC,UAAU,qCAFhH,IAAIC,aAAe,WAAc,SAASC,EAAiBC,EAAQC,GAAS,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CAAE,IAAIE,EAAaH,EAAMC,GAAIE,EAAWC,WAAaD,EAAWC,aAAc,EAAOD,EAAWE,cAAe,EAAU,UAAWF,IAAYA,EAAWG,UAAW,GAAMC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAAiB,OAAO,SAAUR,EAAae,EAAYC,GAAiJ,OAA9HD,GAAYZ,EAAiBH,EAAYiB,UAAWF,GAAiBC,GAAab,EAAiBH,EAAagB,GAAqBhB,GAA7gB,IAInB,WAME,IAAIkB,KAAaA,QAEjBC,OAAOC,UAAUC,MAAM,SAAUC,GAM/B,OAAOC,OAAOC,+BAAiC,WAI7C,SAASA,EAA+BC,GA0CtC,GAzCA3B,gBAAgB4B,KAAMF,GAKtBE,KAAKC,mBAAqBD,KAAKC,mBAAmBC,KAAKF,MAMvDA,KAAKG,gBAAkBH,KAAKG,gBAAgBD,KAAKF,MAIjDA,KAAKI,mBAAqBJ,KAAKI,mBAAmBF,KAAKF,MAOvDA,KAAKK,6BAA+BL,KAAKK,6BAA6BH,KAAKF,MAC3EA,KAAKM,GAAKP,EAAKO,GACfN,KAAKO,cAAgBR,EAAKQ,cAC1BP,KAAKQ,aAAeT,EAAKS,aACzBR,KAAKS,mBAAqBV,EAAKU,mBAC/BT,KAAKU,kBAAoBX,EAAKW,kBAC9BV,KAAKW,eAAiBZ,EAAKY,eAC3BX,KAAKY,SAAWb,EAAKa,SACrBZ,KAAKa,eAAiBd,EAAKc,eAC3Bb,KAAKc,cAAgB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ACEC,OAAU,MAAQ7K,KAAKM,GAAK,eAC5BwK,SAAY9K,KAAKW,eACjB0I,KAAQA,EACRhF,KAAQA,GAEHzE,EAAEmL,MACPC,IAAKhL,KAAKY,SACVyD,KAAMuG,OASVxL,IAAK,MACL+C,MAAO,SAAauE,GAClB,IAAI2C,EAAON,UAAUlK,OAAS,QAAsBmK,IAAjBD,UAAU,GAAmBA,UAAU,GAAK,SAG/E,GAAK/I,KAAKuB,gBAGV,MAAa,UAAT8H,EACKJ,QAAQC,MAAM,iBAAmBxC,GAEjCuC,QAAQtH,IAAI,WAAa+E,OAK/B5G,EAzqBsC,OA4qBhDkG,UAAKgD","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.1.1\n"
6
"Report-Msgid-Bugs-To: "
7
"https://github.com/woocommerce/woocommerce-square/issues\n"
8
- "POT-Creation-Date: 2020-03-20 15:35:44+00:00\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=utf-8\n"
11
"Content-Transfer-Encoding: 8bit\n"
@@ -65,7 +65,7 @@ msgid "No sync job in progress found %s"
65
msgstr ""
66
67
#: includes/Admin/Privacy.php:46 includes/Admin/Settings_Page.php:55
68
- #: includes/Gateway.php:58 includes/Settings.php:183 includes/Settings.php:666
69
msgid "Square"
70
msgstr ""
71
@@ -117,7 +117,7 @@ msgstr ""
117
msgid "Cancel"
118
msgstr ""
119
120
- #: includes/Admin/Settings_Page.php:185 includes/Settings.php:204
121
msgid "Import Products"
122
msgstr ""
123
@@ -309,7 +309,7 @@ msgstr ""
309
msgid "Enable to push inventory changes to Square"
310
msgstr ""
311
312
- #: includes/Admin.php:159 includes/Settings.php:193
313
msgid "Inventory is fetched from Square periodically and updated in WooCommerce"
314
msgstr ""
315
@@ -397,7 +397,7 @@ msgstr ""
397
msgid "Inspect status logs"
398
msgstr ""
399
400
- #: includes/Emails/Sync_Completed.php:123 includes/Settings.php:229
401
msgid "Enable Logging"
402
msgstr ""
403
@@ -488,7 +488,7 @@ msgid ""
488
"Import Products from Square settings."
489
msgstr ""
490
491
- #: includes/Handlers/Product.php:344
492
msgid "Product not synced with Square"
493
msgstr ""
494
@@ -689,30 +689,44 @@ msgid ""
689
"accept credit and debit card payments at checkout."
690
msgstr ""
691
692
- #: includes/Settings.php:136
693
msgid "Sandbox settings"
694
msgstr ""
695
696
- #: includes/Settings.php:139
697
#. translators: Placeholders: %1$s - URL
698
msgid "Sandbox details can be created at: %s"
699
msgstr ""
700
701
- #: includes/Settings.php:145
702
msgid "Sandbox Application ID"
703
msgstr ""
704
705
- #: includes/Settings.php:146
706
msgid ""
707
"Application ID for the Sandbox Application, see the details in the My "
708
"Applications section."
709
msgstr ""
710
711
- #: includes/Settings.php:150
712
msgid "Sandbox Access Token"
713
msgstr ""
714
715
- #: includes/Settings.php:151
716
msgid ""
717
"Access Token for the Sandbox Test Account, see the details in the Sandbox "
718
"Test Account section. Make sure you use the correct Sandbox Access Token "
@@ -720,11 +734,11 @@ msgid ""
720
"Application is assigned a different Access Token."
721
msgstr ""
722
723
- #: includes/Settings.php:159
724
msgid "Business location"
725
msgstr ""
726
727
- #: includes/Settings.php:164
728
#. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
729
#. <a> tag, %4$s - </a> tag
730
msgid ""
@@ -733,11 +747,11 @@ msgid ""
733
"linked."
734
msgstr ""
735
736
- #: includes/Settings.php:172
737
msgid "Product system of record"
738
msgstr ""
739
740
- #: includes/Settings.php:177
741
#. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
742
#. <a> tag, %4$s - </a> tag
743
msgid ""
@@ -746,7 +760,7 @@ msgid ""
746
"here%4$s to read more about choosing a system of record."
747
msgstr ""
748
749
- #: includes/Settings.php:182
750
msgid "Do not sync product data"
751
msgstr ""
752
@@ -754,49 +768,49 @@ msgstr ""
754
msgid "WooCommerce"
755
msgstr ""
756
757
- #: includes/Settings.php:190
758
msgid "Sync inventory"
759
msgstr ""
760
761
- #: includes/Settings.php:191
762
msgid "Enable to sync product inventory with Square"
763
msgstr ""
764
765
- #: includes/Settings.php:197
766
msgid "Handle missing products"
767
msgstr ""
768
769
- #: includes/Settings.php:198
770
msgid "Hide synced products when not found in Square"
771
msgstr ""
772
773
- #: includes/Settings.php:200
774
msgid ""
775
"Products not found in Square will be hidden in the WooCommerce product "
776
"catalog."
777
msgstr ""
778
779
- #: includes/Settings.php:206
780
msgid ""
781
"Run an import to create new products in this WooCommerce store for each new "
782
"product created in Square that has a unique SKU not existing in here. Needs "
783
"to be run each time new items are created in Square."
784
msgstr ""
785
786
- #: includes/Settings.php:216
787
msgid "Connection"
788
msgstr ""
789
790
- #: includes/Settings.php:233
791
#. translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag
792
msgid "Log debug messages to the %1$sWooCommerce status log%2$s"
793
msgstr ""
794
795
- #: includes/Settings.php:260
796
msgid "Please choose a location"
797
msgstr ""
798
799
- #: includes/Settings.php:290
800
msgid "Import all products from Square"
801
msgstr ""
802
@@ -3250,4 +3264,4 @@ msgstr ""
3250
#. translators: https:www.skyverge.com/for-translators-environments/
3251
msgctxt "software environment"
3252
msgid "Production"
3253
- msgstr ""
2
# This file is distributed under the GNU General Public License v3.0.
3
msgid ""
4
msgstr ""
5
+ "Project-Id-Version: WooCommerce Square 2.1.2\n"
6
"Report-Msgid-Bugs-To: "
7
"https://github.com/woocommerce/woocommerce-square/issues\n"
8
+ "POT-Creation-Date: 2020-04-29 12:51:37+00:00\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=utf-8\n"
11
"Content-Transfer-Encoding: 8bit\n"
65
msgstr ""
66
67
#: includes/Admin/Privacy.php:46 includes/Admin/Settings_Page.php:55
68
+ #: includes/Gateway.php:58 includes/Settings.php:190 includes/Settings.php:673
69
msgid "Square"
70
msgstr ""
71
117
msgid "Cancel"
118
msgstr ""
119
120
+ #: includes/Admin/Settings_Page.php:185 includes/Settings.php:211
121
msgid "Import Products"
122
msgstr ""
123
309
msgid "Enable to push inventory changes to Square"
310
msgstr ""
311
312
+ #: includes/Admin.php:159 includes/Settings.php:200
313
msgid "Inventory is fetched from Square periodically and updated in WooCommerce"
314
msgstr ""
315
397
msgid "Inspect status logs"
398
msgstr ""
399
400
+ #: includes/Emails/Sync_Completed.php:123 includes/Settings.php:236
401
msgid "Enable Logging"
402
msgstr ""
403
488
"Import Products from Square settings."
489
msgstr ""
490
491
+ #: includes/Handlers/Product.php:351
492
msgid "Product not synced with Square"
493
msgstr ""
494
689
"accept credit and debit card payments at checkout."
690
msgstr ""
691
692
+ #: includes/Settings.php:134
693
+ msgid "Enable Sandbox Mode"
694
+ msgstr ""
695
+
696
+ #: includes/Settings.php:135
697
+ msgid "Enable to set the plugin in sandbox mode."
698
+ msgstr ""
699
+
700
+ #: includes/Settings.php:137
701
+ msgid ""
702
+ "After enabling you’ll see a new Sandbox settings section with two fields; "
703
+ "Sandbox Application ID & Sandbox Access Token."
704
+ msgstr ""
705
+
706
+ #: includes/Settings.php:143
707
msgid "Sandbox settings"
708
msgstr ""
709
710
+ #: includes/Settings.php:146
711
#. translators: Placeholders: %1$s - URL
712
msgid "Sandbox details can be created at: %s"
713
msgstr ""
714
715
+ #: includes/Settings.php:152
716
msgid "Sandbox Application ID"
717
msgstr ""
718
719
+ #: includes/Settings.php:153
720
msgid ""
721
"Application ID for the Sandbox Application, see the details in the My "
722
"Applications section."
723
msgstr ""
724
725
+ #: includes/Settings.php:157
726
msgid "Sandbox Access Token"
727
msgstr ""
728
729
+ #: includes/Settings.php:158
730
msgid ""
731
"Access Token for the Sandbox Test Account, see the details in the Sandbox "
732
"Test Account section. Make sure you use the correct Sandbox Access Token "
734
"Application is assigned a different Access Token."
735
msgstr ""
736
737
+ #: includes/Settings.php:166
738
msgid "Business location"
739
msgstr ""
740
741
+ #: includes/Settings.php:171
742
#. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
743
#. <a> tag, %4$s - </a> tag
744
msgid ""
747
"linked."
748
msgstr ""
749
750
+ #: includes/Settings.php:179
751
msgid "Product system of record"
752
msgstr ""
753
754
+ #: includes/Settings.php:184
755
#. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
756
#. <a> tag, %4$s - </a> tag
757
msgid ""
760
"here%4$s to read more about choosing a system of record."
761
msgstr ""
762
763
+ #: includes/Settings.php:189
764
msgid "Do not sync product data"
765
msgstr ""
766
768
msgid "WooCommerce"
769
msgstr ""
770
771
+ #: includes/Settings.php:197
772
msgid "Sync inventory"
773
msgstr ""
774
775
+ #: includes/Settings.php:198
776
msgid "Enable to sync product inventory with Square"
777
msgstr ""
778
779
+ #: includes/Settings.php:204
780
msgid "Handle missing products"
781
msgstr ""
782
783
+ #: includes/Settings.php:205
784
msgid "Hide synced products when not found in Square"
785
msgstr ""
786
787
+ #: includes/Settings.php:207
788
msgid ""
789
"Products not found in Square will be hidden in the WooCommerce product "
790
"catalog."
791
msgstr ""
792
793
+ #: includes/Settings.php:213
794
msgid ""
795
"Run an import to create new products in this WooCommerce store for each new "
796
"product created in Square that has a unique SKU not existing in here. Needs "
797
"to be run each time new items are created in Square."
798
msgstr ""
799
800
+ #: includes/Settings.php:223
801
msgid "Connection"
802
msgstr ""
803
804
+ #: includes/Settings.php:240
805
#. translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag
806
msgid "Log debug messages to the %1$sWooCommerce status log%2$s"
807
msgstr ""
808
809
+ #: includes/Settings.php:267
810
msgid "Please choose a location"
811
msgstr ""
812
813
+ #: includes/Settings.php:297
814
msgid "Import all products from Square"
815
msgstr ""
816
3264
#. translators: https:www.skyverge.com/for-translators-environments/
3265
msgctxt "software environment"
3266
msgid "Production"
3267
+ msgstr ""
includes/Gateway/Payment_Form.php CHANGED
@@ -195,18 +195,20 @@ class Payment_Form extends Framework\SV_WC_Payment_Gateway_Payment_Form {
195
public function render_js() {
196
197
$args = [
198
- 'application_id' => $this->get_gateway()->get_application_id(),
199
- 'ajax_log_nonce' => wp_create_nonce( 'wc_' . $this->get_gateway()->get_id() . '_log_js_data' ),
200
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
201
- 'csc_required' => $this->get_gateway()->csc_enabled(),
202
- 'currency_code' => get_woocommerce_currency(),
203
- 'general_error' => __( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
204
- 'id' => $this->get_gateway()->get_id(),
205
- 'id_dasherized' => $this->get_gateway()->get_id_dasherized(),
206
- 'is_3d_secure_enabled' => $this->get_gateway()->is_3d_secure_enabled(),
207
- 'is_add_payment_method_page' => is_add_payment_method_page(),
208
- 'location_id' => wc_square()->get_settings_handler()->get_location_id(),
209
- 'logging_enabled' => $this->get_gateway()->debug_log(),
210
];
211
212
// map the unique square card type string to our framework standards
195
public function render_js() {
196
197
$args = [
198
+ 'application_id' => $this->get_gateway()->get_application_id(),
199
+ 'ajax_log_nonce' => wp_create_nonce( 'wc_' . $this->get_gateway()->get_id() . '_log_js_data' ),
200
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
201
+ 'csc_required' => $this->get_gateway()->csc_enabled(),
202
+ 'currency_code' => get_woocommerce_currency(),
203
+ 'general_error' => __( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
204
+ 'id' => $this->get_gateway()->get_id(),
205
+ 'id_dasherized' => $this->get_gateway()->get_id_dasherized(),
206
+ 'is_3d_secure_enabled' => $this->get_gateway()->is_3d_secure_enabled(),
207
+ 'is_checkout_registration_enabled' => 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout', 'no' ),
208
+ 'is_user_logged_in' => is_user_logged_in(),
209
+ 'is_add_payment_method_page' => is_add_payment_method_page(),
210
+ 'location_id' => wc_square()->get_settings_handler()->get_location_id(),
211
+ 'logging_enabled' => $this->get_gateway()->debug_log(),
212
];
213
214
// map the unique square card type string to our framework standards
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.1.1';
46
47
/** plugin ID */
48
const PLUGIN_ID = 'square';
42
43
44
/** plugin version number */
45
+ const VERSION = '2.1.2';
46
47
/** plugin ID */
48
const PLUGIN_ID = 'square';
includes/Settings.php CHANGED
@@ -130,6 +130,13 @@ class Settings extends \WC_Settings_API {
130
],
131
];
132
133
if ( $this->is_sandbox() ) {
134
$fields['sandbox_settings'] = [
135
'type' => 'title',
@@ -163,7 +170,7 @@ class Settings extends \WC_Settings_API {
163
/* translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s - <a> tag, %4$s - </a> tag */
164
__( 'Select a location to link to this site. Only %1$sactive%2$s %3$slocations%4$s that support credit card processing in Square can be linked.', 'woocommerce-square' ),
165
'<strong>', '</strong>',
166
- '<a href="https://squareup.com/help/us/en/article/5580-manage-multiple-locations-with-square" target="_blank">', '</a>'
167
),
168
'options' => [], // this is populated on display
169
];
@@ -796,6 +803,29 @@ class Settings extends \WC_Settings_API {
796
return (array) get_option( 'wc_square_refresh_tokens', [] );
797
}
798
799
800
/**
801
* Gets the configured environment.
@@ -805,7 +835,8 @@ class Settings extends \WC_Settings_API {
805
* @return string
806
*/
807
public function get_environment() {
808
- return defined( 'WC_SQUARE_SANDBOX' ) && WC_SQUARE_SANDBOX ? 'sandbox' : 'production';
809
}
810
811
130
],
131
];
132
133
+ $fields['enable_sandbox'] = [
134
+ 'title' => __( 'Enable Sandbox Mode', 'woocommerce-square' ),
135
+ 'label' => '<span>' . __( 'Enable to set the plugin in sandbox mode.', 'woocommerce-square' ) . '</span>',
136
+ 'type' => 'checkbox',
137
+ 'description' => __( 'After enabling you’ll see a new Sandbox settings section with two fields; Sandbox Application ID & Sandbox Access Token.', 'woocommerce-square' ),
138
+ ];
139
+
140
if ( $this->is_sandbox() ) {
141
$fields['sandbox_settings'] = [
142
'type' => 'title',
170
/* translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s - <a> tag, %4$s - </a> tag */
171
__( 'Select a location to link to this site. Only %1$sactive%2$s %3$slocations%4$s that support credit card processing in Square can be linked.', 'woocommerce-square' ),
172
'<strong>', '</strong>',
173
+ '<a href="https://docs.woocommerce.com/document/woocommerce-square/#section-4" target="_blank">', '</a>'
174
),
175
'options' => [], // this is populated on display
176
];
803
return (array) get_option( 'wc_square_refresh_tokens', [] );
804
}
805
806
+ /**
807
+ * Gets setting enabled sandbox.
808
+ *
809
+ * @since 2.1.2
810
+ *
811
+ * @return string
812
+ */
813
+ public function get_enable_sandbox() {
814
+ return $this->get_option( 'enable_sandbox' );
815
+ }
816
+
817
+ /**
818
+ * Tells is if the setting for enabling sandbox is checked.
819
+ *
820
+ * @since 2.1.2
821
+ *
822
+ * @return boolean
823
+ */
824
+ public function is_sandbox_setting_enabled() {
825
+ // we also need to check the checkbox as it is not store on the first load after submission.
826
+ return 'yes' == $this->get_enable_sandbox() || isset( $_POST['wc_square_enable_sandbox'] );
827
+ }
828
+
829
830
/**
831
* Gets the configured environment.
835
* @return string
836
*/
837
public function get_environment() {
838
+ $sanboxed = ( defined( 'WC_SQUARE_SANDBOX' ) && WC_SQUARE_SANDBOX ) || $this->is_sandbox_setting_enabled();
839
+ return $sanboxed ? 'sandbox' : 'production';
840
}
841
842
readme.txt CHANGED
@@ -72,6 +72,13 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
72
73
== Changelog ==
74
75
= 2.1.1 - 2020.03.23 =
76
* Fix - Inventory/Stock updates as a result of checkout via PayPal Standard does not reflect on the Square item.
77
* Fix - Error when trying to save an external product with the modified 'sync with square' value.
72
73
== Changelog ==
74
75
+ = 2.1.2 - 2020.04.29 =
76
+ * Fix - INTENT_MISMATCH errors when guest customers save a card and registration is disabled.
77
+ * Fix - Improve checkout compatibility with password managers such as 1Password. This also avoids payment for reload on address change.
78
+ * Fix - Pass valid address values even if checkout fields are not present.
79
+ * Tweak - Sandbox mode can be turned on in the settings, no more need for setting the constant.
80
+ * Tweak - Change location URL to refer to our docs.
81
+
82
= 2.1.1 - 2020.03.23 =
83
* Fix - Inventory/Stock updates as a result of checkout via PayPal Standard does not reflect on the Square item.
84
* Fix - Error when trying to save an external product with the modified 'sync with square' value.
woocommerce-square.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/**
3
* Plugin Name: WooCommerce Square
4
- * Version: 2.1.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
1
<?php
2
/**
3
* Plugin Name: WooCommerce Square
4
+ * Version: 2.1.2
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