WooCommerce Square - Version 3.3.0

Version Description

  • 2022-11-07 =
  • Add - Adds digital wallet buttons in the Pay for Order page.
  • Add - Declare support for High-performance Order Systems ("HPOS").
  • Add - Digital Wallet support for Australia.
  • Add - Filter 'wc_square_update_product_set_description' to override product description during update from Square.
  • Add - Filter 'wc_square_update_product_set_name' to override product name during update from Square.
  • Add - Filter 'wc_square_update_product_set_variation_name' to override variation name during update from Square.
  • Add - Support to store transaction ID while using High-performance Order Storage ("HPOS") (formerly known as Custom Order Tables, "COT").
  • Dev - Plugin version constant added to the main file.
  • Fix - Broken detailed decline messages after migration to Payments API.
  • Fix - Checkout without required state field being empty.
  • Fix - Digital wallet errors on Checkout page.
  • Fix - Error caused while fetching variation SKU.
  • Fix - Failed payment due to 3D secure errors.
  • Fix - Fixes variations shown for WooCommerce simple products in Square dashboard.
  • Fix - Inability to sync products created in both Square and WooCommerce.
  • Fix - Incorrectly set quantity during Product Import.
  • Fix - Issue with checkout using digital wallet when company name is required.
  • Fix - Issue with stock status during product import when the inventory count is 0.
  • Fix - Manage stock value of variation products when the product is not synced with Square.
  • Fix - Stock status visibility under inventory for variable products.
  • Update - Replaces dynamic strings with string literals.
  • Update - WC tested up to 7.1
Download this release

Release Info

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

Code changes from version 3.2.0 to 3.3.0

Files changed (38) hide show
  1. assets/js/admin/wc-square-admin-products.min.js +1 -1
  2. assets/js/frontend/wc-square-digital-wallet.min.js +1 -1
  3. assets/js/frontend/wc-square.min.js +1 -1
  4. build/index.asset.php +1 -1
  5. build/index.js +1 -1
  6. changelog.txt +24 -0
  7. i18n/languages/woocommerce-square.pot +208 -113
  8. includes/API.php +1 -1
  9. includes/Admin/Settings_Page.php +2 -2
  10. includes/Framework/Admin_Notice_Handler.php +5 -5
  11. includes/Framework/Api/Base.php +2 -2
  12. includes/Framework/Lifecycle.php +14 -14
  13. includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php +11 -5
  14. includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_User_Handler.php +4 -4
  15. includes/Framework/PaymentGateway/Payment_Gateway.php +9 -4
  16. includes/Framework/PaymentGateway/Payment_Gateway_My_Payment_Methods.php +23 -23
  17. includes/Framework/PaymentGateway/Payment_Gateway_Plugin.php +2 -2
  18. includes/Framework/Plugin.php +8 -8
  19. includes/Gateway.php +12 -9
  20. includes/Gateway/API/Response_Message_Helper.php +157 -0
  21. includes/Gateway/API/Responses/Charge.php +3 -21
  22. includes/Gateway/API/Responses/Create_Payment.php +3 -20
  23. includes/Gateway/Blocks_Handler.php +1 -2
  24. includes/Gateway/Digital_Wallet.php +163 -30
  25. includes/Gateway/Payment_Form.php +15 -21
  26. includes/Handlers/Connection.php +19 -19
  27. includes/Handlers/Product.php +44 -6
  28. includes/Handlers/Product/Woo_SOR.php +11 -1
  29. includes/Handlers/Sync.php +3 -3
  30. includes/Plugin.php +4 -4
  31. includes/Sync/Manual_Synchronization.php +15 -15
  32. includes/Sync/Product_Import.php +5 -2
  33. readme.txt +25 -1
  34. vendor/autoload.php +16 -3
  35. vendor/composer/autoload_real.php +4 -4
  36. vendor/composer/autoload_static.php +5 -5
  37. vendor/composer/installed.php +6 -6
  38. woocommerce-square.php +16 -2
assets/js/admin/wc-square-admin-products.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";jQuery(document).ready($=>{var typenow=window.typenow||"";var pagenow=window.pagenow||"";var __=wp.i18n.__;if("product"!==typenow){return}if(!wc_square_admin_products.is_product_sync_enabled){return}else if("product_page_product_importer"===pagenow){var importNotice="<div class=\"error\">"+"<p>"+__("Product syncing with square has been enabled. "+"If you are trying to update product inventory, you should do it in Square. "+"Your existing inventory data in WooCommerce will be overwritten with data from Square products.","woocommerce-square")+"</p>"+"</div>";$(".wc-progress-steps").after(importNotice)}if("edit-product"===pagenow){$("#the-list").on("click",".editinline",e=>{var $row=$(e.target).closest("tr");var postID=$row.find("th.check-column input").val();var data={action:"wc_square_get_quick_edit_product_details",security:wc_square_admin_products.get_quick_edit_product_details_nonce,product_id:$row.find("th.check-column input").val()};$.post(wc_square_admin_products.ajax_url,data,response=>{var $editRow=$("tr#edit-"+postID);var $squareSynced=$editRow.find("select.square-synced");var $errors=$editRow.find(".wc-square-sync-with-square-errors");if(!response.success&&response.data){if("multiple_attributes"===response.data){$squareSynced.prop("checked",false);$squareSynced.prop("disabled",true);$errors.find(".multiple_attributes").show();return}else if("missing_variation_sku"===response.data){$squareSynced.prop("checked",false);$squareSynced.prop("disabled",true);$errors.find(".missing_variation_sku").show();return}}var $sku=$editRow.find("input[name=_sku]");var $stockStatus=$editRow.find("select[name=_stock_status]");var $stockQty=$editRow.find("input[name=_stock]");var $manageStockLabel=$editRow.find(".manage_stock_field .manage_stock");var $manageStockInput=$editRow.find("input[name=_manage_stock]");var $manageStockDesc="<span class=\"description\"><a href=\""+wc_square_admin_products.settings_url+"\">"+wc_square_admin_products.i18n.synced_with_square+"</a></span>";var edit_url=response.data.edit_url;var i18n=response.data.i18n;var is_variable=response.data.is_variable;$squareSynced.val(response.data.is_synced_with_square);$sku.on("change keyup keypress",e=>{if(""===$(e.target).val()&&!is_variable){$squareSynced.val("no").trigger("change");$squareSynced.prop("disabled",true);$errors.find(".missing_sku").show()}else{$squareSynced.prop("disabled",false);$squareSynced.trigger("change");return $errors.find(".missing_sku").hide()}}).trigger("change");$squareSynced.on("change",e=>{if("no"===$(e.target).val()){$manageStockInput.off();$manageStockInput.add($stockQty).css({opacity:1});$manageStockLabel.find(".description").remove();if(is_variable){if($manageStockInput.is(":checked")){$(".stock_qty_field").show();$(".backorder_field").show()}else{$(".stock_status_field").show()}}else{$stockQty.prop("readonly",false);$stockStatus.prop("readonly",false)}}else{$manageStockInput.prop("checked",true);$manageStockInput.on("click",()=>{return false});$manageStockInput.add($stockQty).css({opacity:"0.5"});$manageStockLabel.append($manageStockDesc);if(wc_square_admin_products.is_woocommerce_sor&&edit_url&&i18n){$manageStockLabel.append("<p class=\"description\"><a href=\""+edit_url+"\">"+i18n+"</a></p>")}if(is_variable){$(".stock_status_field").hide();$(".stock_qty_field").hide();$(".backorder_field").hide()}else{$stockQty.prop("readonly",true);$stockStatus.prop("readonly",true)}}}).trigger("change")})})}if("product"===pagenow){var syncCheckboxID="#_"+wc_square_admin_products.synced_with_square_taxonomy;var isVariable=()=>{return wc_square_admin_products.variable_product_types.includes($("#product-type").val())};var hasSKU=()=>{return""!==$("#_sku").val().trim()};var hasVariableSKUs=skus=>{if(!skus.length){return false}var valid=skus.filter(sku=>""!==$(sku).val().trim());return valid.length===skus.length};var hasUniqueSKUs=skus=>{var skuValues=skus.map(sku=>$(sku).val());return skuValues.every(sku=>skuValues.indexOf(sku)===skuValues.lastIndexOf(sku))};var hasMultipleAttributes=()=>{var $variation_attributes=$(".woocommerce_attribute_data input[name^=\"attribute_variation\"]:checked");return isVariable()&&$variation_attributes&&$variation_attributes.length>1};var showError=error=>{$(".wc-square-sync-with-square-error."+error).show();$(syncCheckboxID).prop("disabled",true);$(syncCheckboxID).prop("checked",false)};var hideError=function hideError(error){var enable=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;$(".wc-square-sync-with-square-error."+error).hide();if(enable){$(syncCheckboxID).prop("disabled",false)}};var handleSKU=syncCheckboxID=>{if(isVariable()){$("#_sku").off("change keypress keyup");hideError("missing_sku",!hasMultipleAttributes());var skus=$("input[id^=\"variable_sku\"]");skus.on("change keypress keyup",()=>{if(!hasVariableSKUs($.makeArray(skus))||!hasUniqueSKUs($.makeArray(skus))){showError("missing_variation_sku")}else{hideError("missing_variation_sku",!hasMultipleAttributes())}$(syncCheckboxID).triggerHandler("change")}).triggerHandler("change")}else{$("input[id^=\"variable_sku\"]").off("change keypress keyup");hideError("missing_variation_sku",!hasMultipleAttributes());$("#_sku").on("change keypress keyup",e=>{if(""===$(e.target).val().trim()){showError("missing_sku")}else{hideError("missing_sku",!hasMultipleAttributes())}$(syncCheckboxID).trigger("change")}).trigger("change")}};var handleAttributes=syncCheckboxID=>{$("#variable_product_options").on("reload",()=>{if(hasMultipleAttributes()){showError("multiple_attributes")}else{hideError("multiple_attributes",isVariable()?hasVariableSKUs:hasSKU())}$(syncCheckboxID).trigger("change")}).trigger("reload")};var triggerUpdate=()=>{handleSKU(syncCheckboxID);$(syncCheckboxID).trigger("change");if(isVariable()&&!$("input[id^=\"variable_sku\"]").length){showError("missing_variation_sku")}};handleAttributes(syncCheckboxID);var $stockFields=$(".stock_fields");var $stockInput=$stockFields.find("#_stock");var $stockStatus=$(".stock_status_field");var $manageField=$("._manage_stock_field");var $manageInput=$manageField.find("#_manage_stock");var $manageDesc=$manageField.find(".description");var manageDescOriginal=$manageDesc.text();var manageStockOriginal=$("#_manage_stock").is(":checked");$(syncCheckboxID).on("change",e=>{if(!wc_square_admin_products.is_inventory_sync_enabled){return}var variableProduct=wc_square_admin_products.variable_product_types.includes($("#product-type").val());var useSquare;if($(e.target).is(":checked")&&$("#_square_item_variation_id").length>0){useSquare=true;$manageDesc.html("<a href=\""+wc_square_admin_products.settings_url+"\">"+wc_square_admin_products.i18n.synced_with_square+"</a>");$manageInput.prop("disabled",true).prop("checked",!variableProduct);$stockFields.hide();$stockStatus.hide();$stockInput.prop("readonly",true);if(!variableProduct){$stockFields.show()}if(wc_square_admin_products.is_woocommerce_sor&&!variableProduct){if($("p._stock_field span.description").length===0){$stockInput.after("<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\"fetch-stock-with-square\">"+wc_square_admin_products.i18n.fetch_stock_with_square+"</a><div class=\"spinner\" style=\"float:none;\"></div></span>")}$("#fetch-stock-with-square").on("click",e=>{e.preventDefault();var $spinner=$("p._stock_field span.description .spinner");var data={action:"wc_square_fetch_product_stock_with_square",security:wc_square_admin_products.fetch_product_stock_with_square_nonce,product_id:$("#post_ID").val()};$spinner.css("visibility","visible");$.post(wc_square_admin_products.ajax_url,data,response=>{if(response&&response.success){var quantity=response.data;$stockInput.val(quantity);$stockFields.find("input[name=_original_stock]").val(quantity);$stockInput.prop("readonly",false);$("p._stock_field span.description").remove()}else{if(response.data){$(".inventory-fetch-error").remove();$spinner.after("<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">"+response.data+"</span>")}$spinner.css("visibility","hidden")}})})}else if(wc_square_admin_products.is_square_sor){if($("p._stock_field span.description").length===0){$stockInput.after("<span class=\"description\" style=\"display:block;clear:both;\">"+wc_square_admin_products.i18n.managed_by_square+"</span>")}}}else{useSquare=false;$("p._stock_field span.description").remove();$stockInput.prop("readonly",false);$manageDesc.html(manageDescOriginal);$manageInput.prop("disabled",false).prop("checked",manageStockOriginal);if(manageStockOriginal){$stockFields.show();$stockStatus.hide()}else{$stockStatus.show();$stockFields.hide()}}$(".woocommerce_variation").each((index,e)=>{var variationID=$(e).find("h3 > a").attr("rel");var $variationManageInput=$(e).find(".variable_manage_stock");var $variationManageField=$variationManageInput.parent();var $variationStockInput=$(e).find(".wc_input_stock");var $variationStockField=$variationStockInput.parent();if(useSquare){$("#wc_square_variation_manage_stock").prop("disabled",false);$variationStockInput.prop("readonly",true);$variationManageInput.prop("disabled",true).prop("checked",true);if(0===$variationManageField.find(".description").length){$variationManageInput.after("<span class=\"description\">("+wc_square_admin_products.i18n.managed_by_square+")</span>")}if(wc_square_admin_products.is_woocommerce_sor){var fetchVariationStockActionID="fetch-stock-with-square-"+variationID;if(0===$variationStockField.find("span.description").length){$variationStockInput.after("<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\""+fetchVariationStockActionID+"\">"+wc_square_admin_products.i18n.fetch_stock_with_square+"</a><div class=\"spinner\" style=\"float:none;\"></div></span>")}$("#"+fetchVariationStockActionID).on("click",e=>{e.preventDefault();var $spinner=$(e.target).next(".spinner");var data={action:"wc_square_fetch_product_stock_with_square",security:wc_square_admin_products.fetch_product_stock_with_square_nonce,product_id:variationID};$spinner.css("visibility","visible");$.post(wc_square_admin_products.ajax_url,data,response=>{if(response&&response.success){var quantity=response.data;$variationStockInput.val(quantity);$variationStockField.parent().find("input[name^=\"variable_original_stock\"]").val(quantity);$variationStockInput.prop("readonly",false);$variationStockField.find(".description").remove()}else{if(response.data){$(".inventory-fetch-error").remove();$spinner.after("<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">"+response.data+"</span>")}$spinner.css("visibility","hidden")}})})}}else{$variationStockInput.prop("readonly",false);$variationManageInput.prop("disabled",false);$variationManageInput.next(".description").remove();$(e.target).find("#wc_square_variation_manage_stock").prop("disabled",true)}})}).trigger("change");$("#product-type").on("change",()=>{triggerUpdate()});$("#woocommerce-product-data").on("woocommerce_variations_loaded woocommerce_variations_added woocommerce_variations_removed",()=>{triggerUpdate()})}});
1
+ "use strict";jQuery(document).ready($=>{var typenow=window.typenow||"";var pagenow=window.pagenow||"";var __=wp.i18n.__;if("product"!==typenow){return}if(!wc_square_admin_products.is_product_sync_enabled){return}else if("product_page_product_importer"===pagenow){var importNotice="<div class=\"error\">"+"<p>"+__("Product syncing with square has been enabled. "+"If you are trying to update product inventory, you should do it in Square. "+"Your existing inventory data in WooCommerce will be overwritten with data from Square products.","woocommerce-square")+"</p>"+"</div>";$(".wc-progress-steps").after(importNotice)}if("edit-product"===pagenow){$("#the-list").on("click",".editinline",e=>{var $row=$(e.target).closest("tr");var postID=$row.find("th.check-column input").val();var data={action:"wc_square_get_quick_edit_product_details",security:wc_square_admin_products.get_quick_edit_product_details_nonce,product_id:$row.find("th.check-column input").val()};$.post(wc_square_admin_products.ajax_url,data,response=>{var $editRow=$("tr#edit-"+postID);var $squareSynced=$editRow.find("select.square-synced");var $errors=$editRow.find(".wc-square-sync-with-square-errors");if(!response.success&&response.data){if("multiple_attributes"===response.data){$squareSynced.prop("checked",false);$squareSynced.prop("disabled",true);$errors.find(".multiple_attributes").show();return}else if("missing_variation_sku"===response.data){$squareSynced.prop("checked",false);$squareSynced.prop("disabled",true);$errors.find(".missing_variation_sku").show();return}}var $sku=$editRow.find("input[name=_sku]");var $stockStatus=$editRow.find("select[name=_stock_status]");var $stockQty=$editRow.find("input[name=_stock]");var $manageStockLabel=$editRow.find(".manage_stock_field .manage_stock");var $manageStockInput=$editRow.find("input[name=_manage_stock]");var $manageStockDesc="<span class=\"description\"><a href=\""+wc_square_admin_products.settings_url+"\">"+wc_square_admin_products.i18n.synced_with_square+"</a></span>";var edit_url=response.data.edit_url;var i18n=response.data.i18n;var is_variable=response.data.is_variable;$squareSynced.val(response.data.is_synced_with_square);$sku.on("change keyup keypress",e=>{if(""===$(e.target).val()&&!is_variable){$squareSynced.val("no").trigger("change");$squareSynced.prop("disabled",true);$errors.find(".missing_sku").show()}else{$squareSynced.prop("disabled",false);$squareSynced.trigger("change");return $errors.find(".missing_sku").hide()}}).trigger("change");$squareSynced.on("change",e=>{if("no"===$(e.target).val()){$manageStockInput.off();$manageStockInput.add($stockQty).css({opacity:1});$manageStockLabel.find(".description").remove();if(is_variable){if($manageStockInput.is(":checked")){$(".stock_qty_field").show();$(".backorder_field").show()}else{$(".stock_status_field").show()}}else{$stockQty.prop("readonly",false);$stockStatus.prop("readonly",false)}}else{$manageStockInput.prop("checked",true);$manageStockInput.on("click",()=>{return false});$manageStockInput.add($stockQty).css({opacity:"0.5"});$manageStockLabel.append($manageStockDesc);if(wc_square_admin_products.is_woocommerce_sor&&edit_url&&i18n){$manageStockLabel.append("<p class=\"description\"><a href=\""+edit_url+"\">"+i18n+"</a></p>")}if(is_variable){$(".stock_status_field").hide();$(".stock_qty_field").hide();$(".backorder_field").hide()}else{$stockQty.prop("readonly",true);$stockStatus.prop("readonly",true)}}}).trigger("change")})})}if("product"===pagenow){var syncCheckboxID="#_"+wc_square_admin_products.synced_with_square_taxonomy;var isVariable=()=>{return wc_square_admin_products.variable_product_types.includes($("#product-type").val())};var hasSKU=()=>{return""!==$("#_sku").val().trim()};var hasVariableSKUs=skus=>{if(!skus.length){return false}var valid=skus.filter(sku=>""!==$(sku).val().trim());return valid.length===skus.length};var hasUniqueSKUs=skus=>{var skuValues=skus.map(sku=>$(sku).val());return skuValues.every(sku=>skuValues.indexOf(sku)===skuValues.lastIndexOf(sku))};var hasMultipleAttributes=()=>{var $variation_attributes=$(".woocommerce_attribute_data input[name^=\"attribute_variation\"]:checked");return isVariable()&&$variation_attributes&&$variation_attributes.length>1};var showError=error=>{$(".wc-square-sync-with-square-error."+error).show();$(syncCheckboxID).prop("disabled",true);$(syncCheckboxID).prop("checked",false)};var hideError=function hideError(error){var enable=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;$(".wc-square-sync-with-square-error."+error).hide();if(enable){$(syncCheckboxID).prop("disabled",false)}};var handleSKU=syncCheckboxID=>{if(isVariable()){$("#_sku").off("change keypress keyup");hideError("missing_sku",!hasMultipleAttributes());var skus=$("input[id^=\"variable_sku\"]");skus.on("change keypress keyup",()=>{if(!hasVariableSKUs($.makeArray(skus))||!hasUniqueSKUs($.makeArray(skus))){showError("missing_variation_sku")}else{hideError("missing_variation_sku",!hasMultipleAttributes())}$(syncCheckboxID).triggerHandler("change")}).triggerHandler("change")}else{$("input[id^=\"variable_sku\"]").off("change keypress keyup");hideError("missing_variation_sku",!hasMultipleAttributes());$("#_sku").on("change keypress keyup",e=>{if(""===$(e.target).val().trim()){showError("missing_sku")}else{hideError("missing_sku",!hasMultipleAttributes())}$(syncCheckboxID).trigger("change")}).trigger("change")}};var handleAttributes=syncCheckboxID=>{$("#variable_product_options").on("reload",()=>{if(hasMultipleAttributes()){showError("multiple_attributes")}else{hideError("multiple_attributes",isVariable()?hasVariableSKUs:hasSKU())}$(syncCheckboxID).trigger("change")}).trigger("reload")};var triggerUpdate=()=>{handleSKU(syncCheckboxID);$(syncCheckboxID).trigger("change");if(isVariable()&&!$("input[id^=\"variable_sku\"]").length){showError("missing_variation_sku")}};handleAttributes(syncCheckboxID);var $stockFields=$(".stock_fields");var $stockInput=$stockFields.find("#_stock");var $stockStatus=$(".stock_status_field");var $manageField=$("._manage_stock_field");var $manageInput=$manageField.find("#_manage_stock");var $manageDesc=$manageField.find(".description");var manageDescOriginal=$manageDesc.text();var manageStockOriginal=$("#_manage_stock").is(":checked");$(syncCheckboxID).on("change",e=>{if(!wc_square_admin_products.is_inventory_sync_enabled){return}var variableProduct=wc_square_admin_products.variable_product_types.includes($("#product-type").val());var useSquare;if($(e.target).is(":checked")&&$("#_square_item_variation_id").length>0){useSquare=true;$manageDesc.html("<a href=\""+wc_square_admin_products.settings_url+"\">"+wc_square_admin_products.i18n.synced_with_square+"</a>");$manageInput.prop("disabled",true).prop("checked",!variableProduct);$stockFields.hide();$stockStatus.hide();$stockInput.prop("readonly",true);if(!variableProduct){$stockFields.show()}if(wc_square_admin_products.is_woocommerce_sor&&!variableProduct){if($("p._stock_field span.description").length===0){$stockInput.after("<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\"fetch-stock-with-square\">"+wc_square_admin_products.i18n.fetch_stock_with_square+"</a><div class=\"spinner\" style=\"float:none;\"></div></span>")}$("#fetch-stock-with-square").on("click",e=>{e.preventDefault();var $spinner=$("p._stock_field span.description .spinner");var data={action:"wc_square_fetch_product_stock_with_square",security:wc_square_admin_products.fetch_product_stock_with_square_nonce,product_id:$("#post_ID").val()};$spinner.css("visibility","visible");$.post(wc_square_admin_products.ajax_url,data,response=>{if(response&&response.success){var quantity=response.data;$stockInput.val(quantity);$stockFields.find("input[name=_original_stock]").val(quantity);$stockInput.prop("readonly",false);$("p._stock_field span.description").remove()}else{if(response.data){$(".inventory-fetch-error").remove();$spinner.after("<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">"+response.data+"</span>")}$spinner.css("visibility","hidden")}})})}else if(wc_square_admin_products.is_square_sor){if($("p._stock_field span.description").length===0){$stockInput.after("<span class=\"description\" style=\"display:block;clear:both;\">"+wc_square_admin_products.i18n.managed_by_square+"</span>")}}}else{useSquare=false;$("p._stock_field span.description").remove();$stockInput.prop("readonly",false);$manageDesc.html(manageDescOriginal);$manageInput.prop("disabled",false).prop("checked",manageStockOriginal);if(!variableProduct){if(manageStockOriginal){$stockFields.show();$stockStatus.hide()}else{$stockStatus.show();$stockFields.hide()}}}$(".woocommerce_variation").each((index,e)=>{var variationID=$(e).find("h3 > a").attr("rel");var $variationManageInput=$(e).find(".variable_manage_stock");var $variationManageField=$variationManageInput.parent();var $variationStockInput=$(e).find(".wc_input_stock");var $variationStockField=$variationStockInput.parent();if(useSquare){$("#wc_square_variation_manage_stock").prop("disabled",false);$variationStockInput.prop("readonly",true);$variationManageInput.prop("disabled",true).prop("checked",true);if(0===$variationManageField.find(".description").length){$variationManageInput.after("<span class=\"description\">("+wc_square_admin_products.i18n.managed_by_square+")</span>")}if(wc_square_admin_products.is_woocommerce_sor){var fetchVariationStockActionID="fetch-stock-with-square-"+variationID;if(0===$variationStockField.find("span.description").length){$variationStockInput.after("<span class=\"description\" style=\"display:block;clear:both;\"><a href=\"#\" id=\""+fetchVariationStockActionID+"\">"+wc_square_admin_products.i18n.fetch_stock_with_square+"</a><div class=\"spinner\" style=\"float:none;\"></div></span>")}$("#"+fetchVariationStockActionID).on("click",e=>{e.preventDefault();var $spinner=$(e.target).next(".spinner");var data={action:"wc_square_fetch_product_stock_with_square",security:wc_square_admin_products.fetch_product_stock_with_square_nonce,product_id:variationID};$spinner.css("visibility","visible");$.post(wc_square_admin_products.ajax_url,data,response=>{if(response&&response.success){var quantity=response.data;$variationStockInput.val(quantity);$variationStockField.parent().find("input[name^=\"variable_original_stock\"]").val(quantity);$variationStockInput.prop("readonly",false);$variationStockField.find(".description").remove()}else{if(response.data){$(".inventory-fetch-error").remove();$spinner.after("<span class=\"inventory-fetch-error\" style=\"display:inline-block;color:red;\">"+response.data+"</span>")}$spinner.css("visibility","hidden")}})})}}else{$variationStockInput.prop("readonly",false);$variationManageInput.prop("disabled",false);$variationManageInput.next(".description").remove();$(e).find("#wc_square_variation_manage_stock").prop("disabled",true)}})}).trigger("change");$("#product-type").on("change",()=>{triggerUpdate()});$("#woocommerce-product-data").on("woocommerce_variations_loaded woocommerce_variations_added woocommerce_variations_removed",()=>{triggerUpdate()})}});
assets/js/frontend/wc-square-digital-wallet.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}jQuery(document).ready($=>{class WC_Square_Digital_Wallet_Handler{constructor(args){this.args=args;this.payment_request=args.payment_request;this.total_amount=args.payment_request.total.amount;this.cartForm=".cart";this.wallet="#wc-square-digital-wallet";this.buttons=".wc-square-wallet-buttons";this.isGooglePayHidden=this.args.hide_button_options.includes("google");this.isApplePayHidden=this.args.hide_button_options.includes("apple");if($(this.wallet).length===0){return}$(this.wallet).hide();$(this.buttons).hide();this.build_digital_wallet();this.attach_page_events();this.buildDigitalWalletDebounced=this.debounce(this.build_digital_wallet,500)}build_digital_wallet(){this.block_ui();this.get_payment_request().then(response=>{this.payment_request=JSON.parse(response);this.total_amount=this.payment_request.total.amount;this.load_square_form()},message=>{this.log("[Square] Could not build payment request. "+message,"error");$(this.wallet).hide()})}attach_page_events(){if(this.args.context==="product"){var addToCartButton=$(".single_add_to_cart_button");$("#apple-pay-button, #wc-square-google-pay").on("click",e=>{if(addToCartButton.is(".disabled")){e.stopImmediatePropagation();if(addToCartButton.is(".wc-variation-is-unavailable")){window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text)}else if(addToCartButton.is(".wc-variation-selection-needed")){window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text)}return}this.add_to_cart()});$(document.body).on("woocommerce_variation_has_changed",()=>this.build_digital_wallet());$(".quantity").on("input",".qty",()=>this.buildDigitalWalletDebounced())}if(this.args.context==="cart"){$(document.body).on("updated_cart_totals",()=>this.build_digital_wallet())}if(this.args.context==="checkout"){$(document.body).on("updated_checkout",()=>this.build_digital_wallet())}}load_square_form(){if(this.googlePay){this.googlePay.destroy();this.squareFormLoaded=false}if(this.applePay){this.applePay.destroy();this.squareFormLoaded=false}if(this.squareFormLoaded){return}this.squareFormLoaded=true;this.log("[Square] Building digital wallet payment form");var{applicationId,locationId}=this.get_form_params();this.payments=window.Square.payments(applicationId,locationId);this.initializeDigitalWalletPaymentMethods()}initializeDigitalWalletPaymentMethods(){var _this=this;return _asyncToGenerator(function*(){if(!_this.payments){return}var paymentRequest=_this.payments.paymentRequest(_this.create_payment_request());_this.registerDigitalWalletShippingEventHandlers(paymentRequest);if(!_this.isGooglePayHidden){_this.googlePay=yield _this.payments.googlePay(paymentRequest);_this.googlePay.attach("#wc-square-google-pay",{buttonSizeMode:"fill",buttonType:"long",buttonColor:_this.args.google_pay_color});$("#wc-square-google-pay").on("click",function(){var _ref=_asyncToGenerator(function*(e){return _this.handleGooglePayPaymentMethodSubmission(e,_this.googlePay)});return function(_x){return _ref.apply(this,arguments)}}());$("#wc-square-google-pay").show()}if(!_this.isApplePayHidden){try{_this.applePay=yield _this.payments.applePay(paymentRequest);$("#apple-pay-button").on("click",function(){var _ref2=_asyncToGenerator(function*(e){return _this.handleApplePayPaymentMethodSubmission(e,_this.applePay)});return function(_x2){return _ref2.apply(this,arguments)}}());$("#apple-pay-button").show()}catch(e){console.log(e.message)}}if(_this.googlePay||_this.applePay){$(_this.wallet).show();_this.unblock_ui()}})()}handleGooglePayPaymentMethodSubmission(e){var _arguments=arguments,_this2=this;return _asyncToGenerator(function*(){var googlePay=_arguments.length>1&&_arguments[1]!==undefined?_arguments[1]:null;e.preventDefault();if(!googlePay){return}var result=yield googlePay.tokenize();if(result.status==="OK"){var cardData=_objectSpread(_objectSpread({},result.details.card),{},{digital_wallet_type:result.details.method});var billingAndShippingData={billingContact:result.details.billing};if(result.details.shipping){billingAndShippingData.shippingContact=result.details.shipping.contact;billingAndShippingData.shippingOption=result.details.shipping.option}_this2.handle_card_nonce_response(false,result.token,cardData,billingAndShippingData)}})()}handleApplePayPaymentMethodSubmission(e){var _arguments2=arguments,_this3=this;return _asyncToGenerator(function*(){var applePay=_arguments2.length>1&&_arguments2[1]!==undefined?_arguments2[1]:null;e.preventDefault();if(!applePay){return}var result=yield applePay.tokenize();if(result.status==="OK"){var cardData=_objectSpread(_objectSpread({},result.details.card),{},{digital_wallet_type:result.details.method});var billingAndShippingData={billingContact:result.details.billing};if(result.details.shipping){billingAndShippingData.shippingContact=result.details.shipping.contact;billingAndShippingData.shippingOption=result.details.shipping.option}_this3.handle_card_nonce_response(false,result.token,cardData,billingAndShippingData)}})()}registerDigitalWalletShippingEventHandlers(paymentRequest){paymentRequest.addEventListener("shippingoptionchanged",option=>this.handle_shipping_option_changed(option));paymentRequest.addEventListener("shippingcontactchanged",shippingContact=>this.handle_shipping_address_changed(shippingContact))}get_form_params(){var params={applicationId:this.args.application_id,locationId:this.args.location_id,autobuild:false,applePay:{elementId:"apple-pay-button"},googlePay:{elementId:"wc-square-google-pay"}};if(this.payment_request.requestShippingAddress===false){delete params.callbacks.shippingOptionChanged}if(this.args.hide_button_options.includes("google")){delete params.googlePay}if(this.args.hide_button_options.includes("apple")){delete params.applePay}return params}create_payment_request(){return this.payment_request}methods_supported(methods,unsupportedReason){if(methods.applePay===true||methods.googlePay===true){if(methods.applePay===true){$("#apple-pay-button").show()}if(methods.googlePay===true){$("#wc-square-google-pay").show()}$(this.wallet).show()}else{this.log(unsupportedReason)}}get_payment_request(){return new Promise((resolve,reject)=>{var data={context:this.args.context,security:this.args.payment_request_nonce};if(this.args.context==="product"){var product_data=this.get_product_data();$.extend(data,product_data)}$.post(this.get_ajax_url("get_payment_request"),data,response=>{if(response.success){return resolve(response.data)}return reject(response.data)})})}handle_shipping_address_changed(shippingContact){var _this4=this;return _asyncToGenerator(function*(){var data={context:_this4.args.context,shipping_contact:shippingContact,security:_this4.args.recalculate_totals_nonce};var response=yield _this4.recalculate_totals(data);return response})()}handle_shipping_option_changed(shippingOption){var _this5=this;return _asyncToGenerator(function*(){var data={context:_this5.args.context,shipping_option:shippingOption.id,security:_this5.args.recalculate_totals_nonce};var response=yield _this5.recalculate_totals(data);return response})()}handle_card_nonce_response(){var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var nonce=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var cardData=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var billingAndShippingData=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};if(errors){return this.render_errors(errors)}if(!nonce){return this.render_errors(this.args.general_error)}this.block_ui();var{billingContact={},shippingContact={},shippingOption=null}=billingAndShippingData;var data={action:"",_wpnonce:this.args.process_checkout_nonce,billing_first_name:billingContact.givenName?billingContact.givenName:"",billing_last_name:billingContact.familyName?billingContact.familyName:"",billing_company:"",billing_email:shippingContact.email?shippingContact.email:billingContact.email?billingContact.email:"",billing_phone:shippingContact.phone?shippingContact.phone:"",billing_country:billingContact.countryCode?billingContact.countryCode.toUpperCase():"",billing_address_1:billingContact.addressLines&&billingContact.addressLines[0]?billingContact.addressLines[0]:"",billing_address_2:billingContact.addressLines&&billingContact.addressLines[1]?billingContact.addressLines[1]:"",billing_city:billingContact.city?billingContact.city:"",billing_state:billingContact.state?billingContact.state:"",billing_postcode:billingContact.postalCode?billingContact.postalCode:"",shipping_first_name:shippingContact.givenName?shippingContact.givenName:"",shipping_last_name:shippingContact.familyName?shippingContact.familyName:"",shipping_company:"",shipping_country:shippingContact.countryCode?shippingContact.countryCode.toUpperCase():"",shipping_address_1:shippingContact.addressLines&&shippingContact.addressLines[0]?shippingContact.addressLines[0]:"",shipping_address_2:shippingContact.addressLines&&shippingContact.addressLines[1]?shippingContact.addressLines[1]:"",shipping_city:shippingContact.city?shippingContact.city:"",shipping_state:shippingContact.state?shippingContact.state:"",shipping_postcode:shippingContact.postalCode?shippingContact.postalCode:"",shipping_method:[!shippingOption?null:shippingOption.id],order_comments:"",payment_method:"square_credit_card",ship_to_different_address:1,terms:1,"wc-square-credit-card-payment-nonce":nonce,"wc-square-credit-card-last-four":cardData.last4?cardData.last4:null,"wc-square-credit-card-exp-month":cardData.expMonth?cardData.expMonth:null,"wc-square-credit-card-exp-year":cardData.expYear?cardData.expYear:null,"wc-square-credit-card-payment-postcode":cardData.billing.postalCode?cardData.billing.postalCode:null,"wc-square-digital-wallet-type":cardData.digital_wallet_type};if(cardData.digital_wallet_type==="GOOGLE_PAY"){if(billingContact.givenName){data.billing_first_name=billingContact.givenName.split(" ").slice(0,1).join(" ");data.billing_last_name=billingContact.givenName.split(" ").slice(1).join(" ")}if(shippingContact.givenName){data.shipping_last_name=shippingContact.givenName.split(" ").slice(0,1).join(" ");data.shipping_last_name=shippingContact.givenName.split(" ").slice(1).join(" ")}}if(!data.billing_phone&&billingContact.phone){data.billing_phone=billingContact.phone}if(this.args.is_3d_secure_enabled){this.log("3DS verification enabled. Verifying buyer");var self=this;try{this.payments.verifyBuyer(nonce,self.get_verification_details(billingContact,shippingContact)).then(verificationResult=>{if(verificationResult.token){self.log("3DS verification successful");data["wc-square-credit-card-buyer-verification-token"]=verificationResult.token;self.do_checkout(data)}})}catch(err){self.log("3DS verification failed");self.log(err);self.render_errors([err.message])}}else{this.do_checkout(data)}}do_checkout(data){this.process_digital_wallet_checkout(data).then(response=>{window.location=response.redirect},response=>{this.log(response,"error");this.render_errors_html(response.messages)})}get_verification_details(billingContact,shippingContact){var verification_details={intent:"CHARGE",amount:this.total_amount,currencyCode:this.payment_request.currencyCode,billingContact:{familyName:billingContact.familyName?billingContact.familyName:"",givenName:billingContact.givenName?billingContact.givenName:"",email:shippingContact.email?shippingContact.email:"",countryCode:billingContact.countryCode?billingContact.countryCode.toUpperCase():"",state:billingContact.state?billingContact.state:"",city:billingContact.city?billingContact.city:"",postalCode:billingContact.postalCode?billingContact.postalCode:"",phone:shippingContact.phone?shippingContact.phone:"",addressLines:billingContact.addressLines?billingContact.addressLines:""}};this.log(verification_details);return verification_details}recalculate_totals(data){var _this6=this;return _asyncToGenerator(function*(){return new Promise((resolve,reject)=>{return $.post(_this6.get_ajax_url("recalculate_totals"),data,response=>{if(response.success){_this6.total_amount=response.data.total.amount;return resolve(response.data)}return reject(response.data)})})})()}get_product_data(){var product_id=$(".single_add_to_cart_button").val();var attributes={};if($(".single_variation_wrap").length){product_id=$(".single_variation_wrap").find("input[name=\"product_id\"]").val();if($(".variations_form").length){$(".variations_form").find(".variations select").each((index,select)=>{var attribute_name=$(select).data("attribute_name")||$(select).attr("name");var value=$(select).val()||"";return attributes[attribute_name]=value})}}return{product_id,quantity:$(".quantity .qty").val(),attributes}}add_to_cart(){var data={security:this.args.add_to_cart_nonce};var product_data=this.get_product_data();$.extend(data,product_data);$.post(this.get_ajax_url("add_to_cart"),data,response=>{if(response.error){return window.alert(response.data)}var data=JSON.parse(response.data);this.payment_request=data.payment_request;this.args.payment_request_nonce=data.payment_request_nonce;this.args.add_to_cart_nonce=data.add_to_cart_nonce;this.args.recalculate_totals_nonce=data.recalculate_totals_nonce;this.args.process_checkout_nonce=data.process_checkout_nonce})}process_digital_wallet_checkout(data){return new Promise((resolve,reject)=>{$.post(this.get_ajax_url("process_checkout"),data,response=>{if(response.result==="success"){return resolve(response)}return reject(response)})})}get_ajax_url(request){return this.args.ajax_url.replace("%%endpoint%%","square_digital_wallet_"+request)}render_errors_html(errors_html){$(".woocommerce-error, .woocommerce-message").remove();var element=this.args.context==="product"?$(".product"):$(".shop_table.cart").closest("form");element.before(errors_html);this.unblock_ui();$("html, body").animate({scrollTop:element.offset().top-100},1000)}render_errors(errors){var error_message_html="<ul class=\"woocommerce-error\"><li>"+errors.join("</li><li>")+"</li></ul>";this.render_errors_html(error_message_html)}block_ui(){$(this.buttons).block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}unblock_ui(){$(this.buttons).unblock()}log(message){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"notice";if(!this.args.logging_enabled){return}if(type==="error"){return console.error(message)}return console.log(message)}debounce(func,wait,immediate){var timeout;return function(){var context=this,args=arguments;var later=function later(){timeout=null;if(!immediate)func.apply(context,args)};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow)func.apply(context,args)}}}window.WC_Square_Digital_Wallet_Handler=WC_Square_Digital_Wallet_Handler});
1
+ "use strict";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}jQuery(document).ready($=>{class WC_Square_Digital_Wallet_Handler{constructor(args){this.args=args;this.payment_request=args.payment_request;this.total_amount=args.payment_request.total.amount;this.isPayForOrderPage=args.is_pay_for_order_page;this.orderId=args.order_id;this.id_dasherized=args.gateway_id_dasherized;this.cartForm=".cart";this.wallet="#wc-square-digital-wallet";this.buttons=".wc-square-wallet-buttons";this.isGooglePayHidden=this.args.hide_button_options.includes("google");this.isApplePayHidden=this.args.hide_button_options.includes("apple");if($(this.wallet).length===0){return}$(this.wallet).hide();$(this.buttons).hide();this.build_digital_wallet();this.attach_page_events();this.buildDigitalWalletDebounced=this.debounce(this.build_digital_wallet,500)}build_digital_wallet(){this.block_ui();this.get_payment_request().then(response=>{this.payment_request=JSON.parse(response);this.total_amount=this.payment_request.total.amount;this.load_square_form()},message=>{this.log("[Square] Could not build payment request. "+message,"error");$(this.wallet).hide()})}attach_page_events(){if(this.args.context==="product"){var addToCartButton=$(".single_add_to_cart_button");$("#apple-pay-button, #wc-square-google-pay").on("click",e=>{if(addToCartButton.is(".disabled")){e.stopImmediatePropagation();if(addToCartButton.is(".wc-variation-is-unavailable")){window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text)}else if(addToCartButton.is(".wc-variation-selection-needed")){window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text)}return}this.add_to_cart()});$(document.body).on("woocommerce_variation_has_changed",()=>this.build_digital_wallet());$(".quantity").on("input",".qty",()=>this.buildDigitalWalletDebounced())}if(this.args.context==="cart"){$(document.body).on("updated_cart_totals",()=>this.build_digital_wallet())}if(this.args.context==="checkout"){$(document.body).on("updated_checkout",()=>this.build_digital_wallet())}$(document).on("payment_method_selected",()=>{if(!this.isPayForOrderPage){return}$("#payment_method_override").remove()})}load_square_form(){if(this.googlePay){this.googlePay.destroy();this.squareFormLoaded=false}if(this.applePay){this.applePay.destroy();this.squareFormLoaded=false}if(this.squareFormLoaded){return}this.squareFormLoaded=true;this.log("[Square] Building digital wallet payment form");var{applicationId,locationId}=this.get_form_params();this.payments=window.Square.payments(applicationId,locationId);this.initializeDigitalWalletPaymentMethods()}initializeDigitalWalletPaymentMethods(){var _this=this;return _asyncToGenerator(function*(){if(!_this.payments){return}var paymentRequest=_this.payments.paymentRequest(_this.create_payment_request());_this.registerDigitalWalletShippingEventHandlers(paymentRequest);if(!_this.isGooglePayHidden){_this.googlePay=yield _this.payments.googlePay(paymentRequest);_this.googlePay.attach("#wc-square-google-pay",{buttonSizeMode:"fill",buttonType:"long",buttonColor:_this.args.google_pay_color});$("#wc-square-google-pay").on("click",function(){var _ref=_asyncToGenerator(function*(e){return _this.handleGooglePayPaymentMethodSubmission(e,_this.googlePay)});return function(_x){return _ref.apply(this,arguments)}}());$("#wc-square-google-pay").show()}if(!_this.isApplePayHidden){try{_this.applePay=yield _this.payments.applePay(paymentRequest);$("#apple-pay-button").on("click",function(){var _ref2=_asyncToGenerator(function*(e){return _this.handleApplePayPaymentMethodSubmission(e,_this.applePay)});return function(_x2){return _ref2.apply(this,arguments)}}());$("#apple-pay-button").show()}catch(e){console.log(e.message)}}if(_this.googlePay||_this.applePay){$(_this.wallet).show();_this.unblock_ui()}})()}handleGooglePayPaymentMethodSubmission(e){var _arguments=arguments,_this2=this;return _asyncToGenerator(function*(){var googlePay=_arguments.length>1&&_arguments[1]!==undefined?_arguments[1]:null;e.preventDefault();if(!googlePay){return}var result=yield googlePay.tokenize();if(result.status==="OK"){var cardData=_objectSpread(_objectSpread({},result.details.card),{},{digital_wallet_type:result.details.method});var billingAndShippingData={billingContact:result.details.billing};if(result.details.shipping){billingAndShippingData.shippingContact=result.details.shipping.contact;billingAndShippingData.shippingOption=result.details.shipping.option}_this2.handle_card_nonce_response(false,result.token,cardData,billingAndShippingData)}})()}handleApplePayPaymentMethodSubmission(e){var _arguments2=arguments,_this3=this;return _asyncToGenerator(function*(){var applePay=_arguments2.length>1&&_arguments2[1]!==undefined?_arguments2[1]:null;e.preventDefault();if(!applePay){return}var result=yield applePay.tokenize();if(result.status==="OK"){var cardData=_objectSpread(_objectSpread({},result.details.card),{},{digital_wallet_type:result.details.method});var billingAndShippingData={billingContact:result.details.billing};if(result.details.shipping){billingAndShippingData.shippingContact=result.details.shipping.contact;billingAndShippingData.shippingOption=result.details.shipping.option}_this3.handle_card_nonce_response(false,result.token,cardData,billingAndShippingData)}})()}registerDigitalWalletShippingEventHandlers(paymentRequest){paymentRequest.addEventListener("shippingoptionchanged",option=>this.handle_shipping_option_changed(option));paymentRequest.addEventListener("shippingcontactchanged",shippingContact=>this.handle_shipping_address_changed(shippingContact))}get_form_params(){var params={applicationId:this.args.application_id,locationId:this.args.location_id,autobuild:false,applePay:{elementId:"apple-pay-button"},googlePay:{elementId:"wc-square-google-pay"}};if(this.payment_request.requestShippingAddress===false){delete params.callbacks.shippingOptionChanged}if(this.args.hide_button_options.includes("google")){delete params.googlePay}if(this.args.hide_button_options.includes("apple")){delete params.applePay}return params}create_payment_request(){return this.payment_request}methods_supported(methods,unsupportedReason){if(methods.applePay===true||methods.googlePay===true){if(methods.applePay===true){$("#apple-pay-button").show()}if(methods.googlePay===true){$("#wc-square-google-pay").show()}$(this.wallet).show()}else{this.log(unsupportedReason)}}get_payment_request(){return new Promise((resolve,reject)=>{var data={context:this.args.context,security:this.args.payment_request_nonce,is_pay_for_order_page:this.isPayForOrderPage,order_id:this.orderId};if(this.args.context==="product"){var product_data=this.get_product_data();$.extend(data,product_data)}$.post(this.get_ajax_url("get_payment_request"),data,response=>{if(response.success){return resolve(response.data)}return reject(response.data)})})}handle_shipping_address_changed(shippingContact){var _this4=this;return _asyncToGenerator(function*(){var data={context:_this4.args.context,shipping_contact:shippingContact,security:_this4.args.recalculate_totals_nonce,is_pay_for_order_page:_this4.isPayForOrderPage,order_id:_this4.orderId};var response=yield _this4.recalculate_totals(data);return response})()}handle_shipping_option_changed(shippingOption){var _this5=this;return _asyncToGenerator(function*(){var data={context:_this5.args.context,shipping_option:shippingOption.id,security:_this5.args.recalculate_totals_nonce,is_pay_for_order_page:_this5.isPayForOrderPage,order_id:_this5.orderId};var response=yield _this5.recalculate_totals(data);return response})()}handle_card_nonce_response(){var errors=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var nonce=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var cardData=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var billingAndShippingData=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};if(errors){return this.render_errors(errors)}if(!nonce){return this.render_errors(this.args.general_error)}this.block_ui();var orderReviewForm=$("#order_review");var{billingContact={},shippingContact={},shippingOption=null}=billingAndShippingData;var data={action:"",_wpnonce:this.args.process_checkout_nonce,billing_first_name:billingContact.givenName?billingContact.givenName:"",billing_last_name:billingContact.familyName?billingContact.familyName:"",billing_company:$("#billing_company").val(),billing_email:shippingContact.email?shippingContact.email:billingContact.email?billingContact.email:"",billing_phone:shippingContact.phone?shippingContact.phone:"",billing_country:billingContact.countryCode?billingContact.countryCode.toUpperCase():"",billing_address_1:billingContact.addressLines&&billingContact.addressLines[0]?billingContact.addressLines[0]:"",billing_address_2:billingContact.addressLines&&billingContact.addressLines[1]?billingContact.addressLines[1]:"",billing_city:billingContact.city?billingContact.city:"",billing_state:billingContact.state?billingContact.state:"",billing_postcode:billingContact.postalCode?billingContact.postalCode:"",shipping_first_name:shippingContact.givenName?shippingContact.givenName:"",shipping_last_name:shippingContact.familyName?shippingContact.familyName:"",shipping_company:$("#shipping_company").val(),shipping_country:shippingContact.countryCode?shippingContact.countryCode.toUpperCase():"",shipping_address_1:shippingContact.addressLines&&shippingContact.addressLines[0]?shippingContact.addressLines[0]:"",shipping_address_2:shippingContact.addressLines&&shippingContact.addressLines[1]?shippingContact.addressLines[1]:"",shipping_city:shippingContact.city?shippingContact.city:"",shipping_state:shippingContact.state?shippingContact.state:"",shipping_postcode:shippingContact.postalCode?shippingContact.postalCode:"",shipping_method:[!shippingOption?null:shippingOption.id],order_comments:"",payment_method:"square_credit_card",ship_to_different_address:1,terms:1,"wc-square-credit-card-payment-nonce":nonce,"wc-square-credit-card-last-four":cardData.last4?cardData.last4:null,"wc-square-credit-card-exp-month":cardData.expMonth?cardData.expMonth:null,"wc-square-credit-card-exp-year":cardData.expYear?cardData.expYear:null,"wc-square-credit-card-payment-postcode":cardData.billing.postalCode?cardData.billing.postalCode:null,"wc-square-digital-wallet-type":cardData.digital_wallet_type,is_pay_for_order_page:this.isPayForOrderPage};if(this.isPayForOrderPage){var _cardData$billing;if(cardData.last4){$("input[name=wc-".concat(this.id_dasherized,"-last-four]")).val(cardData.last4)}if(cardData.expMonth){$("input[name=wc-".concat(this.id_dasherized,"-exp-month]")).val(cardData.expMonth)}if(cardData.expYear){$("input[name=wc-".concat(this.id_dasherized,"-exp-year]")).val(cardData.expYear)}if(cardData!==null&&cardData!==void 0&&(_cardData$billing=cardData.billing)!==null&&_cardData$billing!==void 0&&_cardData$billing.postalCode){$("input[name=wc-".concat(this.id_dasherized,"-payment-postcode]")).val(cardData.billing.postalCode)}if(cardData.brand){$("input[name=wc-".concat(this.id_dasherized,"-card-type]")).val(cardData.brand)}$("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val(nonce);$("#payment_method_override").remove();$("#payment").after("<input id=\"payment_method_override\" type=\"hidden\" name=\"payment_method\" value=\"square_credit_card\" />")}if(cardData.digital_wallet_type==="GOOGLE_PAY"){if(billingContact.givenName){data.billing_first_name=billingContact.givenName.split(" ").slice(0,1).join(" ");data.billing_last_name=billingContact.givenName.split(" ").slice(1).join(" ")}if(shippingContact.givenName){data.shipping_last_name=shippingContact.givenName.split(" ").slice(0,1).join(" ");data.shipping_last_name=shippingContact.givenName.split(" ").slice(1).join(" ")}}if(!data.billing_phone&&billingContact.phone){data.billing_phone=billingContact.phone}this.log("3DS verification enabled. Verifying buyer");var self=this;try{this.payments.verifyBuyer(nonce,self.get_verification_details(billingContact,shippingContact)).then(verificationResult=>{if(verificationResult.token){if(this.isPayForOrderPage&&orderReviewForm.length){$("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val(verificationResult.token);orderReviewForm.trigger("submit");return}self.log("3DS verification successful");data["wc-square-credit-card-buyer-verification-token"]=verificationResult.token;self.do_checkout(data)}})}catch(err){self.log("3DS verification failed");self.log(err);self.render_errors([err.message])}}do_checkout(data){this.process_digital_wallet_checkout(data).then(response=>{window.location=response.redirect},response=>{this.log(response,"error");this.render_errors_html(response.messages)})}get_verification_details(billingContact,shippingContact){var verification_details={intent:"CHARGE",amount:this.total_amount,currencyCode:this.payment_request.currencyCode,billingContact:{familyName:billingContact.familyName?billingContact.familyName:"",givenName:billingContact.givenName?billingContact.givenName:"",email:shippingContact.email?shippingContact.email:"",countryCode:billingContact.countryCode?billingContact.countryCode.toUpperCase():"",state:billingContact.state?billingContact.state:"",city:billingContact.city?billingContact.city:"",postalCode:billingContact.postalCode?billingContact.postalCode:"",phone:shippingContact.phone?shippingContact.phone:"",addressLines:billingContact.addressLines?billingContact.addressLines:""}};this.log(verification_details);return verification_details}recalculate_totals(data){var _this6=this;return _asyncToGenerator(function*(){return new Promise((resolve,reject)=>{return $.post(_this6.get_ajax_url("recalculate_totals"),data,response=>{if(response.success){_this6.total_amount=response.data.total.amount;return resolve(response.data)}return reject(response.data)})})})()}get_product_data(){var product_id=$(".single_add_to_cart_button").val();var attributes={};if($(".single_variation_wrap").length){product_id=$(".single_variation_wrap").find("input[name=\"product_id\"]").val();if($(".variations_form").length){$(".variations_form").find(".variations select").each((index,select)=>{var attribute_name=$(select).data("attribute_name")||$(select).attr("name");var value=$(select).val()||"";return attributes[attribute_name]=value})}}return{product_id,quantity:$(".quantity .qty").val(),attributes}}add_to_cart(){var data={security:this.args.add_to_cart_nonce};var product_data=this.get_product_data();$.extend(data,product_data);$.post(this.get_ajax_url("add_to_cart"),data,response=>{if(response.error){return window.alert(response.data)}var data=JSON.parse(response.data);this.payment_request=data.payment_request;this.args.payment_request_nonce=data.payment_request_nonce;this.args.add_to_cart_nonce=data.add_to_cart_nonce;this.args.recalculate_totals_nonce=data.recalculate_totals_nonce;this.args.process_checkout_nonce=data.process_checkout_nonce})}process_digital_wallet_checkout(data){return new Promise((resolve,reject)=>{$.post(this.get_ajax_url("process_checkout"),data,response=>{if(response.result==="success"){return resolve(response)}return reject(response)})})}get_ajax_url(request){return this.args.ajax_url.replace("%%endpoint%%","square_digital_wallet_"+request)}render_errors_html(errors_html){$(".woocommerce-error, .woocommerce-message").remove();var element="";switch(this.args.context){case"product":element=$(".product");break;case"cart":element=$(".shop_table.cart").closest("form");break;case"checkout":element=$("form[name=\"checkout\"]");break;default:break;}element.before(errors_html);this.unblock_ui();$("html, body").animate({scrollTop:element.offset().top-100},1000)}render_errors(errors){var error_message_html="<ul class=\"woocommerce-error\"><li>"+errors.join("</li><li>")+"</li></ul>";this.render_errors_html(error_message_html)}block_ui(){$(this.buttons).block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}unblock_ui(){$(this.buttons).unblock()}log(message){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"notice";if(!this.args.logging_enabled){return}if(type==="error"){return console.error(message)}return console.log(message)}debounce(func,wait,immediate){var timeout;return function(){var context=this,args=arguments;var later=function later(){timeout=null;if(!immediate)func.apply(context,args)};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow)func.apply(context,args)}}}window.WC_Square_Digital_Wallet_Handler=WC_Square_Digital_Wallet_Handler});
assets/js/frontend/wc-square.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";jQuery(document).ready($=>{class WC_Square_Payment_Form_Handler{constructor(args){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;this.current_postal_code_value="";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",()=>{$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("")});$(document.body).on("change","#payment_method_".concat(this.id),()=>{if(this.payment_form){this.log("Recalculating payment form size");this.payment_form.recalculateSize()}})}handle_checkout_page(){$(document.body).on("updated_checkout",()=>this.set_payment_fields());$(document.body).on("updated_checkout",()=>this.handle_saved_payment_methods());this.form.on("checkout_place_order_".concat(this.id),()=>this.validate_payment_data())}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",()=>{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",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)}}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()}})}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()}})}set_payment_fields(){if(this.payment_form){this.log("Destroying payment form");this.payment_form.destroy().then(()=>{this.log("Re-building payment form");this.initializeCard(this.payments)});return}this.log("Building payment form");var{applicationId,locationId}=this.get_form_params();this.payments=window.Square.payments(applicationId,locationId);this.initializeCard(this.payments)}initializeCard(payments){var defaultPostalCode=$("#billing_postcode").val();defaultPostalCode=defaultPostalCode||"";payments.card({postalCode:defaultPostalCode}).then(card=>{card.attach("#wc-square-credit-card-container");this.payment_form=card;this.log("Payment form loaded")})}get_form_params(){return{applicationId:this.application_id,locationId:this.location_id}}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.payments.verifyBuyer(tokenized_card_id,this.get_verification_details()).then(verificationResult=>{this.handle_verify_buyer_response(false,verificationResult)});return false}this.log("Requesting payment nonce");this.block_ui();this.handleSubmission();return false}handleSubmission(){var tokenPromise=this.payment_form.tokenize();tokenPromise.then(tokenResult=>{var{token,details,status}=tokenResult;if(status==="OK"){this.handle_card_nonce_response(token,details)}else{if(tokenResult.errors){this.handle_errors(tokenResult.errors)}}})}get_tokenized_payment_method_id(){return $(".payment_method_".concat(this.id)).find(".js-wc-square-credit-card-payment-token:checked").val()}handle_card_nonce_response(nonce,details){var{card:cardData,billing}=details;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.last4){$("input[name=wc-".concat(this.id_dasherized,"-last-four]")).val(cardData.last4)}if(cardData.expMonth){$("input[name=wc-".concat(this.id_dasherized,"-exp-month]")).val(cardData.expMonth)}if(cardData.expYear){$("input[name=wc-".concat(this.id_dasherized,"-exp-year]")).val(cardData.expYear)}if(billing!==null&&billing!==void 0&&billing.postalCode){$("input[name=wc-".concat(this.id_dasherized,"-payment-postcode]")).val(billing.postalCode)}if(cardData.brand){$("input[name=wc-".concat(this.id_dasherized,"-card-type]")).val(cardData.brand)}$("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val(nonce);if(this.is_3ds_enabled){this.log("Verifying buyer");this.payments.verifyBuyer(nonce,this.get_verification_details()).then(verificationResult=>{this.handle_verify_buyer_response(false,verificationResult)});return}this.form.trigger("submit")}handle_verify_buyer_response(errors,verification_result){if(errors){$(errors).each((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")}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}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"}get_amount(){return $("input[name=wc-".concat(this.id_dasherized,"-amount]")).val()}handle_errors(){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((a,b)=>{return field_order.indexOf(a.field)-field_order.indexOf(b.field)})}$(errors).each((index,error)=>{if("UNSUPPORTED_CARD_BRAND"===error.type||"VALIDATION_ERROR"===error.type){return messages.push(error.message)}return this.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()}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)}block_ui(){this.form.block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}unblock_ui(){return this.form.unblock()}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()}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()}has_nonce(){return $("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val()}has_verification_token(){return $("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val()}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,data};$.ajax({url:this.ajax_url,data:ajax_data})}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)}}render_checkout_errors(square_errors){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:response=>{var result=response.responseJSON;if(result.hasOwnProperty("result")&&"failure"===result.result){$(result.messages).map(message=>{var errors=[];$(message).children("li").each(()=>{errors.push($(this).text().trim())});return square_errors.unshift(...errors)})}else if(result.hasOwnProperty("success")&&!result.success){square_errors.unshift(...result.data.messages)}square_handler.render_errors(square_errors)}})}}window.WC_Square_Payment_Form_Handler=WC_Square_Payment_Form_Handler});
1
+ "use strict";jQuery(document).ready($=>{class WC_Square_Payment_Form_Handler{constructor(args){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_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;this.current_postal_code_value="";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",()=>{$("input[name=wc-square-credit-card-payment-nonce]").val("");$("input[name=wc-square-credit-card-buyer-verification-token]").val("")});$(document.body).on("change","#payment_method_".concat(this.id),()=>{if(this.payment_form){this.log("Recalculating payment form size");this.payment_form.recalculateSize()}})}handle_checkout_page(){$(document.body).on("updated_checkout",()=>this.set_payment_fields());$(document.body).on("updated_checkout",()=>this.handle_saved_payment_methods());this.form.on("checkout_place_order_".concat(this.id),()=>this.validate_payment_data())}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",()=>{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",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)}}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()}})}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()}})}set_payment_fields(){if(this.payment_form){this.log("Destroying payment form");this.payment_form.destroy().then(()=>{this.log("Re-building payment form");this.initializeCard(this.payments)});return}this.log("Building payment form");var{applicationId,locationId}=this.get_form_params();this.payments=window.Square.payments(applicationId,locationId);this.initializeCard(this.payments)}initializeCard(payments){var defaultPostalCode=$("#billing_postcode").val();defaultPostalCode=defaultPostalCode||"";payments.card({postalCode:defaultPostalCode}).then(card=>{card.attach("#wc-square-credit-card-container");this.payment_form=card;this.log("Payment form loaded")})}get_form_params(){return{applicationId:this.application_id,locationId:this.location_id}}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.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.payments.verifyBuyer(tokenized_card_id,this.get_verification_details()).then(verificationResult=>{this.handle_verify_buyer_response(false,verificationResult)});return false}this.log("Requesting payment nonce");this.block_ui();this.handleSubmission();return false}handleSubmission(){var tokenPromise=this.payment_form.tokenize();tokenPromise.then(tokenResult=>{var{token,details,status}=tokenResult;if(status==="OK"){this.handle_card_nonce_response(token,details)}else{if(tokenResult.errors){this.handle_errors(tokenResult.errors)}}})}get_tokenized_payment_method_id(){return $(".payment_method_".concat(this.id)).find(".js-wc-square-credit-card-payment-token:checked").val()}handle_card_nonce_response(nonce,details){var{card:cardData,billing}=details;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.last4){$("input[name=wc-".concat(this.id_dasherized,"-last-four]")).val(cardData.last4)}if(cardData.expMonth){$("input[name=wc-".concat(this.id_dasherized,"-exp-month]")).val(cardData.expMonth)}if(cardData.expYear){$("input[name=wc-".concat(this.id_dasherized,"-exp-year]")).val(cardData.expYear)}if(billing!==null&&billing!==void 0&&billing.postalCode){$("input[name=wc-".concat(this.id_dasherized,"-payment-postcode]")).val(billing.postalCode)}if(cardData.brand){$("input[name=wc-".concat(this.id_dasherized,"-card-type]")).val(cardData.brand)}$("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val(nonce);this.log("Verifying buyer");this.payments.verifyBuyer(nonce,this.get_verification_details()).then(verificationResult=>{this.handle_verify_buyer_response(false,verificationResult)})}handle_verify_buyer_response(errors,verification_result){if(errors){$(errors).each((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")}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}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"}get_amount(){return $("input[name=wc-".concat(this.id_dasherized,"-amount]")).val()}handle_errors(){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((a,b)=>{return field_order.indexOf(a.field)-field_order.indexOf(b.field)})}$(errors).each((index,error)=>{if("UNSUPPORTED_CARD_BRAND"===error.type||"VALIDATION_ERROR"===error.type){return messages.push(error.message)}return this.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()}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)}block_ui(){this.form.block({message:null,overlayCSS:{background:"#fff",opacity:0.6}})}unblock_ui(){return this.form.unblock()}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()}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()}has_nonce(){return $("input[name=wc-".concat(this.id_dasherized,"-payment-nonce]")).val()}has_verification_token(){return $("input[name=wc-".concat(this.id_dasherized,"-buyer-verification-token]")).val()}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,data};$.ajax({url:this.ajax_url,data:ajax_data})}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)}}render_checkout_errors(square_errors){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:response=>{var result=response.responseJSON;if(result.hasOwnProperty("result")&&"failure"===result.result){$(result.messages).map(message=>{var errors=[];$(message).children("li").each(()=>{errors.push($(this).text().trim())});return square_errors.unshift(...errors)})}else if(result.hasOwnProperty("success")&&!result.success){square_errors.unshift(...result.data.messages)}square_handler.render_errors(square_errors)}})}}window.WC_Square_Payment_Form_Handler=WC_Square_Payment_Form_Handler});
build/index.asset.php CHANGED
@@ -1 +1 @@
1
- <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'fb7d2eefc86f7c746ceb39c3c41889c7');
1
+ <?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '05c7437d9a4702dc95e9a6ebb3e09a78');
build/index.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=30)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.regeneratorRuntime},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.React},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var a=r(n(3));t.Context=a.createContext({applePayState:"loading",formId:"",googlePayState:"loading",masterpassState:"loading",onCreateNonce:function(){},onVerifyBuyer:function(e,t,n){}}),t.default=t.Context},function(e,t){function n(e,t,n,r,a,o,i){try{var u=e[o](i),l=u.value}catch(e){return void n(e)}u.done?t(l):Promise.resolve(l).then(r,a)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(a,o){var i=e.apply(t,r);function u(e){n(i,a,o,u,l,"next",e)}function l(e){n(i,a,o,u,l,"throw",e)}u(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){var r=n(25),a=n(26),o=n(27),i=n(29);e.exports=function(e,t){return r(e)||a(e,t)||o(e,t)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0});var a=n(8);r(n(15)),r(n(4)),r(n(16)),r(n(17)),r(n(18)),r(n(19)),r(n(20)),r(n(21)),r(n(22)),r(n(23)),r(n(24)),r(n(8)),t.default=a.SquarePaymentForm},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(14)),u=a(n(4));t.SquarePaymentForm=function(e){var t=o.useState("loading"),n=t[0],r=t[1],a=o.useState("loading"),l=a[0],s=a[1],c=o.useState("loading"),d=c[0],f=c[1],p=o.useState(""),m=p[0],v=p[1],y=o.useState(!1),b=y[0],g=y[1],h=o.useState(void 0),_=h[0],O=h[1],C=o.useState(!1),S=C[0],x=C[1],P=i.default((function(t,n,r,a,o,i){!t&&e.createVerificationDetails?_&&_.verifyBuyer(n,e.createVerificationDetails(),(function(t,u){e.cardNonceResponseReceived(t?[t]:null,n,r,u?u.token:void 0,a,o,i)})):e.cardNonceResponseReceived(t,n,r,"",a,o,i)}));function E(t){var n=Object.keys(t);n.includes("masterpass")&&f(!0===t.masterpass?"ready":"unavailable"),n.includes("applePay")&&r(!0===t.applePay?"ready":"unavailable"),n.includes("googlePay")&&s(!0===t.googlePay?"ready":"unavailable"),e.methodsSupported&&e.methodsSupported(t)}var j=function(){x(!0),e.paymentFormLoaded&&e.paymentFormLoaded()};if(o.useEffect((function(){S&&_&&(_.recalculateSize(),e.postalCode&&_.setPostalCode(e.postalCode()),e.focusField&&_.focus(e.focusField()))}),[S,_]),o.useEffect((function(){!function(t,n){if(document.getElementById("sq-payment-form-script")&&"function"==typeof SqPaymentForm)t&&t();else{var r=document.createElement("script");r.id="sq-payment-form-script",e.sandbox?r.src="https://js.squareupsandbox.com/v2/paymentform":r.src="https://js.squareup.com/v2/paymentform",r.onload=function(){t&&t()},r.onerror=function(){n&&n()},document.body.appendChild(r)}}((function(){return g(!0)}),(function(){return v("Unable to load Square payment library")}))}),[]),o.useEffect((function(){return function(){if(!(!b||_||m.length>0))try{var t=new SqPaymentForm(function(e){var t={apiWrapper:e.apiWrapper,applicationId:e.applicationId,autoBuild:!1,callbacks:{cardNonceResponseReceived:e.cardNonceResponseReceived?P:null,createPaymentRequest:e.createPaymentRequest,inputEventReceived:e.inputEventReceived,methodsSupported:E,paymentFormLoaded:j,shippingContactChanged:e.shippingContactChanged,shippingOptionChanged:e.shippingOptionChanged,unsupportedBrowserDetected:e.unsupportedBrowserDetected},locationId:e.locationId};return document.getElementById(e.formId+"-sq-card")?t.card={elementId:e.formId+"-sq-card",inputStyle:e.inputStyles&&e.inputStyles[0]}:document.getElementById(e.formId+"-sq-gift-card")?(t.giftCard={elementId:e.formId+"-sq-gift-card",placeholder:e.placeholderGiftCard||"• • • • • • • • • • • • • • • •"},t.inputClass=e.inputClass||"sq-input",t.inputStyles=e.inputStyles):(t.inputClass=e.inputClass||"sq-input",t.inputStyles=e.inputStyles,document.getElementById(e.formId+"-sq-apple-pay")&&(t.applePay={elementId:e.formId+"-sq-apple-pay"}),document.getElementById(e.formId+"-sq-google-pay")&&(t.googlePay={elementId:e.formId+"-sq-google-pay"}),document.getElementById(e.formId+"-sq-masterpass")&&(t.masterpass={elementId:e.formId+"-sq-masterpass"}),document.getElementById(e.formId+"-sq-card-number")&&(t.cardNumber={elementId:e.formId+"-sq-card-number",placeholder:e.placeholderCreditCard||"• • • • • • • • • • • • • • • •"}),document.getElementById(e.formId+"-sq-cvv")&&(t.cvv={elementId:e.formId+"-sq-cvv",placeholder:e.placeholderCVV||"CVV "}),document.getElementById(e.formId+"-sq-postal-code")?t.postalCode={elementId:e.formId+"-sq-postal-code",placeholder:e.placeholderPostal||"12345"}:t.postalCode=!1,document.getElementById(e.formId+"-sq-expiration-date")&&(t.expirationDate={elementId:e.formId+"-sq-expiration-date",placeholder:e.placeholderExpiration||"MM/YY"})),t}(e));t.build(),O(t)}catch(e){var n=e.message||"Unable to build Square payment form";v(n)}}(),function(){_&&(_.destroy(),O(void 0))}}),[b]),o.useEffect((function(){if(_&&"ready"===d){var t=document.getElementById(e.formId+"-sq-masterpass");if(t){var n=_.masterpassImageUrl();t.style.display="inline-block",t.style.backgroundImage="url("+n+")"}}}),[_,d]),m)return o.default.createElement("div",{className:"sq-payment-form"},o.default.createElement("div",{className:"sq-error-message"},m));var w={applePayState:n,formId:e.formId,googlePayState:l,masterpassState:d,onCreateNonce:function(){_&&_.requestCardNonce()},onVerifyBuyer:function(e,t,n){_&&_.verifyBuyer(e,t,n)}};return o.default.createElement(u.default.Provider,{value:w},o.default.createElement("div",{id:e.formId,className:"sq-payment-form"},e.children))},t.SquarePaymentForm.defaultProps={apiWrapper:"reactjs/0.7.2",formId:"sq-payment-form",inputStyles:[{_mozOsxFontSmoothing:"grayscale",_webkitFontSmoothing:"antialiased",backgroundColor:"transparent",color:"#373F4A",fontFamily:"Helvetica Neue",fontSize:"16px",lineHeight:"24px",padding:"16px",placeholderColor:"#CCC"}],sandbox:!1}},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,n){var r=n(12);e.exports=function(e,t){if(null==e)return{};var n,a,o=r(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wp.i18n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3);t.default=function(e){var t=r.useRef(e);return r.useLayoutEffect((function(){t.current=e}),[e]),r.useCallback((function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.current.apply(t,e)}),[])}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.ApplePayButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-apple-pay",className:"sq-apple-pay",style:{display:"ready"===t.applePayState?"block":"none"}}),"loading"===t.applePayState&&e.loadingView,"unavailable"===t.applePayState&&e.unavailableView)}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardCVVInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-cvv"}))},t.CreditCardCVVInput.defaultProps={label:"CVV"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardExpirationDateInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-expiration-date"}))},t.CreditCardExpirationDateInput.defaultProps={label:"Expiration"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardNumberInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-card-number"}))},t.CreditCardNumberInput.defaultProps={label:"Credit Card"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardPostalCodeInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-postal-code"}))},t.CreditCardPostalCodeInput.defaultProps={label:"Postal"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardSubmitButton=function(e){var t=o.useContext(i.default);return o.default.createElement("button",{className:"sq-creditcard",onClick:t.onCreateNonce},e.children?e.children:"Pay")}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.GiftCardInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-gift-card"}))},t.GiftCardInput.defaultProps={label:"Gift Card"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.GooglePayButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-google-pay",className:"sq-google-pay",style:{display:"ready"===t.googlePayState?"block":"none"}}),"loading"===t.googlePayState&&e.loadingView,"unavailable"===t.googlePayState&&e.unavailableView)}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.MasterpassButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-masterpass",className:"sq-masterpass",style:{display:"ready"===t.masterpassState?"block":"none"}}),"loading"===t.masterpassState&&e.loadingView,"unavailable"===t.masterpassState&&e.unavailableView)}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.SimpleCard=function(){var e=o.useContext(i.default);return o.default.createElement("div",{id:e.formId+"-sq-card"})}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],_n=!0,i=!1;try{for(n=n.call(e);!(_n=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);_n=!0);}catch(e){i=!0,a=e}finally{try{_n||null==n.return||n.return()}finally{if(i)throw a}}return o}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){var r=n(28);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){"use strict";n.r(t);var r=n(9),a=n(10),o=n.n(a),i=n(0),u=(n(13),n(7)),l=n(2),s=n.n(l),c=n(5),d=n.n(c),f=n(1),p=n.n(f),m=n(11);function v(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return y(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){u=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw o}}}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var b=null,g=function(){if(null!==b)return b;var e=Object(m.getSetting)("square_credit_card_data",null);if(!e)throw new Error("Square initialization data is not available");return b={title:e.title||"",applicationId:e.application_id||"",locationId:e.location_id||"",isSandbox:e.is_sandbox||!1,is3dsEnabled:e.is_3ds_enabled||!1,inputStyles:e.input_styles||[],availableCardTypes:e.available_card_types||{},loggingEnabled:e.logging_enabled||!1,generalError:e.general_error||"",showSavedCards:e.show_saved_cards||!1,showSaveOption:e.show_save_option||!1,supports:e.supports||{}}},h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{logs:[],notices:[]},n=!1;if(e){var r=["none","cardNumber","expirationDate","cvv","postalCode"];e.length>=1&&e.sort((function(e,t){return r.indexOf(e.field)-r.indexOf(t.field)}));var a,o=v(e);try{for(o.s();!(a=o.n()).done;){var i=a.value;"UNSUPPORTED_CARD_BRAND"===i.type||"VALIDATION_ERROR"===i.type?(t.notices.push(i.message.replace(/CVV/,"CSC")),n=!0):O(i,t)}}catch(e){o.e(e)}finally{o.f()}}n||t.notices.push(g().generalError)},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notice";g().loggingEnabled&&("error"===t?console.error(e):console.log(e))},O=function(e,t){g().loggingEnabled&&t&&t.logs.push(e)};function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?C(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var x=Object(i.createContext)(!1),P=function(e){var t=e.checkoutFormHandler,n=e.eventRegistration,r=e.emitResponse,a=Object(i.useContext)(x),o=n.onPaymentProcessing,u=n.onCheckoutAfterProcessingWithError,l=n.onCheckoutAfterProcessingWithSuccess;return function(e,t,n,r,a,o){var u=Object(i.useRef)(n);Object(i.useEffect)((function(){u.current=n}),[n]),Object(i.useEffect)((function(){return e(function(){var e=d()(p.a.mark((function e(){var n,i,l,s,c,d,f,m;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l={type:t.responseTypes.SUCCESS},s={nonce:"",notices:[],logs:[]},e.next=4,a(u.current.card);case 4:if(c=e.sent,d=S(S({},s),{},{nonce:c.token}),null!=c&&null!==(n=c.details)&&void 0!==n&&n.card&&null!=c&&null!==(i=c.details)&&void 0!==i&&i.billing&&(d.cardData=S(S({},c.details.card),c.details.billing)),f=d.token||d.nonce,!g().is3dsEnabled||!f){e.next=15;break}return e.next=11,o(u.current.payments,f);case 11:m=e.sent,d.verificationToken=m.verificationToken||"",d.logs=d.logs.concat(m.log||[]),d.errors=d.notices.concat(m.errors||[]);case 15:return f||d.logs.length>0?l.meta={paymentMethodData:r(d)}:d.notices.length>0&&(l.type=t.responseTypes.ERROR,l.message=d.notices),e.abrupt("return",l);case 17:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}())}),[e,t.responseTypes.SUCCESS,t.responseTypes.ERROR,a,o,r])}(o,r,a,t.getPaymentMethodData,t.createNonce,t.verifyBuyer),function(e,t,n){Object(i.useEffect)((function(){var r=function(e){var t={type:n.responseTypes.SUCCESS},r=e.processingResponse,a=r.paymentStatus,o=r.paymentDetails;return a===n.responseTypes.ERROR&&o.checkoutNotices&&(t={type:n.responseTypes.ERROR,message:JSON.parse(o.checkoutNotices),messageContext:n.noticeContexts.PAYMENTS,retry:!0}),t},a=e(r),o=t(r);return function(){a(),o()}}),[e,t,n.noticeContexts.PAYMENTS,n.responseTypes.ERROR,n.responseTypes.SUCCESS])}(u,l,r),null},E=n(6),j=n.n(E),w=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=Object(i.useState)(!1),a=j()(r,2),o=a[0],u=a[1],l=Object(i.useState)(""),c=j()(l,2),f=c[0],m=c[1],v=Object(i.useRef)(null),y=Object(i.useRef)(null),b=Object(i.useMemo)((function(){var r=t&&!n?"STORE":"CHARGE",a={billingContact:{familyName:e.billingData.last_name||"",givenName:e.billingData.first_name||"",email:e.billingData.email||"",country:e.billingData.country||"",region:e.billingData.state||"",city:e.billingData.city||"",postalCode:e.billingData.postcode||"",phone:e.billingData.phone||"",addressLines:[e.billingData.address_1||"",e.billingData.address_2||""]},intent:r};return"CHARGE"===r&&(a.amount=(e.cartTotal.value/100).toString(),a.currencyCode=e.currency.code),a}),[e.billingData,e.cartTotal.value,e.currency.code,t,n]),C=Object(i.useCallback)((function(e){var r,a,o,i=e.cardData,u=void 0===i?{}:i,l=e.nonce,c=e.verificationToken,d=e.notices,p=e.logs;return o={},s()(o,"wc-".concat("square-credit-card","-card-type"),f||""),s()(o,"wc-".concat("square-credit-card","-last-four"),(null==u?void 0:u.last4)||""),s()(o,"wc-".concat("square-credit-card","-exp-month"),(null==u||null===(r=u.expMonth)||void 0===r?void 0:r.toString())||""),s()(o,"wc-".concat("square-credit-card","-exp-year"),(null==u||null===(a=u.expYear)||void 0===a?void 0:a.toString())||""),s()(o,"wc-".concat("square-credit-card","-payment-postcode"),(null==u?void 0:u.postalCode)||""),s()(o,"wc-".concat("square-credit-card","-payment-nonce"),l||""),s()(o,"wc-".concat("square-credit-card","-payment-token"),n||""),s()(o,"wc-".concat("square-credit-card","-buyer-verification-token"),c||""),s()(o,"wc-".concat("square-credit-card","-tokenize-payment-method"),t||!1),s()(o,"log-data",p.length>0?JSON.stringify(p):""),s()(o,"checkout-notices",d.length>0?JSON.stringify(d):""),o}),[f,t,n]),S=function(e,t,n){var r={notices:[],logs:[]};e?h(e,r):t?(O(n,r),_("Card data received"),_(n),r.cardData=n,r.nonce=t):(O("Nonce is missing from the Square response",r),_("Nonce is missing from the Square response","error"),h([],r)),v.current&&v.current(r)},x=Object(i.useCallback)(function(){var e=d()(p.a.mark((function e(t){return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=4;break}return e.next=3,t.tokenize();case 3:return e.abrupt("return",e.sent);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}(),[n]),P=Object(i.useCallback)(function(){var e=d()(p.a.mark((function e(t,n){var r;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.verifyBuyer(n,b);case 3:return r=e.sent,e.abrupt("return",E(r));case 7:e.prev=7,e.t0=e.catch(0),h([e.t0]);case 10:return e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t,n){return e.apply(this,arguments)}}(),[b,E]),E=Object(i.useCallback)((function(e){var t={notices:[],logs:[]};return e&&e.token?t.verificationToken=e.token:(O("Verification token is missing from the Square response",t),_("Verification token is missing from the Square response","error"),h([],t)),t}),[y]),w=Object(i.useCallback)((function(e){if("cardBrandChanged"===e.eventType){var t=e.cardBrand,n="plain";null!==t&&"unknown"!==t||(n=""),null!==g().availableCardTypes[t]&&(n=g().availableCardTypes[t]),_("Card brand changed to ".concat(t)),m(n)}}),[]),I=Object(i.useCallback)((function(){return e.billingData.postcode||""}),[e.billingData.postcode]);return{cardNonceResponseReceived:S,handleInputReceived:w,isLoaded:o,setLoaded:u,getPostalCode:I,cardType:f,createNonce:x,verifyBuyer:P,getPaymentMethodData:C}},I=function(e){var t=e.children,n=e.defaults.postalCode,r=void 0===n?"":n,a=Object(i.useState)(!1),o=j()(a,2),u=o[0],l=o[1],s=Object(i.useState)(!1),c=j()(s,2),f=c[0],m=c[1],v=g(),y=v.applicationId,b=v.locationId;return Object(i.useEffect)((function(){!u&&window.Square&&l(window.Square.payments(y,b))}),[u]),Object(i.useEffect)((function(){u&&!f&&function(){var e=d()(p.a.mark((function e(){var t;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.card({postalCode:r});case 2:t=e.sent,m(t);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()()}),[u]),u?Object(i.createElement)(x.Provider,{value:{payments:u,card:f}},t):null},q=function(){var e=Object(i.useContext)(x).card,t=Object(i.useRef)(!1);return Object(i.useEffect)((function(){e&&function(){var n=d()(p.a.mark((function n(){return p.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:e.attach(t.current);case 1:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()()}),[e]),Object(i.createElement)("div",{ref:t})},M=function(e){var t=e.billing,n=e.eventRegistration,r=e.emitResponse,a=e.shouldSavePayment,o=w(t,a);return Object(i.createElement)(I,{defaults:{postalCode:o.getPostalCode()}},Object(i.createElement)(q,null),Object(i.createElement)(P,{checkoutFormHandler:o,eventRegistration:n,emitResponse:r}))},R=["RenderedComponent"],k=function(e){var t=e.RenderedComponent,n=o()(e,R);return Object(i.createElement)(t,n)},D={name:"square-credit-card",label:Object(i.createElement)((function(e){var t=e.components.PaymentMethodLabel;return Object(i.createElement)(t,{text:g().title})}),null),content:Object(i.createElement)(k,{RenderedComponent:M}),edit:Object(i.createElement)(k,{RenderedComponent:M}),savedTokenComponent:Object(i.createElement)(k,{RenderedComponent:function(e){var t=e.billing,n=e.eventRegistration,r=e.emitResponse,a=e.token,o=w(t,!1,a);return Object(i.createElement)(u.SquarePaymentForm,{formId:"square-credit-card-saved-card",sandbox:g().isSandbox,applicationId:g().applicationId,locationId:g().locationId,paymentFormLoaded:function(){return o.setLoaded(!0)}},o.isLoaded&&Object(i.createElement)(P,{checkoutFormHandler:o,eventRegistration:n,emitResponse:r}))}}),paymentMethodId:"square_credit_card",ariaLabel:"Square",canMakePayment:function(){return!(!g().applicationId||!g().locationId)},supports:{features:g().supports,showSavedCards:g().showSavedCards,showSaveOption:g().showSaveOption}};Object(r.registerPaymentMethod)(D)}]);
1
+ !function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=30)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.regeneratorRuntime},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.React},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var a=r(n(3));t.Context=a.createContext({applePayState:"loading",formId:"",googlePayState:"loading",masterpassState:"loading",onCreateNonce:function(){},onVerifyBuyer:function(e,t,n){}}),t.default=t.Context},function(e,t){function n(e,t,n,r,a,o,i){try{var u=e[o](i),l=u.value}catch(e){return void n(e)}u.done?t(l):Promise.resolve(l).then(r,a)}e.exports=function(e){return function(){var t=this,r=arguments;return new Promise((function(a,o){var i=e.apply(t,r);function u(e){n(i,a,o,u,l,"next",e)}function l(e){n(i,a,o,u,l,"throw",e)}u(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){var r=n(25),a=n(26),o=n(27),i=n(29);e.exports=function(e,t){return r(e)||a(e,t)||o(e,t)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0});var a=n(8);r(n(15)),r(n(4)),r(n(16)),r(n(17)),r(n(18)),r(n(19)),r(n(20)),r(n(21)),r(n(22)),r(n(23)),r(n(24)),r(n(8)),t.default=a.SquarePaymentForm},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(14)),u=a(n(4));t.SquarePaymentForm=function(e){var t=o.useState("loading"),n=t[0],r=t[1],a=o.useState("loading"),l=a[0],s=a[1],c=o.useState("loading"),d=c[0],f=c[1],p=o.useState(""),m=p[0],v=p[1],y=o.useState(!1),b=y[0],g=y[1],h=o.useState(void 0),_=h[0],O=h[1],C=o.useState(!1),S=C[0],x=C[1],P=i.default((function(t,n,r,a,o,i){!t&&e.createVerificationDetails?_&&_.verifyBuyer(n,e.createVerificationDetails(),(function(t,u){e.cardNonceResponseReceived(t?[t]:null,n,r,u?u.token:void 0,a,o,i)})):e.cardNonceResponseReceived(t,n,r,"",a,o,i)}));function j(t){var n=Object.keys(t);n.includes("masterpass")&&f(!0===t.masterpass?"ready":"unavailable"),n.includes("applePay")&&r(!0===t.applePay?"ready":"unavailable"),n.includes("googlePay")&&s(!0===t.googlePay?"ready":"unavailable"),e.methodsSupported&&e.methodsSupported(t)}var E=function(){x(!0),e.paymentFormLoaded&&e.paymentFormLoaded()};if(o.useEffect((function(){S&&_&&(_.recalculateSize(),e.postalCode&&_.setPostalCode(e.postalCode()),e.focusField&&_.focus(e.focusField()))}),[S,_]),o.useEffect((function(){!function(t,n){if(document.getElementById("sq-payment-form-script")&&"function"==typeof SqPaymentForm)t&&t();else{var r=document.createElement("script");r.id="sq-payment-form-script",e.sandbox?r.src="https://js.squareupsandbox.com/v2/paymentform":r.src="https://js.squareup.com/v2/paymentform",r.onload=function(){t&&t()},r.onerror=function(){n&&n()},document.body.appendChild(r)}}((function(){return g(!0)}),(function(){return v("Unable to load Square payment library")}))}),[]),o.useEffect((function(){return function(){if(!(!b||_||m.length>0))try{var t=new SqPaymentForm(function(e){var t={apiWrapper:e.apiWrapper,applicationId:e.applicationId,autoBuild:!1,callbacks:{cardNonceResponseReceived:e.cardNonceResponseReceived?P:null,createPaymentRequest:e.createPaymentRequest,inputEventReceived:e.inputEventReceived,methodsSupported:j,paymentFormLoaded:E,shippingContactChanged:e.shippingContactChanged,shippingOptionChanged:e.shippingOptionChanged,unsupportedBrowserDetected:e.unsupportedBrowserDetected},locationId:e.locationId};return document.getElementById(e.formId+"-sq-card")?t.card={elementId:e.formId+"-sq-card",inputStyle:e.inputStyles&&e.inputStyles[0]}:document.getElementById(e.formId+"-sq-gift-card")?(t.giftCard={elementId:e.formId+"-sq-gift-card",placeholder:e.placeholderGiftCard||"• • • • • • • • • • • • • • • •"},t.inputClass=e.inputClass||"sq-input",t.inputStyles=e.inputStyles):(t.inputClass=e.inputClass||"sq-input",t.inputStyles=e.inputStyles,document.getElementById(e.formId+"-sq-apple-pay")&&(t.applePay={elementId:e.formId+"-sq-apple-pay"}),document.getElementById(e.formId+"-sq-google-pay")&&(t.googlePay={elementId:e.formId+"-sq-google-pay"}),document.getElementById(e.formId+"-sq-masterpass")&&(t.masterpass={elementId:e.formId+"-sq-masterpass"}),document.getElementById(e.formId+"-sq-card-number")&&(t.cardNumber={elementId:e.formId+"-sq-card-number",placeholder:e.placeholderCreditCard||"• • • • • • • • • • • • • • • •"}),document.getElementById(e.formId+"-sq-cvv")&&(t.cvv={elementId:e.formId+"-sq-cvv",placeholder:e.placeholderCVV||"CVV "}),document.getElementById(e.formId+"-sq-postal-code")?t.postalCode={elementId:e.formId+"-sq-postal-code",placeholder:e.placeholderPostal||"12345"}:t.postalCode=!1,document.getElementById(e.formId+"-sq-expiration-date")&&(t.expirationDate={elementId:e.formId+"-sq-expiration-date",placeholder:e.placeholderExpiration||"MM/YY"})),t}(e));t.build(),O(t)}catch(e){var n=e.message||"Unable to build Square payment form";v(n)}}(),function(){_&&(_.destroy(),O(void 0))}}),[b]),o.useEffect((function(){if(_&&"ready"===d){var t=document.getElementById(e.formId+"-sq-masterpass");if(t){var n=_.masterpassImageUrl();t.style.display="inline-block",t.style.backgroundImage="url("+n+")"}}}),[_,d]),m)return o.default.createElement("div",{className:"sq-payment-form"},o.default.createElement("div",{className:"sq-error-message"},m));var w={applePayState:n,formId:e.formId,googlePayState:l,masterpassState:d,onCreateNonce:function(){_&&_.requestCardNonce()},onVerifyBuyer:function(e,t,n){_&&_.verifyBuyer(e,t,n)}};return o.default.createElement(u.default.Provider,{value:w},o.default.createElement("div",{id:e.formId,className:"sq-payment-form"},e.children))},t.SquarePaymentForm.defaultProps={apiWrapper:"reactjs/0.7.2",formId:"sq-payment-form",inputStyles:[{_mozOsxFontSmoothing:"grayscale",_webkitFontSmoothing:"antialiased",backgroundColor:"transparent",color:"#373F4A",fontFamily:"Helvetica Neue",fontSize:"16px",lineHeight:"24px",padding:"16px",placeholderColor:"#CCC"}],sandbox:!1}},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t,n){var r=n(12);e.exports=function(e,t){if(null==e)return{};var n,a,o=r(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=window.wp.i18n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3);t.default=function(e){var t=r.useRef(e);return r.useLayoutEffect((function(){t.current=e}),[e]),r.useCallback((function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.current.apply(t,e)}),[])}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.ApplePayButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-apple-pay",className:"sq-apple-pay",style:{display:"ready"===t.applePayState?"block":"none"}}),"loading"===t.applePayState&&e.loadingView,"unavailable"===t.applePayState&&e.unavailableView)}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardCVVInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-cvv"}))},t.CreditCardCVVInput.defaultProps={label:"CVV"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardExpirationDateInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-expiration-date"}))},t.CreditCardExpirationDateInput.defaultProps={label:"Expiration"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardNumberInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-card-number"}))},t.CreditCardNumberInput.defaultProps={label:"Credit Card"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardPostalCodeInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-postal-code"}))},t.CreditCardPostalCodeInput.defaultProps={label:"Postal"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.CreditCardSubmitButton=function(e){var t=o.useContext(i.default);return o.default.createElement("button",{className:"sq-creditcard",onClick:t.onCreateNonce},e.children?e.children:"Pay")}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.GiftCardInput=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,e.label&&o.default.createElement("span",{className:"sq-label"},e.label),o.default.createElement("div",{id:t.formId+"-sq-gift-card"}))},t.GiftCardInput.defaultProps={label:"Gift Card"}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.GooglePayButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-google-pay",className:"sq-google-pay",style:{display:"ready"===t.googlePayState?"block":"none"}}),"loading"===t.googlePayState&&e.loadingView,"unavailable"===t.googlePayState&&e.unavailableView)}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.MasterpassButton=function(e){var t=o.useContext(i.default);return o.default.createElement("div",null,o.default.createElement("button",{id:t.formId+"-sq-masterpass",className:"sq-masterpass",style:{display:"ready"===t.masterpassState?"block":"none"}}),"loading"===t.masterpassState&&e.loadingView,"unavailable"===t.masterpassState&&e.unavailableView)}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(3)),i=a(n(4));t.SimpleCard=function(){var e=o.useContext(i.default);return o.default.createElement("div",{id:e.formId+"-sq-card"})}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],_n=!0,i=!1;try{for(n=n.call(e);!(_n=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);_n=!0);}catch(e){i=!0,a=e}finally{try{_n||null==n.return||n.return()}finally{if(i)throw a}}return o}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){var r=n(28);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,n){"use strict";n.r(t);var r=n(9),a=n(10),o=n.n(a),i=n(0),u=(n(13),n(7)),l=n(2),s=n.n(l),c=n(5),d=n.n(c),f=n(1),p=n.n(f),m=n(11);function v(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return y(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){u=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw o}}}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var b=null,g=function(){if(null!==b)return b;var e=Object(m.getSetting)("square_credit_card_data",null);if(!e)throw new Error("Square initialization data is not available");return b={title:e.title||"",applicationId:e.application_id||"",locationId:e.location_id||"",isSandbox:e.is_sandbox||!1,inputStyles:e.input_styles||[],availableCardTypes:e.available_card_types||{},loggingEnabled:e.logging_enabled||!1,generalError:e.general_error||"",showSavedCards:e.show_saved_cards||!1,showSaveOption:e.show_save_option||!1,supports:e.supports||{}}},h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{logs:[],notices:[]},n=!1;if(e){var r=["none","cardNumber","expirationDate","cvv","postalCode"];e.length>=1&&e.sort((function(e,t){return r.indexOf(e.field)-r.indexOf(t.field)}));var a,o=v(e);try{for(o.s();!(a=o.n()).done;){var i=a.value;"UNSUPPORTED_CARD_BRAND"===i.type||"VALIDATION_ERROR"===i.type?(t.notices.push(i.message.replace(/CVV/,"CSC")),n=!0):O(i,t)}}catch(e){o.e(e)}finally{o.f()}}n||t.notices.push(g().generalError)},_=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"notice";g().loggingEnabled&&("error"===t?console.error(e):console.log(e))},O=function(e,t){g().loggingEnabled&&t&&t.logs.push(e)};function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?C(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var x=Object(i.createContext)(!1),P=function(e){var t=e.checkoutFormHandler,n=e.eventRegistration,r=e.emitResponse,a=Object(i.useContext)(x),o=n.onPaymentProcessing,u=n.onCheckoutAfterProcessingWithError,l=n.onCheckoutAfterProcessingWithSuccess;return function(e,t,n,r,a,o){var u=Object(i.useRef)(n);Object(i.useEffect)((function(){u.current=n}),[n]),Object(i.useEffect)((function(){return e(function(){var e=d()(p.a.mark((function e(){var n,i,l,s,c,d,f,m;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l={type:t.responseTypes.SUCCESS},s={nonce:"",notices:[],logs:[]},e.next=4,a(u.current.card);case 4:if(c=e.sent,d=S(S({},s),{},{nonce:c.token}),null!=c&&null!==(n=c.details)&&void 0!==n&&n.card&&null!=c&&null!==(i=c.details)&&void 0!==i&&i.billing&&(d.cardData=S(S({},c.details.card),c.details.billing)),!(f=d.token||d.nonce)){e.next=15;break}return e.next=11,o(u.current.payments,f);case 11:m=e.sent,d.verificationToken=m.verificationToken||"",d.logs=d.logs.concat(m.log||[]),d.errors=d.notices.concat(m.errors||[]);case 15:return f||d.logs.length>0?l.meta={paymentMethodData:r(d)}:d.notices.length>0&&(l.type=t.responseTypes.ERROR,l.message=d.notices),e.abrupt("return",l);case 17:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}())}),[e,t.responseTypes.SUCCESS,t.responseTypes.ERROR,a,o,r])}(o,r,a,t.getPaymentMethodData,t.createNonce,t.verifyBuyer),function(e,t,n){Object(i.useEffect)((function(){var r=function(e){var t={type:n.responseTypes.SUCCESS},r=e.processingResponse,a=r.paymentStatus,o=r.paymentDetails;return a===n.responseTypes.ERROR&&o.checkoutNotices&&(t={type:n.responseTypes.ERROR,message:JSON.parse(o.checkoutNotices),messageContext:n.noticeContexts.PAYMENTS,retry:!0}),t},a=e(r),o=t(r);return function(){a(),o()}}),[e,t,n.noticeContexts.PAYMENTS,n.responseTypes.ERROR,n.responseTypes.SUCCESS])}(u,l,r),null},j=n(6),E=n.n(j),w=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=Object(i.useState)(!1),a=E()(r,2),o=a[0],u=a[1],l=Object(i.useState)(""),c=E()(l,2),f=c[0],m=c[1],v=Object(i.useRef)(null),y=Object(i.useRef)(null),b=Object(i.useMemo)((function(){var r=t&&!n?"STORE":"CHARGE",a={billingContact:{familyName:e.billingData.last_name||"",givenName:e.billingData.first_name||"",email:e.billingData.email||"",country:e.billingData.country||"",region:e.billingData.state||"",city:e.billingData.city||"",postalCode:e.billingData.postcode||"",phone:e.billingData.phone||"",addressLines:[e.billingData.address_1||"",e.billingData.address_2||""]},intent:r};return"CHARGE"===r&&(a.amount=(e.cartTotal.value/100).toString(),a.currencyCode=e.currency.code),a}),[e.billingData,e.cartTotal.value,e.currency.code,t,n]),C=Object(i.useCallback)((function(e){var r,a,o,i=e.cardData,u=void 0===i?{}:i,l=e.nonce,c=e.verificationToken,d=e.notices,p=e.logs;return o={},s()(o,"wc-".concat("square-credit-card","-card-type"),f||""),s()(o,"wc-".concat("square-credit-card","-last-four"),(null==u?void 0:u.last4)||""),s()(o,"wc-".concat("square-credit-card","-exp-month"),(null==u||null===(r=u.expMonth)||void 0===r?void 0:r.toString())||""),s()(o,"wc-".concat("square-credit-card","-exp-year"),(null==u||null===(a=u.expYear)||void 0===a?void 0:a.toString())||""),s()(o,"wc-".concat("square-credit-card","-payment-postcode"),(null==u?void 0:u.postalCode)||""),s()(o,"wc-".concat("square-credit-card","-payment-nonce"),l||""),s()(o,"wc-".concat("square-credit-card","-payment-token"),n||""),s()(o,"wc-".concat("square-credit-card","-buyer-verification-token"),c||""),s()(o,"wc-".concat("square-credit-card","-tokenize-payment-method"),t||!1),s()(o,"log-data",p.length>0?JSON.stringify(p):""),s()(o,"checkout-notices",d.length>0?JSON.stringify(d):""),o}),[f,t,n]),S=function(e,t,n){var r={notices:[],logs:[]};e?h(e,r):t?(O(n,r),_("Card data received"),_(n),r.cardData=n,r.nonce=t):(O("Nonce is missing from the Square response",r),_("Nonce is missing from the Square response","error"),h([],r)),v.current&&v.current(r)},x=Object(i.useCallback)(function(){var e=d()(p.a.mark((function e(t){return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=4;break}return e.next=3,t.tokenize();case 3:return e.abrupt("return",e.sent);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}(),[n]),P=Object(i.useCallback)(function(){var e=d()(p.a.mark((function e(t,n){var r;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.verifyBuyer(n,b);case 3:return r=e.sent,e.abrupt("return",j(r));case 7:e.prev=7,e.t0=e.catch(0),h([e.t0]);case 10:return e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(t,n){return e.apply(this,arguments)}}(),[b,j]),j=Object(i.useCallback)((function(e){var t={notices:[],logs:[]};return e&&e.token?t.verificationToken=e.token:(O("Verification token is missing from the Square response",t),_("Verification token is missing from the Square response","error"),h([],t)),t}),[y]),w=Object(i.useCallback)((function(e){if("cardBrandChanged"===e.eventType){var t=e.cardBrand,n="plain";null!==t&&"unknown"!==t||(n=""),null!==g().availableCardTypes[t]&&(n=g().availableCardTypes[t]),_("Card brand changed to ".concat(t)),m(n)}}),[]),I=Object(i.useCallback)((function(){return e.billingData.postcode||""}),[e.billingData.postcode]);return{cardNonceResponseReceived:S,handleInputReceived:w,isLoaded:o,setLoaded:u,getPostalCode:I,cardType:f,createNonce:x,verifyBuyer:P,getPaymentMethodData:C}},I=function(e){var t=e.children,n=e.defaults.postalCode,r=void 0===n?"":n,a=Object(i.useState)(!1),o=E()(a,2),u=o[0],l=o[1],s=Object(i.useState)(!1),c=E()(s,2),f=c[0],m=c[1],v=g(),y=v.applicationId,b=v.locationId;return Object(i.useEffect)((function(){!u&&window.Square&&l(window.Square.payments(y,b))}),[u]),Object(i.useEffect)((function(){u&&!f&&function(){var e=d()(p.a.mark((function e(){var t;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.card({postalCode:r});case 2:t=e.sent,m(t);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()()}),[u]),u?Object(i.createElement)(x.Provider,{value:{payments:u,card:f}},t):null},q=function(){var e=Object(i.useContext)(x).card,t=Object(i.useRef)(!1);return Object(i.useEffect)((function(){e&&function(){var n=d()(p.a.mark((function n(){return p.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:e.attach(t.current);case 1:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()()}),[e]),Object(i.createElement)("div",{ref:t})},M=function(e){var t=e.billing,n=e.eventRegistration,r=e.emitResponse,a=e.shouldSavePayment,o=w(t,a);return Object(i.createElement)(I,{defaults:{postalCode:o.getPostalCode()}},Object(i.createElement)(q,null),Object(i.createElement)(P,{checkoutFormHandler:o,eventRegistration:n,emitResponse:r}))},R=["RenderedComponent"],k=function(e){var t=e.RenderedComponent,n=o()(e,R);return Object(i.createElement)(t,n)},D={name:"square-credit-card",label:Object(i.createElement)((function(e){var t=e.components.PaymentMethodLabel;return Object(i.createElement)(t,{text:g().title})}),null),content:Object(i.createElement)(k,{RenderedComponent:M}),edit:Object(i.createElement)(k,{RenderedComponent:M}),savedTokenComponent:Object(i.createElement)(k,{RenderedComponent:function(e){var t=e.billing,n=e.eventRegistration,r=e.emitResponse,a=e.token,o=w(t,!1,a);return Object(i.createElement)(u.SquarePaymentForm,{formId:"square-credit-card-saved-card",sandbox:g().isSandbox,applicationId:g().applicationId,locationId:g().locationId,paymentFormLoaded:function(){return o.setLoaded(!0)}},o.isLoaded&&Object(i.createElement)(P,{checkoutFormHandler:o,eventRegistration:n,emitResponse:r}))}}),paymentMethodId:"square_credit_card",ariaLabel:"Square",canMakePayment:function(){return!(!g().applicationId||!g().locationId)},supports:{features:g().supports,showSavedCards:g().showSavedCards,showSaveOption:g().showSaveOption}};Object(r.registerPaymentMethod)(D)}]);
changelog.txt CHANGED
@@ -1,5 +1,29 @@
1
  *** WooCommerce Square Changelog ***
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 3.2.0 - 2022-09-14 =
4
  * Add - Ensure the `via WooCommerce` text can be translated and introduce a new filter to update that text while paying with Apple Pay.
5
  * Add - Missing square_customers table.
1
  *** WooCommerce Square Changelog ***
2
 
3
+ = 3.3.0 - 2022-11-07 =
4
+ * Add - Adds digital wallet buttons in the Pay for Order page.
5
+ * Add - Declare support for High-performance Order Systems ("HPOS").
6
+ * Add - Digital Wallet support for Australia.
7
+ * Add - Filter 'wc_square_update_product_set_description' to override product description during update from Square.
8
+ * Add - Filter 'wc_square_update_product_set_name' to override product name during update from Square.
9
+ * Add - Filter 'wc_square_update_product_set_variation_name' to override variation name during update from Square.
10
+ * Add - Support to store transaction ID while using High-performance Order Storage ("HPOS") (formerly known as Custom Order Tables, "COT").
11
+ * Dev - Plugin version constant added to the main file.
12
+ * Fix - Broken detailed decline messages after migration to Payments API.
13
+ * Fix - Checkout without required state field being empty.
14
+ * Fix - Digital wallet errors on Checkout page.
15
+ * Fix - Error caused while fetching variation SKU.
16
+ * Fix - Failed payment due to 3D secure errors.
17
+ * Fix - Fixes variations shown for WooCommerce simple products in Square dashboard.
18
+ * Fix - Inability to sync products created in both Square and WooCommerce.
19
+ * Fix - Incorrectly set quantity during Product Import.
20
+ * Fix - Issue with checkout using digital wallet when company name is required.
21
+ * Fix - Issue with stock status during product import when the inventory count is 0.
22
+ * Fix - Manage stock value of variation products when the product is not synced with Square.
23
+ * Fix - Stock status visibility under inventory for variable products.
24
+ * Update - Replaces dynamic strings with string literals.
25
+ * Update - WC tested up to 7.1
26
+
27
  = 3.2.0 - 2022-09-14 =
28
  * Add - Ensure the `via WooCommerce` text can be translated and introduce a new filter to update that text while paying with Apple Pay.
29
  * Add - Missing square_customers table.
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 3.2.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-square\n"
8
- "POT-Creation-Date: 2022-09-15 01:18:46+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -473,19 +473,19 @@ msgid ""
473
  msgstr ""
474
 
475
  #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:147
476
- #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:265
477
  msgid "Capture Charge"
478
  msgstr ""
479
 
480
- #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:255
481
  msgid "This charge has been fully captured."
482
  msgstr ""
483
 
484
- #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:257
485
  msgid "This charge can no longer be captured."
486
  msgstr ""
487
 
488
- #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:259
489
  msgid "This charge cannot be captured."
490
  msgstr ""
491
 
@@ -584,7 +584,7 @@ msgstr ""
584
 
585
  #: includes/Framework/PaymentGateway/Admin/views/html-admin-gateway-status.php:50
586
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1125
587
- #: includes/Gateway.php:645
588
  msgid "Debug Mode"
589
  msgstr ""
590
 
@@ -602,13 +602,13 @@ msgstr ""
602
 
603
  #: includes/Framework/PaymentGateway/Admin/views/html-admin-gateway-status.php:58
604
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1133
605
- #: includes/Gateway.php:653
606
  msgid "Save to Log"
607
  msgstr ""
608
 
609
  #: includes/Framework/PaymentGateway/Admin/views/html-admin-gateway-status.php:60
610
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1131
611
- #: includes/Gateway.php:651
612
  msgid "Off"
613
  msgstr ""
614
 
@@ -654,6 +654,7 @@ msgid "An error occurred, please try again or try an alternate form of payment"
654
  msgstr ""
655
 
656
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:34
 
657
  msgid ""
658
  "We cannot process your order with the payment information that you "
659
  "provided. Please use a different payment account or an alternate payment "
@@ -661,6 +662,7 @@ msgid ""
661
  msgstr ""
662
 
663
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:35
 
664
  msgid ""
665
  "This order is being placed on hold for review. Please contact us to "
666
  "complete the transaction."
@@ -673,14 +675,17 @@ msgid ""
673
  msgstr ""
674
 
675
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:41
 
676
  msgid "The card verification number is invalid, please try again."
677
  msgstr ""
678
 
679
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:42
 
680
  msgid "Please enter your card verification number and try again."
681
  msgstr ""
682
 
683
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:45
 
684
  msgid ""
685
  "That card type is not accepted, please use an alternate card or other form "
686
  "of payment."
@@ -694,6 +699,7 @@ msgid ""
694
  msgstr ""
695
 
696
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:47
 
697
  msgid "Please select the card type and try again."
698
  msgstr ""
699
 
@@ -706,6 +712,7 @@ msgid "Please enter your card number and try again."
706
  msgstr ""
707
 
708
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:55
 
709
  msgid "The card expiration date is invalid, please re-enter and try again."
710
  msgstr ""
711
 
@@ -714,18 +721,22 @@ msgid "The card expiration month is invalid, please re-enter and try again."
714
  msgstr ""
715
 
716
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:57
 
717
  msgid "The card expiration year is invalid, please re-enter and try again."
718
  msgstr ""
719
 
720
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:58
 
721
  msgid "Please enter your card expiration date and try again."
722
  msgstr ""
723
 
724
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:61
 
725
  msgid "The bank routing number is invalid, please re-enter and try again."
726
  msgstr ""
727
 
728
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:62
 
729
  msgid "The bank account number is invalid, please re-enter and try again."
730
  msgstr ""
731
 
@@ -736,6 +747,7 @@ msgid ""
736
  msgstr ""
737
 
738
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:66
 
739
  msgid ""
740
  "The provided card was declined, please use an alternate card or other form "
741
  "of payment."
@@ -748,22 +760,26 @@ msgid ""
748
  msgstr ""
749
 
750
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:68
 
751
  msgid ""
752
  "The card is inactivate or not authorized for card-not-present transactions, "
753
  "please use an alternate card or other form of payment."
754
  msgstr ""
755
 
756
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:69
 
757
  msgid ""
758
  "The credit limit for the card has been reached, please use an alternate "
759
  "card or other form of payment."
760
  msgstr ""
761
 
762
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:70
 
763
  msgid "The card verification number does not match. Please re-enter and try again."
764
  msgstr ""
765
 
766
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:71
 
767
  msgid ""
768
  "The provided address does not match the billing address for cardholder. "
769
  "Please verify the address and try again."
@@ -833,17 +849,17 @@ msgstr ""
833
 
834
  #: includes/Framework/PaymentGateway/ApplePay/Payment_Gateway_Apple_Pay.php:541
835
  #: includes/Gateway/API/Requests/Orders.php:77
836
- #: includes/Gateway/Digital_Wallet.php:444
837
  msgid "Discount"
838
  msgstr ""
839
 
840
  #: includes/Framework/PaymentGateway/ApplePay/Payment_Gateway_Apple_Pay.php:551
841
- #: includes/Gateway/Digital_Wallet.php:428
842
  msgid "Shipping"
843
  msgstr ""
844
 
845
  #: includes/Framework/PaymentGateway/ApplePay/Payment_Gateway_Apple_Pay.php:561
846
- #: includes/Gateway/Digital_Wallet.php:452
847
  msgid "Fees"
848
  msgstr ""
849
 
@@ -858,7 +874,7 @@ msgstr ""
858
 
859
  #: includes/Framework/PaymentGateway/ApplePay/Payment_Gateway_Apple_Pay_Admin.php:95
860
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1071
861
- #: includes/Gateway.php:586 includes/Gateway.php:756
862
  msgid "Enable / Disable"
863
  msgstr ""
864
 
@@ -1025,7 +1041,7 @@ msgstr ""
1025
  #: includes/Framework/PaymentGateway/Integrations/Payment_Gateway_Integration_Pre_Orders.php:311
1026
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1873
1027
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:2087
1028
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2387
1029
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:584
1030
  #. translators: Placeholders: %s - transaction ID
1031
  msgid "(Transaction ID %s)"
@@ -1081,10 +1097,15 @@ msgid "%1$s Payment Change Failed (%2$s)"
1081
  msgstr ""
1082
 
1083
  #: includes/Framework/PaymentGateway/Integrations/Payment_Gateway_Integration_Subscriptions.php:353
1084
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2523
1085
- #: includes/Gateway/Blocks_Handler.php:137
1086
- #: includes/Gateway/Digital_Wallet.php:226
1087
- #: includes/Gateway/Payment_Form.php:238 includes/Gateway.php:251
 
 
 
 
 
1088
  msgid "An error occurred, please try again or try an alternate form of payment."
1089
  msgstr ""
1090
 
@@ -1257,7 +1278,7 @@ msgid "Thank you for your order."
1257
  msgstr ""
1258
 
1259
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1034
1260
- #: includes/Gateway/Blocks_Handler.php:152
1261
  msgid "Credit Card"
1262
  msgstr ""
1263
 
@@ -1266,44 +1287,44 @@ msgid "Pay securely using your credit card."
1266
  msgstr ""
1267
 
1268
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1072
1269
- #: includes/Gateway.php:587
1270
  msgid "Enable this gateway"
1271
  msgstr ""
1272
 
1273
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1078
1274
- #: includes/Gateway.php:593
1275
  msgid "Title"
1276
  msgstr ""
1277
 
1278
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1080
1279
- #: includes/Gateway.php:595
1280
  msgid "Payment method title that the customer will see during checkout."
1281
  msgstr ""
1282
 
1283
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1085
1284
- #: includes/Gateway.php:600
1285
  msgid "Description"
1286
  msgstr ""
1287
 
1288
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1087
1289
- #: includes/Gateway.php:602
1290
  msgid "Payment method description that the customer will see during checkout."
1291
  msgstr ""
1292
 
1293
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1116
1294
- #: includes/Gateway.php:636
1295
  msgid "Detailed Decline Messages"
1296
  msgstr ""
1297
 
1298
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1118
1299
- #: includes/Gateway.php:638
1300
  msgid ""
1301
  "Check to enable detailed decline messages to the customer during checkout "
1302
  "when possible, rather than a generic decline message."
1303
  msgstr ""
1304
 
1305
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1128
1306
- #: includes/Gateway.php:648
1307
  #. translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag
1308
  msgid ""
1309
  "Show Detailed Error Messages and API requests/responses on the checkout "
@@ -1311,12 +1332,12 @@ msgid ""
1311
  msgstr ""
1312
 
1313
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1132
1314
- #: includes/Gateway.php:652
1315
  msgid "Show on Checkout Page"
1316
  msgstr ""
1317
 
1318
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1135
1319
- #: includes/Gateway.php:655
1320
  #. translators: show debugging information on both checkout page and in the log
1321
  msgid "Both"
1322
  msgstr ""
@@ -1388,7 +1409,7 @@ msgid "%1$s Refund Failed: %2$s"
1388
  msgstr ""
1389
 
1390
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1923
1391
- #: includes/Gateway.php:1160
1392
  #. translators: Placeholders: %s - payment gateway title (such as
1393
  #. Authorize.net, Braintree, etc)
1394
  msgid "%s Order completely refunded."
@@ -1418,109 +1439,109 @@ msgstr ""
1418
  msgid "%1$s Void in the amount of %2$s approved."
1419
  msgstr ""
1420
 
1421
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2358
1422
  #. translators: Placeholders: %1$s - payment method title, %2$s - environment
1423
  #. ("Test"), %3$s - transaction type (authorization/charge)
1424
  msgid "%1$s %2$s %3$s Approved"
1425
  msgstr ""
1426
 
1427
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2368
1428
  #. translators: Placeholders: %1$s - credit card type (MasterCard, Visa,
1429
  #. etc...), %2$s - last four digits of the card
1430
  msgid "%1$s ending in %2$s"
1431
  msgstr ""
1432
 
1433
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2379
1434
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:576
1435
  #: includes/Framework/PaymentGateway/Payment_Gateway_Payment_Form.php:528
1436
  #. translators: Placeholders: %s - expiry date
1437
  msgid "(expires %s)"
1438
  msgstr ""
1439
 
1440
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2418
1441
  #. translators: Placeholders: %1$s - payment gateway title, %2$s - message
1442
  #. (probably reason for the transaction being held for review)
1443
  msgid "%1$s Transaction Held for Review (%2$s)"
1444
  msgstr ""
1445
 
1446
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2459
1447
  msgid ""
1448
  "Your order has been received and is being reviewed. Thank you for your "
1449
  "business."
1450
  msgstr ""
1451
 
1452
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2506
1453
  #. translators: Placeholders: %1$s - payment gateway title, %2$s - error
1454
  #. message; e.g. Order Note: [Payment method] Payment failed [error]
1455
  msgid "%1$s Payment Failed (%2$s)"
1456
  msgstr ""
1457
 
1458
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2755
1459
  msgid "Transaction Type"
1460
  msgstr ""
1461
 
1462
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2757
1463
  msgid ""
1464
  "Select how transactions should be processed. Charge submits all "
1465
  "transactions for settlement, Authorization simply authorizes the order "
1466
  "total for capture later."
1467
  msgstr ""
1468
 
1469
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2768
1470
  msgid "Charge Virtual-Only Orders"
1471
  msgstr ""
1472
 
1473
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2770
1474
  msgid ""
1475
  "If the order contains exclusively virtual items, enable this to immediately "
1476
  "charge, rather than authorize, the transaction."
1477
  msgstr ""
1478
 
1479
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2778
1480
  msgid "Enable Partial Capture"
1481
  msgstr ""
1482
 
1483
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2780
1484
  msgid "Allow orders to be partially captured multiple times."
1485
  msgstr ""
1486
 
1487
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2792
1488
  msgid "Capture Paid Orders"
1489
  msgstr ""
1490
 
1491
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2795
1492
  msgid "Automatically capture orders when they are changed to %s."
1493
  msgstr ""
1494
 
1495
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2796
1496
  msgid "a paid status"
1497
  msgstr ""
1498
 
1499
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2986
1500
  msgid "Accepted Card Logos"
1501
  msgstr ""
1502
 
1503
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2988
1504
  msgid ""
1505
  "These are the card logos that are displayed to customers as accepted during "
1506
  "checkout."
1507
  msgstr ""
1508
 
1509
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2991
1510
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag
1511
  msgid ""
1512
  "This setting %1$sdoes not%2$s change which card types the gateway will "
1513
  "accept. Accepted cards are configured from your payment processor account."
1514
  msgstr ""
1515
 
1516
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3082
1517
  #. translators:
1518
  #. http:www.cybersource.com/products/payment_security/payment_tokenization/ and
1519
  #. https:en.wikipedia.org/wiki/Tokenization_(data_security)
1520
  msgid "Tokenization"
1521
  msgstr ""
1522
 
1523
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3083
1524
  msgid "Allow customers to securely save their payment details for future checkout."
1525
  msgstr ""
1526
 
@@ -1911,7 +1932,81 @@ msgstr ""
1911
  msgid "Adjustment"
1912
  msgstr ""
1913
 
1914
- #: includes/Gateway/Blocks_Handler.php:298
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1915
  #. translators: %1$s - opening bold HTML tag, %2$s - closing bold HTML tag,
1916
  #. %3$s - version number
1917
  msgid ""
@@ -1920,11 +2015,11 @@ msgid ""
1920
  "version of WooCommerce Blocks or WooCommerce to fix these issues."
1921
  msgstr ""
1922
 
1923
- #: includes/Gateway/Digital_Wallet.php:91
1924
  msgid "via WooCommerce"
1925
  msgstr ""
1926
 
1927
- #: includes/Gateway/Digital_Wallet.php:132
1928
  #. Translators: %1$s: expected location of apple pay verification file, %2$s:
1929
  #. opening href tag with link to Square documentation, %3$s: closing href tag
1930
  msgid ""
@@ -1933,7 +2028,7 @@ msgid ""
1933
  "information, please read our documentation on %2$sSetting up Apple Pay%3$s."
1934
  msgstr ""
1935
 
1936
- #: includes/Gateway/Digital_Wallet.php:148
1937
  #. Translators: %1$s: opening bold tags, %2$s: closing strong/bold tags, %3$s:
1938
  #. expected location of apple pay verification file, %4$s: opening href tag
1939
  #. with link to Square documentation, %5$s: closing href tag
@@ -1943,55 +2038,55 @@ msgid ""
1943
  "logs%2$s to find out what caused the registration to fail."
1944
  msgstr ""
1945
 
1946
- #: includes/Gateway/Digital_Wallet.php:195
1947
  msgid "OR"
1948
  msgstr ""
1949
 
1950
- #: includes/Gateway/Digital_Wallet.php:297
1951
  #. translators: product ID
1952
  msgid "Product with the ID (%d) cannot be found."
1953
  msgstr ""
1954
 
1955
- #: includes/Gateway/Digital_Wallet.php:313
1956
  #. translators: 1: product name 2: quantity in stock
1957
  msgid ""
1958
  "You cannot add that amount of \"%1$s\"; to the cart because there is not "
1959
  "enough stock (%2$s remaining)."
1960
  msgstr ""
1961
 
1962
- #: includes/Gateway/Digital_Wallet.php:318
1963
  #. translators: 1: product name
1964
  msgid "You cannot purchase \"%1$s\" because it is currently not available."
1965
  msgstr ""
1966
 
1967
- #: includes/Gateway/Digital_Wallet.php:340
1968
- #: includes/Gateway/Digital_Wallet.php:436
1969
  msgid "Tax"
1970
  msgstr ""
1971
 
1972
- #: includes/Gateway/Digital_Wallet.php:375
1973
  msgid "This payment method cannot be used for multiple shipments."
1974
  msgstr ""
1975
 
1976
- #: includes/Gateway/Digital_Wallet.php:386
1977
  #: vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler_Store.php:378
1978
  msgid "Pending"
1979
  msgstr ""
1980
 
1981
- #: includes/Gateway/Digital_Wallet.php:487
1982
  #. translators: Context (product, cart, checkout or page)
1983
  msgid "Empty payment request data for %s."
1984
  msgstr ""
1985
 
1986
- #: includes/Gateway/Digital_Wallet.php:751
1987
  msgid "Empty cart"
1988
  msgstr ""
1989
 
1990
- #: includes/Gateway/Digital_Wallet.php:885
1991
  msgid "Unable to verify domain with Apple Pay - missing access token."
1992
  msgstr ""
1993
 
1994
- #: includes/Gateway/Payment_Form.php:180
1995
  msgid "Postal code"
1996
  msgstr ""
1997
 
@@ -1999,39 +2094,39 @@ msgstr ""
1999
  msgid "Allow customers to use Square to securely pay with their credit cards"
2000
  msgstr ""
2001
 
2002
- #: includes/Gateway.php:449
2003
  msgid "Refunds must be made within %s of the original payment date."
2004
  msgstr ""
2005
 
2006
- #: includes/Gateway.php:473
2007
  msgid ""
2008
  "Could not find original transaction tender. Please refund this transaction "
2009
  "from your Square dashboard."
2010
  msgstr ""
2011
 
2012
- #: includes/Gateway.php:629
2013
  msgid "Advanced Settings"
2014
  msgstr ""
2015
 
2016
- #: includes/Gateway.php:691
2017
  msgid "Customer Profiles"
2018
  msgstr ""
2019
 
2020
- #: includes/Gateway.php:692
2021
  msgid ""
2022
  "Check to enable tokenization and allow customers to securely save their "
2023
  "payment details for future checkout."
2024
  msgstr ""
2025
 
2026
- #: includes/Gateway.php:750
2027
  msgid "Digital Wallet Settings"
2028
  msgstr ""
2029
 
2030
- #: includes/Gateway.php:751
2031
  msgid "Take payments on your store with Apple Pay and Google Pay."
2032
  msgstr ""
2033
 
2034
- #: includes/Gateway.php:758
2035
  #. translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag
2036
  msgid ""
2037
  "Allow customers to pay with Apple Pay or Google Pay from your Product, Cart "
@@ -2039,52 +2134,52 @@ msgid ""
2039
  "our %1$sdocumentation%2$s."
2040
  msgstr ""
2041
 
2042
- #: includes/Gateway.php:761
2043
  msgid "Enable digital wallets"
2044
  msgstr ""
2045
 
2046
- #: includes/Gateway.php:765
2047
  msgid "Button Type"
2048
  msgstr ""
2049
 
2050
- #: includes/Gateway.php:766
2051
  msgid ""
2052
  "This setting only applies to the Apple Pay button. When Google Pay is "
2053
  "available, the Google Pay button will always have the \"Buy with\" button "
2054
  "text."
2055
  msgstr ""
2056
 
2057
- #: includes/Gateway.php:767
2058
  msgid "Select which text is displayed on the digital wallet buttons."
2059
  msgstr ""
2060
 
2061
- #: includes/Gateway.php:779
2062
  msgid "Apple Pay Button Color"
2063
  msgstr ""
2064
 
2065
- #: includes/Gateway.php:780
2066
  msgid "Select the color of the Apple Pay button."
2067
  msgstr ""
2068
 
2069
- #: includes/Gateway.php:792
2070
  msgid "Google Pay Button Color"
2071
  msgstr ""
2072
 
2073
- #: includes/Gateway.php:793
2074
  msgid "Select the color of the Google Pay button."
2075
  msgstr ""
2076
 
2077
- #: includes/Gateway.php:804
2078
  msgid "Hide Digital Wallet Buttons"
2079
  msgstr ""
2080
 
2081
- #: includes/Gateway.php:805
2082
  msgid ""
2083
  "Select any digital wallet buttons you don't want to be displayed on your "
2084
  "store."
2085
  msgstr ""
2086
 
2087
- #: includes/Gateway.php:1089
2088
  msgid " An error occurred, please try again or try an alternate form of payment."
2089
  msgstr ""
2090
 
@@ -2124,14 +2219,14 @@ msgstr ""
2124
  msgid "Disconnect from Square"
2125
  msgstr ""
2126
 
2127
- #: includes/Handlers/Product.php:175
2128
  #. translators: Placeholder: %s category ID
2129
  msgid ""
2130
  "Square category with id (%s) was not imported to your Store. Please run "
2131
  "Import Products from Square settings."
2132
  msgstr ""
2133
 
2134
- #: includes/Handlers/Product.php:309
2135
  msgid "Product not synced with Square"
2136
  msgstr ""
2137
 
@@ -2472,50 +2567,50 @@ msgstr ""
2472
  msgid "Product %s could not be updated in Square."
2473
  msgstr ""
2474
 
2475
- #: includes/Sync/Product_Import.php:546
2476
  #. translators: Placeholders: %1$s - Square item name, %2$s - Square item
2477
  #. variation name, %3$s - failure reason
2478
  msgid "Could not import \"%1$s - %2$s\" from Square. %3$s"
2479
  msgstr ""
2480
 
2481
- #: includes/Sync/Product_Import.php:591
2482
  #. translators: Placeholders: %1$s - Square item name, %2$s - failure reason
2483
  msgid "Could not import \"%1$s\" from Square. %2$s"
2484
  msgstr ""
2485
 
2486
- #: includes/Sync/Product_Import.php:620
2487
  msgid "Items with variable pricing cannot be imported."
2488
  msgstr ""
2489
 
2490
- #: includes/Sync/Product_Import.php:624
2491
  msgid "Variations with missing SKUs cannot be imported."
2492
  msgstr ""
2493
 
2494
- #: includes/Sync/Product_Import.php:717 includes/Sync/Product_Import.php:994
2495
  msgid "The SKU already exists on another product"
2496
  msgstr ""
2497
 
2498
- #: includes/Sync/Product_Import.php:909
2499
  #. translators: Placeholders: %1$s - variation ID, %2$s - product name
2500
  msgid "Variation #%1$s of %2$s"
2501
  msgstr ""
2502
 
2503
- #: includes/Sync/Product_Import.php:1288
2504
  #. translators: Placeholders: %s - missing parameter name
2505
  msgid "Missing parameter %s"
2506
  msgstr ""
2507
 
2508
- #: includes/Sync/Product_Import.php:1294
2509
  #. translators: Placeholders: %s - comma separated list of valid product types
2510
  msgid "Invalid product type - the product type must be any of these: %s"
2511
  msgstr ""
2512
 
2513
- #: includes/Sync/Product_Import.php:1345
2514
  #. translators: Placeholders: %1$s - Square item name, %2$s - Failure reason
2515
  msgid "Could not update %1$s from Square. %2$s"
2516
  msgstr ""
2517
 
2518
- #: includes/Sync/Product_Import.php:1348
2519
  #. translators: Placeholders: %1$s - Square item name, %2$s - Failure reason
2520
  msgid "Could not import %1$s from Square. %2$s"
2521
  msgstr ""
@@ -3246,21 +3341,21 @@ msgstr[1] ""
3246
  msgid "Migrated action with ID %1$d in %2$s to ID %3$d in %4$s"
3247
  msgstr ""
3248
 
3249
- #: woocommerce-square.php:349
3250
  #. translators: plugin name
3251
  msgid ""
3252
  "<strong>All features in %1$s have been disabled</strong> due to unsupported "
3253
  "settings:<br>"
3254
  msgstr ""
3255
 
3256
- #: woocommerce-square.php:357
3257
  #. translators: minimum PHP version, current PHP version
3258
  msgid ""
3259
  "&bull;&nbsp;<strong>Invalid PHP version: </strong>The minimum PHP version "
3260
  "required is %1$s. You are running %2$s.<br>"
3261
  msgstr ""
3262
 
3263
- #: woocommerce-square.php:366
3264
  #. translators: link to documentation
3265
  msgid ""
3266
  "&bull;&nbsp;<strong>Invalid OPcache config: </strong><a href=\"%s\" "
@@ -3335,63 +3430,63 @@ msgctxt "hash before order number"
3335
  msgid "#"
3336
  msgstr ""
3337
 
3338
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2360
3339
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:565
3340
  msgctxt "noun, software environment"
3341
  msgid "Test"
3342
  msgstr ""
3343
 
3344
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2361
3345
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2761
3346
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:566
3347
  msgctxt "credit card transaction type"
3348
  msgid "Authorization"
3349
  msgstr ""
3350
 
3351
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2361
3352
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2760
3353
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:566
3354
  msgctxt "noun, credit card transaction type"
3355
  msgid "Charge"
3356
  msgstr ""
3357
 
3358
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:2789
3359
  msgctxt ""
3360
  "coordinating conjunction for a list of order statuses: on-hold, processing, "
3361
  "or completed"
3362
  msgid "or"
3363
  msgstr ""
3364
 
3365
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3019
3366
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:201
3367
  msgctxt "credit card type"
3368
  msgid "Visa"
3369
  msgstr ""
3370
 
3371
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3020
3372
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:205
3373
  msgctxt "credit card type"
3374
  msgid "MasterCard"
3375
  msgstr ""
3376
 
3377
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3021
3378
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:209
3379
  msgctxt "credit card type"
3380
  msgid "American Express"
3381
  msgstr ""
3382
 
3383
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3022
3384
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:217
3385
  msgctxt "credit card type"
3386
  msgid "Discover"
3387
  msgstr ""
3388
 
3389
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3023
3390
  msgctxt "credit card type"
3391
  msgid "Diners"
3392
  msgstr ""
3393
 
3394
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3024
3395
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:221
3396
  msgctxt "credit card type"
3397
  msgid "JCB"
@@ -3417,7 +3512,7 @@ msgctxt "credit card type"
3417
  msgid "Laser"
3418
  msgstr ""
3419
 
3420
- #: includes/Framework/PaymentGateway/Payment_Gateway.php:3509
3421
  msgctxt "software environment"
3422
  msgid "Production"
3423
  msgstr ""
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Square 3.3.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-square\n"
8
+ "POT-Creation-Date: 2022-11-07 04:24:20+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
473
  msgstr ""
474
 
475
  #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:147
476
+ #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:271
477
  msgid "Capture Charge"
478
  msgstr ""
479
 
480
+ #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:261
481
  msgid "This charge has been fully captured."
482
  msgstr ""
483
 
484
+ #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:263
485
  msgid "This charge can no longer be captured."
486
  msgstr ""
487
 
488
+ #: includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php:265
489
  msgid "This charge cannot be captured."
490
  msgstr ""
491
 
584
 
585
  #: includes/Framework/PaymentGateway/Admin/views/html-admin-gateway-status.php:50
586
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1125
587
+ #: includes/Gateway.php:643
588
  msgid "Debug Mode"
589
  msgstr ""
590
 
602
 
603
  #: includes/Framework/PaymentGateway/Admin/views/html-admin-gateway-status.php:58
604
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1133
605
+ #: includes/Gateway.php:651
606
  msgid "Save to Log"
607
  msgstr ""
608
 
609
  #: includes/Framework/PaymentGateway/Admin/views/html-admin-gateway-status.php:60
610
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1131
611
+ #: includes/Gateway.php:649
612
  msgid "Off"
613
  msgstr ""
614
 
654
  msgstr ""
655
 
656
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:34
657
+ #: includes/Gateway/API/Response_Message_Helper.php:115
658
  msgid ""
659
  "We cannot process your order with the payment information that you "
660
  "provided. Please use a different payment account or an alternate payment "
662
  msgstr ""
663
 
664
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:35
665
+ #: includes/Gateway/API/Response_Message_Helper.php:116
666
  msgid ""
667
  "This order is being placed on hold for review. Please contact us to "
668
  "complete the transaction."
675
  msgstr ""
676
 
677
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:41
678
+ #: includes/Gateway/API/Response_Message_Helper.php:118
679
  msgid "The card verification number is invalid, please try again."
680
  msgstr ""
681
 
682
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:42
683
+ #: includes/Gateway/API/Response_Message_Helper.php:119
684
  msgid "Please enter your card verification number and try again."
685
  msgstr ""
686
 
687
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:45
688
+ #: includes/Gateway/API/Response_Message_Helper.php:120
689
  msgid ""
690
  "That card type is not accepted, please use an alternate card or other form "
691
  "of payment."
699
  msgstr ""
700
 
701
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:47
702
+ #: includes/Gateway/API/Response_Message_Helper.php:122
703
  msgid "Please select the card type and try again."
704
  msgstr ""
705
 
712
  msgstr ""
713
 
714
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:55
715
+ #: includes/Gateway/API/Response_Message_Helper.php:124
716
  msgid "The card expiration date is invalid, please re-enter and try again."
717
  msgstr ""
718
 
721
  msgstr ""
722
 
723
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:57
724
+ #: includes/Gateway/API/Response_Message_Helper.php:125
725
  msgid "The card expiration year is invalid, please re-enter and try again."
726
  msgstr ""
727
 
728
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:58
729
+ #: includes/Gateway/API/Response_Message_Helper.php:126
730
  msgid "Please enter your card expiration date and try again."
731
  msgstr ""
732
 
733
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:61
734
+ #: includes/Gateway/API/Response_Message_Helper.php:127
735
  msgid "The bank routing number is invalid, please re-enter and try again."
736
  msgstr ""
737
 
738
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:62
739
+ #: includes/Gateway/API/Response_Message_Helper.php:128
740
  msgid "The bank account number is invalid, please re-enter and try again."
741
  msgstr ""
742
 
747
  msgstr ""
748
 
749
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:66
750
+ #: includes/Gateway/API/Response_Message_Helper.php:129
751
  msgid ""
752
  "The provided card was declined, please use an alternate card or other form "
753
  "of payment."
760
  msgstr ""
761
 
762
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:68
763
+ #: includes/Gateway/API/Response_Message_Helper.php:130
764
  msgid ""
765
  "The card is inactivate or not authorized for card-not-present transactions, "
766
  "please use an alternate card or other form of payment."
767
  msgstr ""
768
 
769
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:69
770
+ #: includes/Gateway/API/Response_Message_Helper.php:131
771
  msgid ""
772
  "The credit limit for the card has been reached, please use an alternate "
773
  "card or other form of payment."
774
  msgstr ""
775
 
776
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:70
777
+ #: includes/Gateway/API/Response_Message_Helper.php:132
778
  msgid "The card verification number does not match. Please re-enter and try again."
779
  msgstr ""
780
 
781
  #: includes/Framework/PaymentGateway/Api/Payment_Gateway_Api_Response_Message_Helper.php:71
782
+ #: includes/Gateway/API/Response_Message_Helper.php:133
783
  msgid ""
784
  "The provided address does not match the billing address for cardholder. "
785
  "Please verify the address and try again."
849
 
850
  #: includes/Framework/PaymentGateway/ApplePay/Payment_Gateway_Apple_Pay.php:541
851
  #: includes/Gateway/API/Requests/Orders.php:77
852
+ #: includes/Gateway/Digital_Wallet.php:501
853
  msgid "Discount"
854
  msgstr ""
855
 
856
  #: includes/Framework/PaymentGateway/ApplePay/Payment_Gateway_Apple_Pay.php:551
857
+ #: includes/Gateway/Digital_Wallet.php:485
858
  msgid "Shipping"
859
  msgstr ""
860
 
861
  #: includes/Framework/PaymentGateway/ApplePay/Payment_Gateway_Apple_Pay.php:561
862
+ #: includes/Gateway/Digital_Wallet.php:509
863
  msgid "Fees"
864
  msgstr ""
865
 
874
 
875
  #: includes/Framework/PaymentGateway/ApplePay/Payment_Gateway_Apple_Pay_Admin.php:95
876
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1071
877
+ #: includes/Gateway.php:584 includes/Gateway.php:754
878
  msgid "Enable / Disable"
879
  msgstr ""
880
 
1041
  #: includes/Framework/PaymentGateway/Integrations/Payment_Gateway_Integration_Pre_Orders.php:311
1042
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1873
1043
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:2087
1044
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2392
1045
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:584
1046
  #. translators: Placeholders: %s - transaction ID
1047
  msgid "(Transaction ID %s)"
1097
  msgstr ""
1098
 
1099
  #: includes/Framework/PaymentGateway/Integrations/Payment_Gateway_Integration_Subscriptions.php:353
1100
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2528
1101
+ #: includes/Gateway/API/Response_Message_Helper.php:92
1102
+ #: includes/Gateway/API/Response_Message_Helper.php:94
1103
+ #: includes/Gateway/API/Response_Message_Helper.php:96
1104
+ #: includes/Gateway/API/Response_Message_Helper.php:108
1105
+ #: includes/Gateway/API/Response_Message_Helper.php:114
1106
+ #: includes/Gateway/Blocks_Handler.php:136
1107
+ #: includes/Gateway/Digital_Wallet.php:238
1108
+ #: includes/Gateway/Payment_Form.php:233 includes/Gateway.php:251
1109
  msgid "An error occurred, please try again or try an alternate form of payment."
1110
  msgstr ""
1111
 
1278
  msgstr ""
1279
 
1280
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1034
1281
+ #: includes/Gateway/Blocks_Handler.php:151
1282
  msgid "Credit Card"
1283
  msgstr ""
1284
 
1287
  msgstr ""
1288
 
1289
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1072
1290
+ #: includes/Gateway.php:585
1291
  msgid "Enable this gateway"
1292
  msgstr ""
1293
 
1294
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1078
1295
+ #: includes/Gateway.php:591
1296
  msgid "Title"
1297
  msgstr ""
1298
 
1299
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1080
1300
+ #: includes/Gateway.php:593
1301
  msgid "Payment method title that the customer will see during checkout."
1302
  msgstr ""
1303
 
1304
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1085
1305
+ #: includes/Gateway.php:598
1306
  msgid "Description"
1307
  msgstr ""
1308
 
1309
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1087
1310
+ #: includes/Gateway.php:600
1311
  msgid "Payment method description that the customer will see during checkout."
1312
  msgstr ""
1313
 
1314
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1116
1315
+ #: includes/Gateway.php:634
1316
  msgid "Detailed Decline Messages"
1317
  msgstr ""
1318
 
1319
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1118
1320
+ #: includes/Gateway.php:636
1321
  msgid ""
1322
  "Check to enable detailed decline messages to the customer during checkout "
1323
  "when possible, rather than a generic decline message."
1324
  msgstr ""
1325
 
1326
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1128
1327
+ #: includes/Gateway.php:646
1328
  #. translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag
1329
  msgid ""
1330
  "Show Detailed Error Messages and API requests/responses on the checkout "
1332
  msgstr ""
1333
 
1334
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1132
1335
+ #: includes/Gateway.php:650
1336
  msgid "Show on Checkout Page"
1337
  msgstr ""
1338
 
1339
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1135
1340
+ #: includes/Gateway.php:653
1341
  #. translators: show debugging information on both checkout page and in the log
1342
  msgid "Both"
1343
  msgstr ""
1409
  msgstr ""
1410
 
1411
  #: includes/Framework/PaymentGateway/Payment_Gateway.php:1923
1412
+ #: includes/Gateway.php:1163
1413
  #. translators: Placeholders: %s - payment gateway title (such as
1414
  #. Authorize.net, Braintree, etc)
1415
  msgid "%s Order completely refunded."
1439
  msgid "%1$s Void in the amount of %2$s approved."
1440
  msgstr ""
1441
 
1442
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2363
1443
  #. translators: Placeholders: %1$s - payment method title, %2$s - environment
1444
  #. ("Test"), %3$s - transaction type (authorization/charge)
1445
  msgid "%1$s %2$s %3$s Approved"
1446
  msgstr ""
1447
 
1448
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2373
1449
  #. translators: Placeholders: %1$s - credit card type (MasterCard, Visa,
1450
  #. etc...), %2$s - last four digits of the card
1451
  msgid "%1$s ending in %2$s"
1452
  msgstr ""
1453
 
1454
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2384
1455
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:576
1456
  #: includes/Framework/PaymentGateway/Payment_Gateway_Payment_Form.php:528
1457
  #. translators: Placeholders: %s - expiry date
1458
  msgid "(expires %s)"
1459
  msgstr ""
1460
 
1461
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2423
1462
  #. translators: Placeholders: %1$s - payment gateway title, %2$s - message
1463
  #. (probably reason for the transaction being held for review)
1464
  msgid "%1$s Transaction Held for Review (%2$s)"
1465
  msgstr ""
1466
 
1467
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2464
1468
  msgid ""
1469
  "Your order has been received and is being reviewed. Thank you for your "
1470
  "business."
1471
  msgstr ""
1472
 
1473
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2511
1474
  #. translators: Placeholders: %1$s - payment gateway title, %2$s - error
1475
  #. message; e.g. Order Note: [Payment method] Payment failed [error]
1476
  msgid "%1$s Payment Failed (%2$s)"
1477
  msgstr ""
1478
 
1479
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2760
1480
  msgid "Transaction Type"
1481
  msgstr ""
1482
 
1483
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2762
1484
  msgid ""
1485
  "Select how transactions should be processed. Charge submits all "
1486
  "transactions for settlement, Authorization simply authorizes the order "
1487
  "total for capture later."
1488
  msgstr ""
1489
 
1490
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2773
1491
  msgid "Charge Virtual-Only Orders"
1492
  msgstr ""
1493
 
1494
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2775
1495
  msgid ""
1496
  "If the order contains exclusively virtual items, enable this to immediately "
1497
  "charge, rather than authorize, the transaction."
1498
  msgstr ""
1499
 
1500
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2783
1501
  msgid "Enable Partial Capture"
1502
  msgstr ""
1503
 
1504
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2785
1505
  msgid "Allow orders to be partially captured multiple times."
1506
  msgstr ""
1507
 
1508
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2797
1509
  msgid "Capture Paid Orders"
1510
  msgstr ""
1511
 
1512
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2800
1513
  msgid "Automatically capture orders when they are changed to %s."
1514
  msgstr ""
1515
 
1516
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2801
1517
  msgid "a paid status"
1518
  msgstr ""
1519
 
1520
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2991
1521
  msgid "Accepted Card Logos"
1522
  msgstr ""
1523
 
1524
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2993
1525
  msgid ""
1526
  "These are the card logos that are displayed to customers as accepted during "
1527
  "checkout."
1528
  msgstr ""
1529
 
1530
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2996
1531
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag
1532
  msgid ""
1533
  "This setting %1$sdoes not%2$s change which card types the gateway will "
1534
  "accept. Accepted cards are configured from your payment processor account."
1535
  msgstr ""
1536
 
1537
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3087
1538
  #. translators:
1539
  #. http:www.cybersource.com/products/payment_security/payment_tokenization/ and
1540
  #. https:en.wikipedia.org/wiki/Tokenization_(data_security)
1541
  msgid "Tokenization"
1542
  msgstr ""
1543
 
1544
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3088
1545
  msgid "Allow customers to securely save their payment details for future checkout."
1546
  msgstr ""
1547
 
1932
  msgid "Adjustment"
1933
  msgstr ""
1934
 
1935
+ #: includes/Gateway/API/Response_Message_Helper.php:91
1936
+ msgid "The card expiration date is missing or incorrectly formatted."
1937
+ msgstr ""
1938
+
1939
+ #: includes/Gateway/API/Response_Message_Helper.php:93
1940
+ msgid ""
1941
+ "The card issuer has declined the transaction due to restrictions on where "
1942
+ "the card can be used."
1943
+ msgstr ""
1944
+
1945
+ #: includes/Gateway/API/Response_Message_Helper.php:95
1946
+ msgid "The payment source has insufficient funds to cover the payment."
1947
+ msgstr ""
1948
+
1949
+ #: includes/Gateway/API/Response_Message_Helper.php:97
1950
+ msgid "The card issuer has determined the payment amount is too high or too low."
1951
+ msgstr ""
1952
+
1953
+ #: includes/Gateway/API/Response_Message_Helper.php:98
1954
+ msgid "The card issuer declined the request because the card is expired."
1955
+ msgstr ""
1956
+
1957
+ #: includes/Gateway/API/Response_Message_Helper.php:99
1958
+ msgid "The card issuer declined the request because the CVV value is invalid."
1959
+ msgstr ""
1960
+
1961
+ #: includes/Gateway/API/Response_Message_Helper.php:100
1962
+ msgid "The card issuer declined the request because the postal code is invalid."
1963
+ msgstr ""
1964
+
1965
+ #: includes/Gateway/API/Response_Message_Helper.php:101
1966
+ msgid "A temporary internal error occurred. You can safely retry the payment."
1967
+ msgstr ""
1968
+
1969
+ #: includes/Gateway/API/Response_Message_Helper.php:102
1970
+ msgid "The specified card number is invalid."
1971
+ msgstr ""
1972
+
1973
+ #: includes/Gateway/API/Response_Message_Helper.php:103
1974
+ #: includes/Gateway/API/Response_Message_Helper.php:111
1975
+ msgid "The card expiration date is invalid or indicates that the card is expired."
1976
+ msgstr ""
1977
+
1978
+ #: includes/Gateway/API/Response_Message_Helper.php:104
1979
+ msgid "The card is not supported in the geographic region."
1980
+ msgstr ""
1981
+
1982
+ #: includes/Gateway/API/Response_Message_Helper.php:105
1983
+ msgid "The postal code is incorrectly formatted."
1984
+ msgstr ""
1985
+
1986
+ #: includes/Gateway/API/Response_Message_Helper.php:106
1987
+ msgid ""
1988
+ "Square declined the request because the payment amount exceeded the "
1989
+ "processing limit for this seller."
1990
+ msgstr ""
1991
+
1992
+ #: includes/Gateway/API/Response_Message_Helper.php:107
1993
+ msgid "The card issuer declined the refund."
1994
+ msgstr ""
1995
+
1996
+ #: includes/Gateway/API/Response_Message_Helper.php:117
1997
+ msgid ""
1998
+ "This order is being placed on hold for review due to an incorrect card "
1999
+ "verification number. You may contact the store to complete the transaction."
2000
+ msgstr ""
2001
+
2002
+ #: includes/Gateway/API/Response_Message_Helper.php:121
2003
+ #: includes/Gateway/API/Response_Message_Helper.php:123
2004
+ msgid ""
2005
+ "The card type is invalid or does not correlate with the credit card number. "
2006
+ "Please try again or use an alternate card or other form of payment."
2007
+ msgstr ""
2008
+
2009
+ #: includes/Gateway/Blocks_Handler.php:297
2010
  #. translators: %1$s - opening bold HTML tag, %2$s - closing bold HTML tag,
2011
  #. %3$s - version number
2012
  msgid ""
2015
  "version of WooCommerce Blocks or WooCommerce to fix these issues."
2016
  msgstr ""
2017
 
2018
+ #: includes/Gateway/Digital_Wallet.php:93
2019
  msgid "via WooCommerce"
2020
  msgstr ""
2021
 
2022
+ #: includes/Gateway/Digital_Wallet.php:138
2023
  #. Translators: %1$s: expected location of apple pay verification file, %2$s:
2024
  #. opening href tag with link to Square documentation, %3$s: closing href tag
2025
  msgid ""
2028
  "information, please read our documentation on %2$sSetting up Apple Pay%3$s."
2029
  msgstr ""
2030
 
2031
+ #: includes/Gateway/Digital_Wallet.php:154
2032
  #. Translators: %1$s: opening bold tags, %2$s: closing strong/bold tags, %3$s:
2033
  #. expected location of apple pay verification file, %4$s: opening href tag
2034
  #. with link to Square documentation, %5$s: closing href tag
2038
  "logs%2$s to find out what caused the registration to fail."
2039
  msgstr ""
2040
 
2041
+ #: includes/Gateway/Digital_Wallet.php:201
2042
  msgid "OR"
2043
  msgstr ""
2044
 
2045
+ #: includes/Gateway/Digital_Wallet.php:318
2046
  #. translators: product ID
2047
  msgid "Product with the ID (%d) cannot be found."
2048
  msgstr ""
2049
 
2050
+ #: includes/Gateway/Digital_Wallet.php:334
2051
  #. translators: 1: product name 2: quantity in stock
2052
  msgid ""
2053
  "You cannot add that amount of \"%1$s\"; to the cart because there is not "
2054
  "enough stock (%2$s remaining)."
2055
  msgstr ""
2056
 
2057
+ #: includes/Gateway/Digital_Wallet.php:339
2058
  #. translators: 1: product name
2059
  msgid "You cannot purchase \"%1$s\" because it is currently not available."
2060
  msgstr ""
2061
 
2062
+ #: includes/Gateway/Digital_Wallet.php:361
2063
+ #: includes/Gateway/Digital_Wallet.php:493
2064
  msgid "Tax"
2065
  msgstr ""
2066
 
2067
+ #: includes/Gateway/Digital_Wallet.php:419
2068
  msgid "This payment method cannot be used for multiple shipments."
2069
  msgstr ""
2070
 
2071
+ #: includes/Gateway/Digital_Wallet.php:430
2072
  #: vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler_Store.php:378
2073
  msgid "Pending"
2074
  msgstr ""
2075
 
2076
+ #: includes/Gateway/Digital_Wallet.php:544
2077
  #. translators: Context (product, cart, checkout or page)
2078
  msgid "Empty payment request data for %s."
2079
  msgstr ""
2080
 
2081
+ #: includes/Gateway/Digital_Wallet.php:864
2082
  msgid "Empty cart"
2083
  msgstr ""
2084
 
2085
+ #: includes/Gateway/Digital_Wallet.php:998
2086
  msgid "Unable to verify domain with Apple Pay - missing access token."
2087
  msgstr ""
2088
 
2089
+ #: includes/Gateway/Payment_Form.php:175
2090
  msgid "Postal code"
2091
  msgstr ""
2092
 
2094
  msgid "Allow customers to use Square to securely pay with their credit cards"
2095
  msgstr ""
2096
 
2097
+ #: includes/Gateway.php:447
2098
  msgid "Refunds must be made within %s of the original payment date."
2099
  msgstr ""
2100
 
2101
+ #: includes/Gateway.php:471
2102
  msgid ""
2103
  "Could not find original transaction tender. Please refund this transaction "
2104
  "from your Square dashboard."
2105
  msgstr ""
2106
 
2107
+ #: includes/Gateway.php:627
2108
  msgid "Advanced Settings"
2109
  msgstr ""
2110
 
2111
+ #: includes/Gateway.php:689
2112
  msgid "Customer Profiles"
2113
  msgstr ""
2114
 
2115
+ #: includes/Gateway.php:690
2116
  msgid ""
2117
  "Check to enable tokenization and allow customers to securely save their "
2118
  "payment details for future checkout."
2119
  msgstr ""
2120
 
2121
+ #: includes/Gateway.php:748
2122
  msgid "Digital Wallet Settings"
2123
  msgstr ""
2124
 
2125
+ #: includes/Gateway.php:749
2126
  msgid "Take payments on your store with Apple Pay and Google Pay."
2127
  msgstr ""
2128
 
2129
+ #: includes/Gateway.php:756
2130
  #. translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag
2131
  msgid ""
2132
  "Allow customers to pay with Apple Pay or Google Pay from your Product, Cart "
2134
  "our %1$sdocumentation%2$s."
2135
  msgstr ""
2136
 
2137
+ #: includes/Gateway.php:759
2138
  msgid "Enable digital wallets"
2139
  msgstr ""
2140
 
2141
+ #: includes/Gateway.php:763
2142
  msgid "Button Type"
2143
  msgstr ""
2144
 
2145
+ #: includes/Gateway.php:764
2146
  msgid ""
2147
  "This setting only applies to the Apple Pay button. When Google Pay is "
2148
  "available, the Google Pay button will always have the \"Buy with\" button "
2149
  "text."
2150
  msgstr ""
2151
 
2152
+ #: includes/Gateway.php:765
2153
  msgid "Select which text is displayed on the digital wallet buttons."
2154
  msgstr ""
2155
 
2156
+ #: includes/Gateway.php:777
2157
  msgid "Apple Pay Button Color"
2158
  msgstr ""
2159
 
2160
+ #: includes/Gateway.php:778
2161
  msgid "Select the color of the Apple Pay button."
2162
  msgstr ""
2163
 
2164
+ #: includes/Gateway.php:790
2165
  msgid "Google Pay Button Color"
2166
  msgstr ""
2167
 
2168
+ #: includes/Gateway.php:791
2169
  msgid "Select the color of the Google Pay button."
2170
  msgstr ""
2171
 
2172
+ #: includes/Gateway.php:802
2173
  msgid "Hide Digital Wallet Buttons"
2174
  msgstr ""
2175
 
2176
+ #: includes/Gateway.php:803
2177
  msgid ""
2178
  "Select any digital wallet buttons you don't want to be displayed on your "
2179
  "store."
2180
  msgstr ""
2181
 
2182
+ #: includes/Gateway.php:1092
2183
  msgid " An error occurred, please try again or try an alternate form of payment."
2184
  msgstr ""
2185
 
2219
  msgid "Disconnect from Square"
2220
  msgstr ""
2221
 
2222
+ #: includes/Handlers/Product.php:214
2223
  #. translators: Placeholder: %s category ID
2224
  msgid ""
2225
  "Square category with id (%s) was not imported to your Store. Please run "
2226
  "Import Products from Square settings."
2227
  msgstr ""
2228
 
2229
+ #: includes/Handlers/Product.php:348
2230
  msgid "Product not synced with Square"
2231
  msgstr ""
2232
 
2567
  msgid "Product %s could not be updated in Square."
2568
  msgstr ""
2569
 
2570
+ #: includes/Sync/Product_Import.php:549
2571
  #. translators: Placeholders: %1$s - Square item name, %2$s - Square item
2572
  #. variation name, %3$s - failure reason
2573
  msgid "Could not import \"%1$s - %2$s\" from Square. %3$s"
2574
  msgstr ""
2575
 
2576
+ #: includes/Sync/Product_Import.php:594
2577
  #. translators: Placeholders: %1$s - Square item name, %2$s - failure reason
2578
  msgid "Could not import \"%1$s\" from Square. %2$s"
2579
  msgstr ""
2580
 
2581
+ #: includes/Sync/Product_Import.php:623
2582
  msgid "Items with variable pricing cannot be imported."
2583
  msgstr ""
2584
 
2585
+ #: includes/Sync/Product_Import.php:627
2586
  msgid "Variations with missing SKUs cannot be imported."
2587
  msgstr ""
2588
 
2589
+ #: includes/Sync/Product_Import.php:720 includes/Sync/Product_Import.php:997
2590
  msgid "The SKU already exists on another product"
2591
  msgstr ""
2592
 
2593
+ #: includes/Sync/Product_Import.php:912
2594
  #. translators: Placeholders: %1$s - variation ID, %2$s - product name
2595
  msgid "Variation #%1$s of %2$s"
2596
  msgstr ""
2597
 
2598
+ #: includes/Sync/Product_Import.php:1291
2599
  #. translators: Placeholders: %s - missing parameter name
2600
  msgid "Missing parameter %s"
2601
  msgstr ""
2602
 
2603
+ #: includes/Sync/Product_Import.php:1297
2604
  #. translators: Placeholders: %s - comma separated list of valid product types
2605
  msgid "Invalid product type - the product type must be any of these: %s"
2606
  msgstr ""
2607
 
2608
+ #: includes/Sync/Product_Import.php:1348
2609
  #. translators: Placeholders: %1$s - Square item name, %2$s - Failure reason
2610
  msgid "Could not update %1$s from Square. %2$s"
2611
  msgstr ""
2612
 
2613
+ #: includes/Sync/Product_Import.php:1351
2614
  #. translators: Placeholders: %1$s - Square item name, %2$s - Failure reason
2615
  msgid "Could not import %1$s from Square. %2$s"
2616
  msgstr ""
3341
  msgid "Migrated action with ID %1$d in %2$s to ID %3$d in %4$s"
3342
  msgstr ""
3343
 
3344
+ #: woocommerce-square.php:354
3345
  #. translators: plugin name
3346
  msgid ""
3347
  "<strong>All features in %1$s have been disabled</strong> due to unsupported "
3348
  "settings:<br>"
3349
  msgstr ""
3350
 
3351
+ #: woocommerce-square.php:362
3352
  #. translators: minimum PHP version, current PHP version
3353
  msgid ""
3354
  "&bull;&nbsp;<strong>Invalid PHP version: </strong>The minimum PHP version "
3355
  "required is %1$s. You are running %2$s.<br>"
3356
  msgstr ""
3357
 
3358
+ #: woocommerce-square.php:371
3359
  #. translators: link to documentation
3360
  msgid ""
3361
  "&bull;&nbsp;<strong>Invalid OPcache config: </strong><a href=\"%s\" "
3430
  msgid "#"
3431
  msgstr ""
3432
 
3433
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2365
3434
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:565
3435
  msgctxt "noun, software environment"
3436
  msgid "Test"
3437
  msgstr ""
3438
 
3439
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2366
3440
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2766
3441
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:566
3442
  msgctxt "credit card transaction type"
3443
  msgid "Authorization"
3444
  msgstr ""
3445
 
3446
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2366
3447
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2765
3448
  #: includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:566
3449
  msgctxt "noun, credit card transaction type"
3450
  msgid "Charge"
3451
  msgstr ""
3452
 
3453
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:2794
3454
  msgctxt ""
3455
  "coordinating conjunction for a list of order statuses: on-hold, processing, "
3456
  "or completed"
3457
  msgid "or"
3458
  msgstr ""
3459
 
3460
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3024
3461
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:201
3462
  msgctxt "credit card type"
3463
  msgid "Visa"
3464
  msgstr ""
3465
 
3466
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3025
3467
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:205
3468
  msgctxt "credit card type"
3469
  msgid "MasterCard"
3470
  msgstr ""
3471
 
3472
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3026
3473
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:209
3474
  msgctxt "credit card type"
3475
  msgid "American Express"
3476
  msgstr ""
3477
 
3478
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3027
3479
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:217
3480
  msgctxt "credit card type"
3481
  msgid "Discover"
3482
  msgstr ""
3483
 
3484
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3028
3485
  msgctxt "credit card type"
3486
  msgid "Diners"
3487
  msgstr ""
3488
 
3489
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3029
3490
  #: includes/Framework/PaymentGateway/Payment_Gateway_Helper.php:221
3491
  msgctxt "credit card type"
3492
  msgid "JCB"
3512
  msgid "Laser"
3513
  msgstr ""
3514
 
3515
+ #: includes/Framework/PaymentGateway/Payment_Gateway.php:3514
3516
  msgctxt "software environment"
3517
  msgid "Production"
3518
  msgstr ""
includes/API.php CHANGED
@@ -813,7 +813,7 @@ class API extends Base {
813
  $this->get_plugin()->log( 'Access Token Expired, attempting a refresh.' );
814
  $this->get_plugin()->get_connection_handler()->refresh_connection();
815
 
816
- $failure_value = get_option( 'wc_' . $this->get_plugin()->get_id() . '_refresh_failed', 'yes' );
817
 
818
  if ( empty( $failure_value ) ) {
819
  // Successfully refreshed on the last attempt
813
  $this->get_plugin()->log( 'Access Token Expired, attempting a refresh.' );
814
  $this->get_plugin()->get_connection_handler()->refresh_connection();
815
 
816
+ $failure_value = get_option( 'wc_square_refresh_failed', 'yes' );
817
 
818
  if ( empty( $failure_value ) ) {
819
  // Successfully refreshed on the last attempt
includes/Admin/Settings_Page.php CHANGED
@@ -125,7 +125,7 @@ class Settings_Page extends \WC_Settings_Page {
125
  */
126
  public function get_settings() {
127
 
128
- return (array) apply_filters( 'woocommerce_get_settings_' . $this->get_id(), $this->settings_handler->get_form_fields() );
129
  }
130
 
131
 
@@ -152,7 +152,7 @@ class Settings_Page extends \WC_Settings_Page {
152
  *
153
  * @param array $sections settings sections
154
  */
155
- return (array) apply_filters( 'woocommerce_get_sections_' . $this->get_id(), $sections );
156
  }
157
 
158
 
125
  */
126
  public function get_settings() {
127
 
128
+ return (array) apply_filters( 'woocommerce_get_settings_square', $this->settings_handler->get_form_fields() );
129
  }
130
 
131
 
152
  *
153
  * @param array $sections settings sections
154
  */
155
+ return (array) apply_filters( 'woocommerce_get_sections_square', $sections );
156
  }
157
 
158
 
includes/Framework/Admin_Notice_Handler.php CHANGED
@@ -43,7 +43,7 @@ class Admin_Notice_Handler {
43
  add_action( 'admin_footer', array( $this, 'render_admin_notice_js' ), 20 );
44
 
45
  // AJAX handler to dismiss any warning/error notices
46
- add_action( 'wp_ajax_wc_plugin_framework_' . $this->get_plugin()->get_id() . '_dismiss_notice', array( $this, 'handle_dismiss_notice' ) );
47
  }
48
 
49
 
@@ -203,7 +203,7 @@ class Admin_Notice_Handler {
203
  echo sprintf(
204
  '<div class="%1$s" data-plugin-id="%2$s" data-message-id="%3$s" %4$s><p>%5$s</p></div>',
205
  esc_attr( implode( ' ', $classes ) ),
206
- esc_attr( $this->get_plugin()->get_id() ),
207
  esc_attr( $message_id ),
208
  ( ! $params['is_visible'] ) ? 'style="display:none;"' : '',
209
  wp_kses_post( $message )
@@ -295,7 +295,7 @@ class Admin_Notice_Handler {
295
 
296
  $dismissed_notices[ $message_id ] = true;
297
 
298
- update_user_meta( $user_id, '_wc_plugin_framework_' . $this->get_plugin()->get_id() . '_dismissed_messages', $dismissed_notices );
299
 
300
  /**
301
  * Admin Notice Dismissed Action.
@@ -306,7 +306,7 @@ class Admin_Notice_Handler {
306
  * @param string $message_id notice identifier
307
  * @param string|int $user_id
308
  */
309
- do_action( 'wc_' . $this->get_plugin()->get_id(). '_dismiss_notice', $message_id, $user_id );
310
  }
311
 
312
  /**
@@ -340,7 +340,7 @@ class Admin_Notice_Handler {
340
  $user_id = get_current_user_id();
341
  }
342
 
343
- $dismissed_notices = get_user_meta( $user_id, '_wc_plugin_framework_' . $this->get_plugin()->get_id() . '_dismissed_messages', true );
344
 
345
  if ( empty( $dismissed_notices ) ) {
346
  return array();
43
  add_action( 'admin_footer', array( $this, 'render_admin_notice_js' ), 20 );
44
 
45
  // AJAX handler to dismiss any warning/error notices
46
+ add_action( 'wp_ajax_wc_plugin_framework_square_dismiss_notice', array( $this, 'handle_dismiss_notice' ) );
47
  }
48
 
49
 
203
  echo sprintf(
204
  '<div class="%1$s" data-plugin-id="%2$s" data-message-id="%3$s" %4$s><p>%5$s</p></div>',
205
  esc_attr( implode( ' ', $classes ) ),
206
+ esc_attr( 'square' ),
207
  esc_attr( $message_id ),
208
  ( ! $params['is_visible'] ) ? 'style="display:none;"' : '',
209
  wp_kses_post( $message )
295
 
296
  $dismissed_notices[ $message_id ] = true;
297
 
298
+ update_user_meta( $user_id, '_wc_plugin_framework_square_dismissed_messages', $dismissed_notices );
299
 
300
  /**
301
  * Admin Notice Dismissed Action.
306
  * @param string $message_id notice identifier
307
  * @param string|int $user_id
308
  */
309
+ do_action( 'wc_square_dismiss_notice', $message_id, $user_id );
310
  }
311
 
312
  /**
340
  $user_id = get_current_user_id();
341
  }
342
 
343
+ $dismissed_notices = get_user_meta( $user_id, '_wc_plugin_framework_square_dismissed_messages', true );
344
 
345
  if ( empty( $dismissed_notices ) ) {
346
  return array();
includes/Framework/Api/Base.php CHANGED
@@ -549,7 +549,7 @@ abstract class Base {
549
  */
550
  protected function get_api_id() {
551
 
552
- return $this->get_plugin()->get_id();
553
  }
554
 
555
  /**
@@ -654,6 +654,6 @@ abstract class Base {
654
  * @param bool $is_available whether TLS 1.2 is available
655
  * @param Base $api API class instance
656
  */
657
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_api_is_tls_1_2_available', $is_available, $this );
658
  }
659
  }
549
  */
550
  protected function get_api_id() {
551
 
552
+ return 'square';
553
  }
554
 
555
  /**
654
  * @param bool $is_available whether TLS 1.2 is available
655
  * @param Base $api API class instance
656
  */
657
+ return apply_filters( 'wc_square_api_is_tls_1_2_available', $is_available, $this );
658
  }
659
  }
includes/Framework/Lifecycle.php CHANGED
@@ -65,7 +65,7 @@ class Lifecycle {
65
  }
66
 
67
  // catch any milestones triggered by action
68
- add_action( 'wc_' . $this->get_plugin()->get_id() . '_milestone_reached', array( $this, 'trigger_milestone' ), 10, 3 );
69
  }
70
 
71
 
@@ -97,7 +97,7 @@ class Lifecycle {
97
  *
98
  * @since 3.0.0
99
  */
100
- do_action( 'wc_' . $this->get_plugin()->get_id() . '_installed' );
101
 
102
  } else {
103
 
@@ -118,7 +118,7 @@ class Lifecycle {
118
  *
119
  * @param string $installed_version previously installed version
120
  */
121
- do_action( 'wc_' . $this->get_plugin()->get_id() . '_updated', $installed_version );
122
  }
123
 
124
  // new version number
@@ -142,16 +142,16 @@ class Lifecycle {
142
  */
143
  public function handle_activation() {
144
 
145
- if ( ! get_option( 'wc_' . $this->get_plugin()->get_id() . '_is_active', false ) ) {
146
 
147
  /**
148
  * Fires when the plugin is activated.
149
  *
150
  * @since 3.0.0
151
  */
152
- do_action( 'wc_' . $this->get_plugin()->get_id() . '_activated' );
153
 
154
- update_option( 'wc_' . $this->get_plugin()->get_id() . '_is_active', 'yes' );
155
  }
156
  }
157
 
@@ -170,9 +170,9 @@ class Lifecycle {
170
  *
171
  * @since 3.0.0
172
  */
173
- do_action( 'wc_' . $this->get_plugin()->get_id() . '_deactivated' );
174
 
175
- delete_option( 'wc_' . $this->get_plugin()->get_id() . '_is_active' );
176
  }
177
 
178
  /**
@@ -240,7 +240,7 @@ class Lifecycle {
240
  * @param string $message message text to be used for the milestone notice
241
  * @param string $id milestone ID
242
  */
243
- $message = apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_milestone_message', $this->generate_milestone_notice_message( $message ), $id );
244
 
245
  if ( $message ) {
246
 
@@ -349,7 +349,7 @@ class Lifecycle {
349
 
350
  $milestone_messages[ $id ] = $message;
351
 
352
- return update_option( 'wc_' . $this->get_plugin()->get_id() . '_milestone_messages', $milestone_messages );
353
  }
354
 
355
 
@@ -459,7 +459,7 @@ class Lifecycle {
459
  */
460
  protected function get_event_history_option_name() {
461
 
462
- return 'wc_' . $this->get_plugin()->get_id() . '_lifecycle_events';
463
  }
464
 
465
 
@@ -475,7 +475,7 @@ class Lifecycle {
475
  */
476
  protected function get_milestone_messages() {
477
 
478
- return get_option( 'wc_' . $this->get_plugin()->get_id() . '_milestone_messages', array() );
479
  }
480
 
481
 
@@ -491,7 +491,7 @@ class Lifecycle {
491
 
492
  $this->milestone_version = $version;
493
 
494
- return update_option( 'wc_' . $this->get_plugin()->get_id() . '_milestone_version', $version );
495
  }
496
 
497
 
@@ -505,7 +505,7 @@ class Lifecycle {
505
  public function get_milestone_version() {
506
 
507
  if ( ! $this->milestone_version ) {
508
- $this->milestone_version = get_option( 'wc_' . $this->get_plugin()->get_id() . '_milestone_version', '' );
509
  }
510
 
511
  return $this->milestone_version;
65
  }
66
 
67
  // catch any milestones triggered by action
68
+ add_action( 'wc_square_milestone_reached', array( $this, 'trigger_milestone' ), 10, 3 );
69
  }
70
 
71
 
97
  *
98
  * @since 3.0.0
99
  */
100
+ do_action( 'wc_square_installed' );
101
 
102
  } else {
103
 
118
  *
119
  * @param string $installed_version previously installed version
120
  */
121
+ do_action( 'wc_square_updated', $installed_version );
122
  }
123
 
124
  // new version number
142
  */
143
  public function handle_activation() {
144
 
145
+ if ( ! get_option( 'wc_square_is_active', false ) ) {
146
 
147
  /**
148
  * Fires when the plugin is activated.
149
  *
150
  * @since 3.0.0
151
  */
152
+ do_action( 'wc_square_activated' );
153
 
154
+ update_option( 'wc_square_is_active', 'yes' );
155
  }
156
  }
157
 
170
  *
171
  * @since 3.0.0
172
  */
173
+ do_action( 'wc_square_deactivated' );
174
 
175
+ delete_option( 'wc_square_is_active' );
176
  }
177
 
178
  /**
240
  * @param string $message message text to be used for the milestone notice
241
  * @param string $id milestone ID
242
  */
243
+ $message = apply_filters( 'wc_square_milestone_message', $this->generate_milestone_notice_message( $message ), $id );
244
 
245
  if ( $message ) {
246
 
349
 
350
  $milestone_messages[ $id ] = $message;
351
 
352
+ return update_option( 'wc_square_milestone_messages', $milestone_messages );
353
  }
354
 
355
 
459
  */
460
  protected function get_event_history_option_name() {
461
 
462
+ return 'wc_square_lifecycle_events';
463
  }
464
 
465
 
475
  */
476
  protected function get_milestone_messages() {
477
 
478
+ return get_option( 'wc_square_milestone_messages', array() );
479
  }
480
 
481
 
491
 
492
  $this->milestone_version = $version;
493
 
494
+ return update_option( 'wc_square_milestone_version', $version );
495
  }
496
 
497
 
505
  public function get_milestone_version() {
506
 
507
  if ( ! $this->milestone_version ) {
508
+ $this->milestone_version = get_option( 'wc_square_milestone_version', '' );
509
  }
510
 
511
  return $this->milestone_version;
includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_Order.php CHANGED
@@ -39,7 +39,7 @@ class Payment_Gateway_Admin_Order {
39
 
40
  add_action( 'woocommerce_order_item_add_action_buttons', array( $this, 'add_capture_button' ) );
41
 
42
- add_action( 'wp_ajax_wc_' . $this->get_plugin()->get_id() . '_capture_charge', array( $this, 'ajax_process_capture' ) );
43
 
44
  // bulk capture order action
45
  add_action( 'admin_footer-edit.php', array( $this, 'maybe_add_capture_charge_bulk_order_action' ) );
@@ -98,8 +98,8 @@ class Payment_Gateway_Admin_Order {
98
  'gateway_id' => Order_Compatibility::get_prop( $order, 'payment_method' ),
99
  'order_id' => Order_Compatibility::get_prop( $order, 'id' ),
100
  'capture_ays' => esc_html__( 'Are you sure you wish to process this capture? The action cannot be undone.', 'woocommerce-square' ),
101
- 'capture_action' => 'wc_' . $this->get_plugin()->get_id() . '_capture_charge',
102
- 'capture_nonce' => wp_create_nonce( 'wc_' . $this->get_plugin()->get_id() . '_capture_charge' ),
103
  'capture_error' => esc_html__( 'Something went wrong, and the capture could no be completed. Please try again.', 'woocommerce-square' ),
104
  ) );
105
 
@@ -216,8 +216,14 @@ class Payment_Gateway_Admin_Order {
216
  */
217
  public function add_capture_button( $order ) {
218
 
 
 
 
 
 
 
219
  // only display the button for core orders
220
- if ( ! $order instanceof \WC_Order || 'shop_order' !== get_post_type( Order_Compatibility::get_prop( $order, 'id' ) ) ) {
221
  return;
222
  }
223
 
@@ -300,7 +306,7 @@ class Payment_Gateway_Admin_Order {
300
  */
301
  public function ajax_process_capture() {
302
 
303
- check_ajax_referer( 'wc_' . $this->get_plugin()->get_id() . '_capture_charge', 'nonce' );
304
 
305
  $gateway_id = Square_Helper::get_request( 'gateway_id' );
306
 
39
 
40
  add_action( 'woocommerce_order_item_add_action_buttons', array( $this, 'add_capture_button' ) );
41
 
42
+ add_action( 'wp_ajax_wc_square_capture_charge', array( $this, 'ajax_process_capture' ) );
43
 
44
  // bulk capture order action
45
  add_action( 'admin_footer-edit.php', array( $this, 'maybe_add_capture_charge_bulk_order_action' ) );
98
  'gateway_id' => Order_Compatibility::get_prop( $order, 'payment_method' ),
99
  'order_id' => Order_Compatibility::get_prop( $order, 'id' ),
100
  'capture_ays' => esc_html__( 'Are you sure you wish to process this capture? The action cannot be undone.', 'woocommerce-square' ),
101
+ 'capture_action' => 'wc_square_capture_charge',
102
+ 'capture_nonce' => wp_create_nonce( 'wc_square_capture_charge' ),
103
  'capture_error' => esc_html__( 'Something went wrong, and the capture could no be completed. Please try again.', 'woocommerce-square' ),
104
  ) );
105
 
216
  */
217
  public function add_capture_button( $order ) {
218
 
219
+ if ( class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) ) {
220
+ $post_type = \Automattic\WooCommerce\Utilities\OrderUtil::get_order_type( $order->get_id() );
221
+ } else {
222
+ $post_type = get_post_type( Order_Compatibility::get_prop( $order, 'id' ) );
223
+ }
224
+
225
  // only display the button for core orders
226
+ if ( ! $order instanceof \WC_Order || 'shop_order' !== $post_type ) {
227
  return;
228
  }
229
 
306
  */
307
  public function ajax_process_capture() {
308
 
309
+ check_ajax_referer( 'wc_square_capture_charge', 'nonce' );
310
 
311
  $gateway_id = Square_Helper::get_request( 'gateway_id' );
312
 
includes/Framework/PaymentGateway/Admin/Payment_Gateway_Admin_User_Handler.php CHANGED
@@ -40,10 +40,10 @@ class Payment_Gateway_Admin_User_Handler {
40
  add_action( 'edit_user_profile_update', array( $this, 'save_profile_fields' ) );
41
 
42
  // Display the token editor markup inside the profile section
43
- add_action( 'wc_payment_gateway_' . $this->get_plugin()->get_id() . '_user_profile', array( $this, 'display_token_editors' ) );
44
 
45
  // Display the customer ID field markup inside the profile section
46
- add_action( 'wc_payment_gateway_' . $this->get_plugin()->get_id() . '_user_profile', array( $this, 'display_customer_id_fields' ) );
47
  }
48
 
49
 
@@ -78,7 +78,7 @@ class Payment_Gateway_Admin_User_Handler {
78
  }
79
 
80
  $user_id = $user->ID;
81
- $plugin_id = $this->get_plugin()->get_id();
82
  $section_title = $this->get_title();
83
  $section_description = $this->get_description();
84
 
@@ -354,7 +354,7 @@ class Payment_Gateway_Admin_User_Handler {
354
  * @param bool $display
355
  * @param \Payment_Gateway_Plugin $plugin the gateway plugin instance
356
  */
357
- return apply_filters( 'wc_payment_gateway_' . $this->get_plugin()->get_id() . '_display_user_profile', ! empty( $gateways ), $this->get_plugin() );
358
  }
359
 
360
 
40
  add_action( 'edit_user_profile_update', array( $this, 'save_profile_fields' ) );
41
 
42
  // Display the token editor markup inside the profile section
43
+ add_action( 'wc_payment_gateway_square_user_profile', array( $this, 'display_token_editors' ) );
44
 
45
  // Display the customer ID field markup inside the profile section
46
+ add_action( 'wc_payment_gateway_square_user_profile', array( $this, 'display_customer_id_fields' ) );
47
  }
48
 
49
 
78
  }
79
 
80
  $user_id = $user->ID;
81
+ $plugin_id = 'square';
82
  $section_title = $this->get_title();
83
  $section_description = $this->get_description();
84
 
354
  * @param bool $display
355
  * @param \Payment_Gateway_Plugin $plugin the gateway plugin instance
356
  */
357
+ return apply_filters( 'wc_payment_gateway_square_display_user_profile', ! empty( $gateways ), $this->get_plugin() );
358
  }
359
 
360
 
includes/Framework/PaymentGateway/Payment_Gateway.php CHANGED
@@ -484,7 +484,7 @@ abstract class Payment_Gateway extends \WC_Payment_Gateway {
484
  * @param string $js_url JS asset URL
485
  * @return string
486
  */
487
- $js_url = apply_filters( 'wc_payment_gateway_' . $this->get_plugin()->get_id() . '_javascript_url', $js_url );
488
 
489
  wp_enqueue_script( $handle, $js_url, array(), $this->get_plugin()->get_version(), true );
490
  }
@@ -504,7 +504,7 @@ abstract class Payment_Gateway extends \WC_Payment_Gateway {
504
  * @param string $css_url CSS asset URL
505
  * @return string
506
  */
507
- $css_url = apply_filters( 'wc_payment_gateway_' . $this->get_plugin()->get_id() . '_css_url', $css_url );
508
 
509
  wp_enqueue_style( $handle, $css_url, array(), $this->get_plugin()->get_version() );
510
  }
@@ -1503,7 +1503,7 @@ abstract class Payment_Gateway extends \WC_Payment_Gateway {
1503
  * @since 3.0.0
1504
  * @param bool $use_svg true by default, false to use PNGs
1505
  */
1506
- $image_extension = apply_filters( 'wc_payment_gateway_' . $this->get_plugin()->get_id() . '_use_svg', true ) ? '.svg' : '.png';
1507
 
1508
  // first, is the card image available within the plugin?
1509
  if ( is_readable( $this->get_plugin()->get_payment_gateway_framework_assets_path() . '/images/card-' . $image_type . $image_extension ) ) {
@@ -2209,6 +2209,11 @@ abstract class Payment_Gateway extends \WC_Payment_Gateway {
2209
 
2210
  $this->update_order_meta( $order, 'trans_id', $response->get_transaction_id() );
2211
 
 
 
 
 
 
2212
  update_post_meta( Order_Compatibility::get_prop( $order, 'id' ), '_transaction_id', $response->get_transaction_id() );
2213
  }
2214
 
@@ -2674,7 +2679,7 @@ abstract class Payment_Gateway extends \WC_Payment_Gateway {
2674
  }
2675
 
2676
  // no leading underscore since this is meant to be visible to the admin
2677
- return 'wc_' . $this->get_plugin()->get_id() . '_customer_id' . ( ! $this->is_production_environment( $environment_id ) ? '_' . $environment_id : '' );
2678
  }
2679
 
2680
 
484
  * @param string $js_url JS asset URL
485
  * @return string
486
  */
487
+ $js_url = apply_filters( 'wc_payment_gateway_square_javascript_url', $js_url );
488
 
489
  wp_enqueue_script( $handle, $js_url, array(), $this->get_plugin()->get_version(), true );
490
  }
504
  * @param string $css_url CSS asset URL
505
  * @return string
506
  */
507
+ $css_url = apply_filters( 'wc_payment_gateway_square_css_url', $css_url );
508
 
509
  wp_enqueue_style( $handle, $css_url, array(), $this->get_plugin()->get_version() );
510
  }
1503
  * @since 3.0.0
1504
  * @param bool $use_svg true by default, false to use PNGs
1505
  */
1506
+ $image_extension = apply_filters( 'wc_payment_gateway_square_use_svg', true ) ? '.svg' : '.png';
1507
 
1508
  // first, is the card image available within the plugin?
1509
  if ( is_readable( $this->get_plugin()->get_payment_gateway_framework_assets_path() . '/images/card-' . $image_type . $image_extension ) ) {
2209
 
2210
  $this->update_order_meta( $order, 'trans_id', $response->get_transaction_id() );
2211
 
2212
+ if ( $order instanceof \WC_Order ) {
2213
+ $order->set_transaction_id( $response->get_transaction_id() );
2214
+ $order->save();
2215
+ }
2216
+
2217
  update_post_meta( Order_Compatibility::get_prop( $order, 'id' ), '_transaction_id', $response->get_transaction_id() );
2218
  }
2219
 
2679
  }
2680
 
2681
  // no leading underscore since this is meant to be visible to the admin
2682
+ return 'wc_square_customer_id' . ( ! $this->is_production_environment( $environment_id ) ? '_' . $environment_id : '' );
2683
  }
2684
 
2685
 
includes/Framework/PaymentGateway/Payment_Gateway_My_Payment_Methods.php CHANGED
@@ -49,7 +49,7 @@ class Payment_Gateway_My_Payment_Methods {
49
  add_action( 'wp', array( $this, 'init' ) );
50
 
51
  // save a payment method via AJAX
52
- add_action( 'wp_ajax_wc_' . $this->get_plugin()->get_id() . '_save_payment_method', array( $this, 'ajax_save_payment_method' ) );
53
  }
54
 
55
 
@@ -166,7 +166,7 @@ class Payment_Gateway_My_Payment_Methods {
166
  *
167
  * @param Payment_Gateway_My_Payment_Methods $this instance
168
  */
169
- do_action( 'wc_' . $this->get_plugin()->get_id() . '_before_my_payment_method_table', $this );
170
 
171
  echo $this->get_table_html();
172
 
@@ -179,7 +179,7 @@ class Payment_Gateway_My_Payment_Methods {
179
  *
180
  * @param Payment_Gateway_My_Payment_Methods $this instance
181
  */
182
- do_action( 'wc_' . $this->get_plugin()->get_id() . '_after_my_payment_method_table', $this );
183
 
184
  }
185
  }
@@ -193,11 +193,11 @@ class Payment_Gateway_My_Payment_Methods {
193
  public function render_js() {
194
 
195
  $args = array(
196
- 'id' => $this->get_plugin()->get_id(),
197
  'slug' => $this->get_plugin()->get_id_dasherized(),
198
  'has_core_tokens' => (bool) wc_get_customer_saved_methods_list( get_current_user_id() ),
199
  'ajax_url' => admin_url( 'admin-ajax.php' ),
200
- 'ajax_nonce' => wp_create_nonce( 'wc_' . $this->get_plugin()->get_id() . '_save_payment_method' ),
201
  'i18n' => array(
202
  'edit_button' => esc_html__( 'Edit', 'woocommerce-square' ),
203
  'cancel_button' => esc_html__( 'Cancel', 'woocommerce-square' ),
@@ -214,11 +214,11 @@ class Payment_Gateway_My_Payment_Methods {
214
  * @param array $args arguments
215
  * @param Payment_Gateway_My_Payment_Methods $handler payment methods handler
216
  */
217
- $args = apply_filters( 'wc_payment_gateway_' . $this->get_plugin()->get_id() . '_payment_methods_js_args', $args, $this );
218
 
219
  wc_enqueue_js( sprintf(
220
  'window.wc_%1$s_payment_methods_handler = new %2$s( %3$s );',
221
- esc_js( $this->get_plugin()->get_id() ),
222
  esc_js( $this->get_js_handler_class() ),
223
  wp_json_encode( $args )
224
  ) );
@@ -265,7 +265,7 @@ class Payment_Gateway_My_Payment_Methods {
265
  * @param string $html table HTML
266
  * @param Payment_Gateway_My_Payment_Methods $this instance
267
  */
268
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_html', $html, $this );
269
  }
270
 
271
 
@@ -295,7 +295,7 @@ class Payment_Gateway_My_Payment_Methods {
295
  * @param string $html table head HTML
296
  * @param Payment_Gateway_My_Payment_Methods $this instance
297
  */
298
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_head_html', $html, $this );
299
  }
300
 
301
 
@@ -328,7 +328,7 @@ class Payment_Gateway_My_Payment_Methods {
328
  * }
329
  * @param Payment_Gateway_My_Payment_Methods $this instance
330
  */
331
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_headers', $headers, $this );
332
  }
333
 
334
 
@@ -379,7 +379,7 @@ class Payment_Gateway_My_Payment_Methods {
379
  * @param string $html table body HTML
380
  * @param Payment_Gateway_My_Payment_Methods $this instance
381
  */
382
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_body_html', $html, $this );
383
  }
384
 
385
 
@@ -437,7 +437,7 @@ class Payment_Gateway_My_Payment_Methods {
437
  * @param Payment_Gateway_Payment_Token[] $tokens simple array of token objects
438
  * @param Payment_Gateway_My_Payment_Methods $this instance
439
  */
440
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_row_html', $html, $tokens, $this );
441
  }
442
 
443
 
@@ -478,7 +478,7 @@ class Payment_Gateway_My_Payment_Methods {
478
  * @param array $token simple array of Payment_Gateway_Payment_Token objects
479
  * @param Payment_Gateway_My_Payment_Methods $this instance
480
  */
481
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_body_row_data', $method, $token, $this );
482
  }
483
 
484
  /**
@@ -502,7 +502,7 @@ class Payment_Gateway_My_Payment_Methods {
502
  * @param string $title payment method title
503
  * @param Payment_Gateway_Payment_Token $token token object
504
  */
505
- $title = apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_method_title', $title, $token, $this );
506
 
507
  $html = '<div class="view">' . esc_html( $title ) . '</div>';
508
 
@@ -519,7 +519,7 @@ class Payment_Gateway_My_Payment_Methods {
519
  * @param string $html title HTML
520
  * @param Payment_Gateway_Payment_Token $token token object
521
  */
522
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_method_title_html', $html, $token );
523
  }
524
 
525
 
@@ -550,7 +550,7 @@ class Payment_Gateway_My_Payment_Methods {
550
  * @param string $html "default" flag HTML
551
  * @param Payment_Gateway_Payment_Token $token token object
552
  */
553
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_method_default_html', $html, $token );
554
  }
555
 
556
 
@@ -587,7 +587,7 @@ class Payment_Gateway_My_Payment_Methods {
587
  * @param string $html details HTML
588
  * @param Payment_Gateway_Payment_Token $token token object
589
  */
590
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_details_html', $html, $token );
591
  }
592
 
593
 
@@ -613,7 +613,7 @@ class Payment_Gateway_My_Payment_Methods {
613
  * @param string $html expiration date HTML
614
  * @param Payment_Gateway_Payment_Token $token token object
615
  */
616
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_method_expiry_html', $html, $token );
617
  }
618
 
619
 
@@ -674,7 +674,7 @@ class Payment_Gateway_My_Payment_Methods {
674
  * @param string $html actions HTML
675
  * @param Payment_Gateway_Payment_Token $token token object
676
  */
677
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_actions_html', $html, $token );
678
  }
679
 
680
 
@@ -723,7 +723,7 @@ class Payment_Gateway_My_Payment_Methods {
723
  * @param Payment_Gateway_Payment_Token $token
724
  * @param Payment_Gateway_My_Payment_Methods $this instance
725
  */
726
- return apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_table_method_actions', $actions, $token, $this );
727
  }
728
 
729
 
@@ -739,7 +739,7 @@ class Payment_Gateway_My_Payment_Methods {
739
  */
740
  public function ajax_save_payment_method() {
741
 
742
- check_ajax_referer( 'wc_' . $this->get_plugin()->get_id() . '_save_payment_method', 'nonce' );
743
 
744
  try {
745
 
@@ -778,7 +778,7 @@ class Payment_Gateway_My_Payment_Methods {
778
  wp_send_json_success( array(
779
  'html' => $this->get_table_body_row_html( array( $token ) ),
780
  'is_default' => $token->is_default(),
781
- 'nonce' => wp_create_nonce( 'wc_' . $this->get_plugin()->get_id() . '_save_payment_method' ),
782
  ) );
783
 
784
  } catch ( \Exception $e ) {
@@ -900,7 +900,7 @@ class Payment_Gateway_My_Payment_Methods {
900
  * @since 3.0.0
901
  * @param \Payment_Gateway_My_Payment_Methods $this instance
902
  */
903
- do_action( 'wc_' . $this->get_plugin()->get_id() . '_my_payment_methods_action_' . sanitize_title( $action ), $this );
904
  break;
905
  }
906
 
49
  add_action( 'wp', array( $this, 'init' ) );
50
 
51
  // save a payment method via AJAX
52
+ add_action( 'wp_ajax_wc_square_save_payment_method', array( $this, 'ajax_save_payment_method' ) );
53
  }
54
 
55
 
166
  *
167
  * @param Payment_Gateway_My_Payment_Methods $this instance
168
  */
169
+ do_action( 'wc_square_before_my_payment_method_table', $this );
170
 
171
  echo $this->get_table_html();
172
 
179
  *
180
  * @param Payment_Gateway_My_Payment_Methods $this instance
181
  */
182
+ do_action( 'wc_square_after_my_payment_method_table', $this );
183
 
184
  }
185
  }
193
  public function render_js() {
194
 
195
  $args = array(
196
+ 'id' => 'square',
197
  'slug' => $this->get_plugin()->get_id_dasherized(),
198
  'has_core_tokens' => (bool) wc_get_customer_saved_methods_list( get_current_user_id() ),
199
  'ajax_url' => admin_url( 'admin-ajax.php' ),
200
+ 'ajax_nonce' => wp_create_nonce( 'wc_square_save_payment_method' ),
201
  'i18n' => array(
202
  'edit_button' => esc_html__( 'Edit', 'woocommerce-square' ),
203
  'cancel_button' => esc_html__( 'Cancel', 'woocommerce-square' ),
214
  * @param array $args arguments
215
  * @param Payment_Gateway_My_Payment_Methods $handler payment methods handler
216
  */
217
+ $args = apply_filters( 'wc_payment_gateway_square_payment_methods_js_args', $args, $this );
218
 
219
  wc_enqueue_js( sprintf(
220
  'window.wc_%1$s_payment_methods_handler = new %2$s( %3$s );',
221
+ esc_js( 'square' ),
222
  esc_js( $this->get_js_handler_class() ),
223
  wp_json_encode( $args )
224
  ) );
265
  * @param string $html table HTML
266
  * @param Payment_Gateway_My_Payment_Methods $this instance
267
  */
268
+ return apply_filters( 'wc_square_my_payment_methods_table_html', $html, $this );
269
  }
270
 
271
 
295
  * @param string $html table head HTML
296
  * @param Payment_Gateway_My_Payment_Methods $this instance
297
  */
298
+ return apply_filters( 'wc_square_my_payment_methods_table_head_html', $html, $this );
299
  }
300
 
301
 
328
  * }
329
  * @param Payment_Gateway_My_Payment_Methods $this instance
330
  */
331
+ return apply_filters( 'wc_square_my_payment_methods_table_headers', $headers, $this );
332
  }
333
 
334
 
379
  * @param string $html table body HTML
380
  * @param Payment_Gateway_My_Payment_Methods $this instance
381
  */
382
+ return apply_filters( 'wc_square_my_payment_methods_table_body_html', $html, $this );
383
  }
384
 
385
 
437
  * @param Payment_Gateway_Payment_Token[] $tokens simple array of token objects
438
  * @param Payment_Gateway_My_Payment_Methods $this instance
439
  */
440
+ return apply_filters( 'wc_square_my_payment_methods_table_row_html', $html, $tokens, $this );
441
  }
442
 
443
 
478
  * @param array $token simple array of Payment_Gateway_Payment_Token objects
479
  * @param Payment_Gateway_My_Payment_Methods $this instance
480
  */
481
+ return apply_filters( 'wc_square_my_payment_methods_table_body_row_data', $method, $token, $this );
482
  }
483
 
484
  /**
502
  * @param string $title payment method title
503
  * @param Payment_Gateway_Payment_Token $token token object
504
  */
505
+ $title = apply_filters( 'wc_square_my_payment_methods_table_method_title', $title, $token, $this );
506
 
507
  $html = '<div class="view">' . esc_html( $title ) . '</div>';
508
 
519
  * @param string $html title HTML
520
  * @param Payment_Gateway_Payment_Token $token token object
521
  */
522
+ return apply_filters( 'wc_square_my_payment_methods_table_method_title_html', $html, $token );
523
  }
524
 
525
 
550
  * @param string $html "default" flag HTML
551
  * @param Payment_Gateway_Payment_Token $token token object
552
  */
553
+ return apply_filters( 'wc_square_my_payment_methods_table_method_default_html', $html, $token );
554
  }
555
 
556
 
587
  * @param string $html details HTML
588
  * @param Payment_Gateway_Payment_Token $token token object
589
  */
590
+ return apply_filters( 'wc_square_my_payment_methods_table_details_html', $html, $token );
591
  }
592
 
593
 
613
  * @param string $html expiration date HTML
614
  * @param Payment_Gateway_Payment_Token $token token object
615
  */
616
+ return apply_filters( 'wc_square_my_payment_methods_table_method_expiry_html', $html, $token );
617
  }
618
 
619
 
674
  * @param string $html actions HTML
675
  * @param Payment_Gateway_Payment_Token $token token object
676
  */
677
+ return apply_filters( 'wc_square_my_payment_methods_table_actions_html', $html, $token );
678
  }
679
 
680
 
723
  * @param Payment_Gateway_Payment_Token $token
724
  * @param Payment_Gateway_My_Payment_Methods $this instance
725
  */
726
+ return apply_filters( 'wc_square_my_payment_methods_table_method_actions', $actions, $token, $this );
727
  }
728
 
729
 
739
  */
740
  public function ajax_save_payment_method() {
741
 
742
+ check_ajax_referer( 'wc_square_save_payment_method', 'nonce' );
743
 
744
  try {
745
 
778
  wp_send_json_success( array(
779
  'html' => $this->get_table_body_row_html( array( $token ) ),
780
  'is_default' => $token->is_default(),
781
+ 'nonce' => wp_create_nonce( 'wc_square_save_payment_method' ),
782
  ) );
783
 
784
  } catch ( \Exception $e ) {
900
  * @since 3.0.0
901
  * @param \Payment_Gateway_My_Payment_Methods $this instance
902
  */
903
+ do_action( 'wc_square_my_payment_methods_action_' . sanitize_title( $action ), $this );
904
  break;
905
  }
906
 
includes/Framework/PaymentGateway/Payment_Gateway_Plugin.php CHANGED
@@ -374,7 +374,7 @@ abstract class Payment_Gateway_Plugin extends Plugin {
374
  *
375
  * @param bool $activated whether Apple Pay is activated
376
  */
377
- $activated = (bool) apply_filters( 'wc_payment_gateway_' . $this->get_id() . '_activate_apple_pay', false );
378
 
379
  if ( $this->supports_apple_pay() && $activated ) {
380
  $this->apple_pay = $this->build_apple_pay_instance();
@@ -919,7 +919,7 @@ abstract class Payment_Gateway_Plugin extends Plugin {
919
  public function get_settings_url( $gateway_id = null ) {
920
 
921
  // default to first gateway
922
- if ( is_null( $gateway_id ) || $gateway_id === $this->get_id() ) {
923
  reset( $this->gateways );
924
  $gateway_id = key( $this->gateways );
925
  }
374
  *
375
  * @param bool $activated whether Apple Pay is activated
376
  */
377
+ $activated = (bool) apply_filters( 'wc_payment_gateway_square_activate_apple_pay', false );
378
 
379
  if ( $this->supports_apple_pay() && $activated ) {
380
  $this->apple_pay = $this->build_apple_pay_instance();
919
  public function get_settings_url( $gateway_id = null ) {
920
 
921
  // default to first gateway
922
+ if ( is_null( $gateway_id ) || $gateway_id === 'square' ) {
923
  reset( $this->gateways );
924
  $gateway_id = key( $this->gateways );
925
  }
includes/Framework/Plugin.php CHANGED
@@ -140,7 +140,7 @@ abstract class Plugin {
140
  */
141
  protected function init_admin_message_handler() {
142
 
143
- $this->message_handler = new Admin_Message_Handler( $this->get_id() );
144
  }
145
 
146
 
@@ -338,8 +338,8 @@ abstract class Plugin {
338
  $custom_actions = array();
339
 
340
  // settings url(s)
341
- if ( $this->get_settings_link( $this->get_id() ) ) {
342
- $custom_actions['configure'] = $this->get_settings_link( $this->get_id() );
343
  }
344
 
345
  // documentation url if any
@@ -370,8 +370,8 @@ abstract class Plugin {
370
  */
371
  public function add_api_request_logging() {
372
 
373
- if ( ! has_action( 'wc_' . $this->get_id() . '_api_request_performed' ) ) {
374
- add_action( 'wc_' . $this->get_id() . '_api_request_performed', array( $this, 'log_api_request' ), 10, 2 );
375
  }
376
  }
377
 
@@ -470,7 +470,7 @@ abstract class Plugin {
470
  public function log( $message, $log_id = null ) {
471
 
472
  if ( is_null( $log_id ) ) {
473
- $log_id = $this->get_id();
474
  }
475
 
476
  if ( ! is_object( $this->logger ) ) {
@@ -525,7 +525,7 @@ abstract class Plugin {
525
  * @return string plugin id with dashes in place of underscores
526
  */
527
  public function get_id_dasherized() {
528
- return str_replace( '_', '-', $this->get_id() );
529
  }
530
 
531
 
@@ -597,7 +597,7 @@ abstract class Plugin {
597
  */
598
  public function get_plugin_version_name() {
599
 
600
- return 'wc_' . $this->get_id() . '_version';
601
  }
602
 
603
 
140
  */
141
  protected function init_admin_message_handler() {
142
 
143
+ $this->message_handler = new Admin_Message_Handler( 'square' );
144
  }
145
 
146
 
338
  $custom_actions = array();
339
 
340
  // settings url(s)
341
+ if ( $this->get_settings_link( 'square' ) ) {
342
+ $custom_actions['configure'] = $this->get_settings_link( 'square' );
343
  }
344
 
345
  // documentation url if any
370
  */
371
  public function add_api_request_logging() {
372
 
373
+ if ( ! has_action( 'wc_square_api_request_performed' ) ) {
374
+ add_action( 'wc_square_api_request_performed', array( $this, 'log_api_request' ), 10, 2 );
375
  }
376
  }
377
 
470
  public function log( $message, $log_id = null ) {
471
 
472
  if ( is_null( $log_id ) ) {
473
+ $log_id = 'square';
474
  }
475
 
476
  if ( ! is_object( $this->logger ) ) {
525
  * @return string plugin id with dashes in place of underscores
526
  */
527
  public function get_id_dasherized() {
528
+ return str_replace( '_', '-', 'square' );
529
  }
530
 
531
 
597
  */
598
  public function get_plugin_version_name() {
599
 
600
+ return 'wc_square_version';
601
  }
602
 
603
 
includes/Gateway.php CHANGED
@@ -233,7 +233,7 @@ class Gateway extends Payment_Gateway_Direct {
233
 
234
  try {
235
 
236
- if ( $this->is_3d_secure_enabled() && ! Square_Helper::get_post( 'wc-' . $this->get_id_dasherized() . '-buyer-verification-token' ) ) {
237
  throw new \Exception( '3D Secure Verification Token is missing' );
238
  }
239
 
@@ -269,9 +269,7 @@ class Gateway extends Payment_Gateway_Direct {
269
 
270
  $order = parent::get_order( $order_id );
271
 
272
- if ( $this->is_3d_secure_enabled() ) {
273
- $order->payment->verification_token = Square_Helper::get_post( 'wc-' . $this->get_id_dasherized() . '-buyer-verification-token' );
274
- }
275
 
276
  if ( empty( $order->payment->token ) ) {
277
 
@@ -864,12 +862,15 @@ class Gateway extends Payment_Gateway_Direct {
864
  /**
865
  * Determines if 3d secure is enabled.
866
  *
867
- * @since 2.1.0
 
868
  *
869
  * @return bool
870
  */
871
  public function is_3d_secure_enabled() {
872
 
 
 
873
  /**
874
  * Filters whether or not 3d Secure should be enabled.
875
  *
@@ -892,11 +893,13 @@ class Gateway extends Payment_Gateway_Direct {
892
  * @return bool
893
  */
894
  public function is_digital_wallet_available() {
895
- $is_available = false;
896
- $base_location = wc_get_base_location();
897
- $supported_countries = array( 'US', 'GB', 'CA', 'IE', 'FR', 'ES' );
 
 
898
 
899
- if ( wc_site_is_https() && in_array( get_woocommerce_currency(), array( 'USD', 'GBP', 'CAD', 'EUR' ), true ) && ( ! empty( $base_location['country'] ) && in_array( $base_location['country'], $supported_countries, true ) ) ) {
900
  $is_available = true;
901
  }
902
 
233
 
234
  try {
235
 
236
+ if ( '' === Square_Helper::get_post( 'wc-' . $this->get_id_dasherized() . '-buyer-verification-token' ) ) {
237
  throw new \Exception( '3D Secure Verification Token is missing' );
238
  }
239
 
269
 
270
  $order = parent::get_order( $order_id );
271
 
272
+ $order->payment->verification_token = Square_Helper::get_post( 'wc-' . $this->get_id_dasherized() . '-buyer-verification-token' );
 
 
273
 
274
  if ( empty( $order->payment->token ) ) {
275
 
862
  /**
863
  * Determines if 3d secure is enabled.
864
  *
865
+ * @since 2.1.0
866
+ * @deprecated 3.3.0 Square automatically detects whether SCA is required, so we do not need this function.
867
  *
868
  * @return bool
869
  */
870
  public function is_3d_secure_enabled() {
871
 
872
+ _deprecated_function( __FUNCTION__, '3.3.0' );
873
+
874
  /**
875
  * Filters whether or not 3d Secure should be enabled.
876
  *
893
  * @return bool
894
  */
895
  public function is_digital_wallet_available() {
896
+ $is_available = false;
897
+ $base_location = wc_get_base_location();
898
+ $supported_countries = array( 'US', 'GB', 'CA', 'IE', 'FR', 'ES', 'AU' );
899
+ $is_currency_supported = in_array( get_woocommerce_currency(), array( 'USD', 'GBP', 'CAD', 'EUR', 'AUD' ), true );
900
+ $is_country_supported = ( ! empty( $base_location['country'] ) && in_array( $base_location['country'], $supported_countries, true ) );
901
 
902
+ if ( wc_site_is_https() && $is_currency_supported && $is_country_supported ) {
903
  $is_available = true;
904
  }
905
 
includes/Gateway/API/Response_Message_Helper.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Square
4
+ *
5
+ * This source file is subject to the GNU General Public License v3.0
6
+ * that is bundled with this package in the file license.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.html
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@woocommerce.com so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade WooCommerce Square to newer
16
+ * versions in the future. If you wish to customize WooCommerce Square for your
17
+ * needs please refer to https://docs.woocommerce.com/document/woocommerce-square/
18
+ *
19
+ * @author WooCommerce
20
+ * @copyright Copyright: (c) 2019, Automattic, Inc.
21
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
22
+ */
23
+
24
+ namespace WooCommerce\Square\Gateway\API;
25
+
26
+ defined( 'ABSPATH' ) || exit;
27
+
28
+ /**
29
+ * WooCommerce Payment Gateway API Response Message Helper
30
+ *
31
+ * This utility class is meant to provide a standard set of error messages to be
32
+ * displayed to the customer during checkout.
33
+ *
34
+ * Most gateways define a plethora of error conditions, some of which a customer
35
+ * can resolve on their own, and others which must be handled by the admin/
36
+ * merchant. It's not always clear which conditions should be reported to a
37
+ * customer, or what the best wording is. This utility class seeks to ease
38
+ * the development burden of handling customer-facing error messages by
39
+ * defining a set of common error conditions/messages which can be used by
40
+ * nearly any gateway.
41
+ *
42
+ * This class, or a subclass, should be instantiated by the API response object,
43
+ * which will use a gateway-specific mapping of error conditions to message,
44
+ * and returned by the `Payment_Gateway_API_Response::get_user_message()`
45
+ * method implementation. Add new common/generic codes and messages to this
46
+ * base class as they are encountered during gateway integration development,
47
+ * and use a subclass to include any gateway-specific codes/messages.
48
+ *
49
+ * @since 2.2.3
50
+ */
51
+ class Response_Message_Helper {
52
+
53
+
54
+ /**
55
+ * Returns a message appropriate for a frontend user. This should be used
56
+ * to provide enough information to a user to allow them to resolve an
57
+ * issue on their own, but not enough to help nefarious folks fishing for
58
+ * info.
59
+ *
60
+ * @since 2.2.3
61
+ *
62
+ * @param string[] $message_ids array of string $message_id's which identify the message(s) to return
63
+ * @return string a user message, combining all $message_ids
64
+ */
65
+ public function get_user_messages( $message_ids ) {
66
+ $messages = array();
67
+
68
+ foreach ( $message_ids as $message_id ) {
69
+ $messages[] = $this->get_user_message( $message_id );
70
+ }
71
+
72
+ $messages = implode( ' ', $messages );
73
+
74
+ return trim( $messages );
75
+ }
76
+
77
+
78
+ /**
79
+ * Returns a message appropriate for a frontend user. This should be used
80
+ * to provide enough information to a user to allow them to resolve an
81
+ * issue on their own, but not enough to help nefarious folks fishing for
82
+ * info.
83
+ *
84
+ * @since 2.2.3
85
+ * @param string $message_id identifies the message to return
86
+ * @return string a user message
87
+ */
88
+ public function get_user_message( $message_id ) {
89
+ $error_codes = array(
90
+ // ErrorCodes from https://developer.squareup.com/docs/payments-api/error-codes
91
+ 'BAD_EXPIRATION' => esc_html__( 'The card expiration date is missing or incorrectly formatted.', 'woocommerce-square' ),
92
+ 'INVALID_ACCOUNT' => esc_html__( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
93
+ 'CARDHOLDER_INSUFFICIENT_PERMISSIONS' => esc_html__( 'The card issuer has declined the transaction due to restrictions on where the card can be used.', 'woocommerce-square' ),
94
+ 'INSUFFICIENT_PERMISSIONS' => esc_html__( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
95
+ 'INSUFFICIENT_FUNDS' => esc_html__( 'The payment source has insufficient funds to cover the payment.', 'woocommerce-square' ),
96
+ 'INVALID_LOCATION' => esc_html__( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
97
+ 'TRANSACTION_LIMIT' => esc_html__( 'The card issuer has determined the payment amount is too high or too low.', 'woocommerce-square' ),
98
+ 'CARD_EXPIRED' => esc_html__( 'The card issuer declined the request because the card is expired.', 'woocommerce-square' ),
99
+ 'CVV_FAILURE' => esc_html__( 'The card issuer declined the request because the CVV value is invalid.', 'woocommerce-square' ),
100
+ 'ADDRESS_VERIFICATION_FAILURE' => esc_html__( 'The card issuer declined the request because the postal code is invalid.', 'woocommerce-square' ),
101
+ 'TEMPORARY_ERROR' => esc_html__( 'A temporary internal error occurred. You can safely retry the payment.', 'woocommerce-square' ),
102
+ 'PAN_FAILURE' => esc_html__( 'The specified card number is invalid.', 'woocommerce-square' ),
103
+ 'EXPIRATION_FAILURE' => esc_html__( 'The card expiration date is invalid or indicates that the card is expired.', 'woocommerce-square' ),
104
+ 'CARD_NOT_SUPPORTED' => esc_html__( 'The card is not supported in the geographic region.', 'woocommerce-square' ),
105
+ 'INVALID_POSTAL_CODE' => esc_html__( 'The postal code is incorrectly formatted.', 'woocommerce-square' ),
106
+ 'PAYMENT_LIMIT_EXCEEDED' => esc_html__( 'Square declined the request because the payment amount exceeded the processing limit for this seller.', 'woocommerce-square' ),
107
+ 'REFUND_DECLINED' => esc_html__( 'The card issuer declined the refund.', 'woocommerce-square' ),
108
+ 'GENERIC_DECLINE' => esc_html__( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
109
+
110
+ // ErrorCodes not listed under Square Docs
111
+ 'INVALID_EXPIRATION' => esc_html__( 'The card expiration date is invalid or indicates that the card is expired.', 'woocommerce-square' ),
112
+
113
+ // ErrorCodes from SV Framework - https://github.com/skyverge/wc-plugin-framework/blob/master/woocommerce/payment-gateway/api/class-sv-wc-payment-gateway-api-response-message-helper.php
114
+ 'ERROR' => esc_html__( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
115
+ 'DECLINE' => esc_html__( 'We cannot process your order with the payment information that you provided. Please use a different payment account or an alternate payment method.', 'woocommerce-square' ),
116
+ 'HELD_FOR_REVIEW' => esc_html__( 'This order is being placed on hold for review. Please contact us to complete the transaction.', 'woocommerce-square' ),
117
+ 'HELD_FOR_INCORRECT_CSC' => esc_html__( 'This order is being placed on hold for review due to an incorrect card verification number. You may contact the store to complete the transaction.', 'woocommerce-square' ),
118
+ 'CVV_FAILURE' => esc_html__( 'The card verification number is invalid, please try again.', 'woocommerce-square' ),
119
+ 'CSC_MISSING' => esc_html__( 'Please enter your card verification number and try again.', 'woocommerce-square' ),
120
+ 'UNSUPPORTED_CARD_BRAND' => esc_html__( 'That card type is not accepted, please use an alternate card or other form of payment.', 'woocommerce-square' ),
121
+ 'INVALID_CARD' => esc_html__( 'The card type is invalid or does not correlate with the credit card number. Please try again or use an alternate card or other form of payment.', 'woocommerce-square' ),
122
+ 'CARD_TYPE_MISSING' => esc_html__( 'Please select the card type and try again.', 'woocommerce-square' ),
123
+ 'CARD_NUMBER_TYPE_INVALID' => esc_html__( 'The card type is invalid or does not correlate with the credit card number. Please try again or use an alternate card or other form of payment.', 'woocommerce-square' ),
124
+ 'INVALID_EXPIRATION' => esc_html__( 'The card expiration date is invalid, please re-enter and try again.', 'woocommerce-square' ),
125
+ 'INVALID_EXPIRATION_YEAR' => esc_html__( 'The card expiration year is invalid, please re-enter and try again.', 'woocommerce-square' ),
126
+ 'CARD_EXPIRY_MISSING' => esc_html__( 'Please enter your card expiration date and try again.', 'woocommerce-square' ),
127
+ 'BANK_ABA_INVALID' => esc_html__( 'The bank routing number is invalid, please re-enter and try again.', 'woocommerce-square' ),
128
+ 'BANK_ACCOUNT_NUMBER_INVALID' => esc_html__( 'The bank account number is invalid, please re-enter and try again.', 'woocommerce-square' ),
129
+ 'CARD_DECLINED' => esc_html__( 'The provided card was declined, please use an alternate card or other form of payment.', 'woocommerce-square' ),
130
+ 'CARD_INACTIVE' => esc_html__( 'The card is inactivate or not authorized for card-not-present transactions, please use an alternate card or other form of payment.', 'woocommerce-square' ),
131
+ 'TRANSACTION_LIMIT' => esc_html__( 'The credit limit for the card has been reached, please use an alternate card or other form of payment.', 'woocommerce-square' ),
132
+ 'VERIFY_CVV_FAILURE' => esc_html__( 'The card verification number does not match. Please re-enter and try again.', 'woocommerce-square' ),
133
+ 'AVS_MISMATCH' => esc_html__( 'The provided address does not match the billing address for cardholder. Please verify the address and try again.', 'woocommerce-square' ),
134
+ );
135
+
136
+ $message = null;
137
+ $message_id = strtoupper( $message_id );
138
+
139
+ if ( array_key_exists( $message_id, $error_codes ) ) {
140
+ $message = $error_codes[ $message_id ];
141
+ }
142
+
143
+ /**
144
+ * Payment Gateway API Response User Message Filter.
145
+ *
146
+ * Allow actors to modify the error message returned to a user when a transaction
147
+ * has encountered an error and the admin has enabled the "show detailed
148
+ * decline messages" setting
149
+ *
150
+ * @since 2.2.3
151
+ * @param string $message message to show to user
152
+ * @param string $message_id machine code for the message, e.g. card_expired
153
+ * @param Response_Message_Helper $this instance
154
+ */
155
+ return apply_filters( 'wc_payment_gateway_transaction_response_user_message', $message, $message_id, $this );
156
+ }
157
+ }
includes/Gateway/API/Responses/Charge.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
  namespace WooCommerce\Square\Gateway\API\Responses;
 
4
  use WooCommerce\Square\Framework\PaymentGateway\Api\Payment_Gateway_API_Authorization_Response;
5
  use WooCommerce\Square\Framework\PaymentGateway\Api\Payment_Gateway_API_Response_Message_Helper;
6
 
@@ -126,28 +127,9 @@ class Charge extends \WooCommerce\Square\Gateway\API\Response implements Payment
126
  */
127
  public function get_user_message() {
128
 
129
- $message_id = '';
130
-
131
- switch ( $this->get_status_code() ) {
132
-
133
- case 'CARD_DECLINED':
134
- $message_id = 'card_declined';
135
- break;
136
-
137
- case 'INVALID_EXPIRATION':
138
- $message_id = 'card_expiry_invalid';
139
- break;
140
-
141
- case 'VERIFY_AVS_FAILURE':
142
- $message_id = 'avs_mismatch';
143
- break;
144
-
145
- case 'VERIFY_CVV_FAILURE':
146
- $message_id = 'csc_mismatch';
147
- break;
148
- }
149
 
150
- $helper = new Payment_Gateway_API_Response_Message_Helper();
151
 
152
  return $helper->get_user_message( $message_id );
153
  }
1
  <?php
2
 
3
  namespace WooCommerce\Square\Gateway\API\Responses;
4
+
5
  use WooCommerce\Square\Framework\PaymentGateway\Api\Payment_Gateway_API_Authorization_Response;
6
  use WooCommerce\Square\Framework\PaymentGateway\Api\Payment_Gateway_API_Response_Message_Helper;
7
 
127
  */
128
  public function get_user_message() {
129
 
130
+ $message_id = $this->get_status_code();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
+ $helper = new \WooCommerce\Square\Gateway\API\Response_Message_Helper();
133
 
134
  return $helper->get_user_message( $message_id );
135
  }
includes/Gateway/API/Responses/Create_Payment.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
  namespace WooCommerce\Square\Gateway\API\Responses;
 
4
  use WooCommerce\Square\Framework\PaymentGateway\Api\Payment_Gateway_API_Authorization_Response;
5
  use WooCommerce\Square\Framework\PaymentGateway\Api\Payment_Gateway_API_Response_Message_Helper;
6
 
@@ -112,27 +113,9 @@ class Create_Payment extends \WooCommerce\Square\Gateway\API\Response implements
112
  */
113
  public function get_user_message() {
114
 
115
- $message_id = '';
116
-
117
- switch ( $this->get_status_code() ) {
118
- case 'CARD_DECLINED':
119
- $message_id = 'card_declined';
120
- break;
121
-
122
- case 'INVALID_EXPIRATION':
123
- $message_id = 'card_expiry_invalid';
124
- break;
125
-
126
- case 'VERIFY_AVS_FAILURE':
127
- $message_id = 'avs_mismatch';
128
- break;
129
-
130
- case 'VERIFY_CVV_FAILURE':
131
- $message_id = 'csc_mismatch';
132
- break;
133
- }
134
 
135
- $helper = new Payment_Gateway_API_Response_Message_Helper();
136
 
137
  return $helper->get_user_message( $message_id );
138
  }
1
  <?php
2
 
3
  namespace WooCommerce\Square\Gateway\API\Responses;
4
+
5
  use WooCommerce\Square\Framework\PaymentGateway\Api\Payment_Gateway_API_Authorization_Response;
6
  use WooCommerce\Square\Framework\PaymentGateway\Api\Payment_Gateway_API_Response_Message_Helper;
7
 
113
  */
114
  public function get_user_message() {
115
 
116
+ $message_id = $this->get_status_code();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
+ $helper = new \WooCommerce\Square\Gateway\API\Response_Message_Helper();
119
 
120
  return $helper->get_user_message( $message_id );
121
  }
includes/Gateway/Blocks_Handler.php CHANGED
@@ -130,7 +130,6 @@ class Blocks_Handler extends AbstractPaymentMethodType {
130
  'application_id' => $this->get_gateway()->get_application_id(),
131
  'location_id' => $this->plugin->get_settings_handler()->get_location_id(),
132
  'is_sandbox' => $this->plugin->get_settings_handler()->is_sandbox(),
133
- 'is_3ds_enabled' => $this->get_gateway()->is_3d_secure_enabled(),
134
  'input_styles' => $this->get_input_styles(),
135
  'available_card_types' => $this->get_available_card_types(),
136
  'logging_enabled' => $this->get_gateway()->debug_log(),
@@ -291,7 +290,7 @@ class Blocks_Handler extends AbstractPaymentMethodType {
291
  public function display_compatible_version_notice() {
292
  $wc_blocks_version = Package::get_version();
293
 
294
- if ( version_compare( $wc_blocks_version, '4.8.0', '<' ) && 'yes' === $this->get_gateway()->get_option( 'enabled', 'no' ) && $this->get_gateway()->is_3d_secure_enabled() ) {
295
  ?>
296
  <div class="notice notice-warning is-dismissible">
297
  <?php // translators: %1$s - opening bold HTML tag, %2$s - closing bold HTML tag, %3$s - version number ?>
130
  'application_id' => $this->get_gateway()->get_application_id(),
131
  'location_id' => $this->plugin->get_settings_handler()->get_location_id(),
132
  'is_sandbox' => $this->plugin->get_settings_handler()->is_sandbox(),
 
133
  'input_styles' => $this->get_input_styles(),
134
  'available_card_types' => $this->get_available_card_types(),
135
  'logging_enabled' => $this->get_gateway()->debug_log(),
290
  public function display_compatible_version_notice() {
291
  $wc_blocks_version = Package::get_version();
292
 
293
+ if ( version_compare( $wc_blocks_version, '4.8.0', '<' ) && 'yes' === $this->get_gateway()->get_option( 'enabled', 'no' ) ) {
294
  ?>
295
  <div class="notice notice-warning is-dismissible">
296
  <?php // translators: %1$s - opening bold HTML tag, %2$s - closing bold HTML tag, %3$s - version number ?>
includes/Gateway/Digital_Wallet.php CHANGED
@@ -21,6 +21,7 @@ namespace WooCommerce\Square\Gateway;
21
 
22
  defined( 'ABSPATH' ) || exit;
23
 
 
24
  use WooCommerce\Square\Plugin;
25
 
26
  class Digital_Wallet {
@@ -71,6 +72,7 @@ class Digital_Wallet {
71
  // Calculate the value of option `wc_square_apple_pay_enabled` which is not stored in the DB for WC Admin inbox notifications
72
  add_filter( 'pre_option_wc_square_apple_pay_enabled', array( $this, 'get_option_is_apple_pay_enabled' ), 10, 1 );
73
  add_filter( 'woocommerce_checkout_posted_data', array( $this, 'filter_posted_data' ) );
 
74
  }
75
 
76
  /**
@@ -109,6 +111,10 @@ class Digital_Wallet {
109
  add_action( 'woocommerce_before_checkout_form', array( $this, 'render_button' ), 15 );
110
  }
111
 
 
 
 
 
112
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
113
  }
114
 
@@ -182,7 +188,7 @@ class Digital_Wallet {
182
  $button_text = '';
183
  }
184
 
185
- $apple_pay_classes[] = 'wc-square-wallet-button-' . $apple_button_style;
186
 
187
  ?>
188
  <div id="wc-square-digital-wallet" style="display:none;">
@@ -214,6 +220,12 @@ class Digital_Wallet {
214
  wp_enqueue_script( 'wc-square-digital-wallet', $this->gateway->get_plugin()->get_plugin_url() . '/assets/js/frontend/wc-square-digital-wallet.min.js', array( 'jquery' ), Plugin::VERSION, true );
215
 
216
  try {
 
 
 
 
 
 
217
  $args = apply_filters(
218
  'wc_square_digital_wallet_js_args',
219
  array(
@@ -231,9 +243,10 @@ class Digital_Wallet {
231
  'process_checkout_nonce' => wp_create_nonce( 'woocommerce-process_checkout' ),
232
  'logging_enabled' => $this->gateway->debug_log(),
233
  'hide_button_options' => $this->get_hidden_button_options(),
234
- 'is_3d_secure_enabled' => $this->gateway->is_3d_secure_enabled(),
235
  'google_pay_color' => $this->gateway->get_option( 'digital_wallets_google_pay_button_color', 'black' ),
236
  'apple_pay_color' => $this->gateway->get_option( 'digital_wallets_apple_pay_button_color', 'black' ),
 
 
237
  )
238
  );
239
 
@@ -255,7 +268,9 @@ class Digital_Wallet {
255
  * @return array
256
  */
257
  public function get_payment_request_for_context( $context ) {
258
- $payment_request = array();
 
 
259
 
260
  switch ( $context ) {
261
  case 'product':
@@ -264,7 +279,13 @@ class Digital_Wallet {
264
 
265
  case 'cart':
266
  case 'checkout':
267
- if ( isset( WC()->cart ) && $this->allowed_for_cart() ) {
 
 
 
 
 
 
268
  WC()->cart->calculate_totals();
269
  $payment_request = $this->build_payment_request( WC()->cart->total );
270
  }
@@ -360,10 +381,20 @@ class Digital_Wallet {
360
  * @return array
361
  */
362
  public function build_payment_request( $amount, $data = array() ) {
363
- $data = wp_parse_args(
 
 
 
 
 
 
 
 
 
 
364
  $data,
365
  array(
366
- 'requestShippingContact' => isset( WC()->cart ) && WC()->cart->needs_shipping(),
367
  'requestEmailAddress' => true,
368
  'requestBillingContact' => true,
369
  'countryCode' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
@@ -371,12 +402,25 @@ class Digital_Wallet {
371
  )
372
  );
373
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  if ( count( WC()->shipping->get_packages() ) > 1 ) {
375
  throw new \Exception( __( 'This payment method cannot be used for multiple shipments.', 'woocommerce-square' ) );
376
  }
377
 
378
  if ( ! isset( $data['lineItems'] ) ) {
379
- $data['lineItems'] = $this->build_payment_request_line_items();
380
  }
381
 
382
  if ( true === $data['requestShippingContact'] ) {
@@ -403,19 +447,32 @@ class Digital_Wallet {
403
  * Builds an array of line items/totals to be sent back to Square in the lineItems array.
404
  *
405
  * @since 2.3
406
- * @param array $cart_totals
407
  * @return array
408
  */
409
- public function build_payment_request_line_items( $cart_totals = array() ) {
410
- $cart_totals = empty( $cart_totals ) ? $this->get_cart_totals() : $cart_totals;
411
- $line_items = array();
 
 
 
 
 
 
 
 
412
 
413
- foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
414
- $amount = number_format( $cart_item['line_subtotal'], 2, '.', '' );
415
- $quantity_label = 1 < $cart_item['quantity'] ? ' x ' . $cart_item['quantity'] : '';
 
 
 
 
 
416
 
417
  $item = array(
418
- 'label' => $cart_item['data']->get_name() . $quantity_label,
419
  'amount' => $amount,
420
  'pending' => false,
421
  );
@@ -423,34 +480,34 @@ class Digital_Wallet {
423
  $line_items[] = $item;
424
  }
425
 
426
- if ( $cart_totals['shipping'] > 0 ) {
427
  $line_items[] = array(
428
  'label' => __( 'Shipping', 'woocommerce-square' ),
429
- 'amount' => number_format( $cart_totals['shipping'], 2, '.', '' ),
430
  'pending' => false,
431
  );
432
  }
433
 
434
- if ( $cart_totals['taxes'] > 0 ) {
435
  $line_items[] = array(
436
  'label' => __( 'Tax', 'woocommerce-square' ),
437
- 'amount' => number_format( $cart_totals['taxes'], 2, '.', '' ),
438
  'pending' => false,
439
  );
440
  }
441
 
442
- if ( $cart_totals['discount'] > 0 ) {
443
  $line_items[] = array(
444
  'label' => __( 'Discount', 'woocommerce-square' ),
445
- 'amount' => number_format( $cart_totals['discount'], 2, '.', '' ),
446
  'pending' => false,
447
  );
448
  }
449
 
450
- if ( $cart_totals['fees'] > 0 ) {
451
  $line_items[] = array(
452
  'label' => __( 'Fees', 'woocommerce-square' ),
453
- 'amount' => number_format( $cart_totals['fees'], 2, '.', '' ),
454
  'pending' => false,
455
  );
456
  }
@@ -585,6 +642,12 @@ class Digital_Wallet {
585
  }
586
  }
587
 
 
 
 
 
 
 
588
  $packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages );
589
 
590
  WC()->shipping->calculate_shipping( $packages );
@@ -596,11 +659,11 @@ class Digital_Wallet {
596
  * @param string $country_code The country's 2 letter ISO 3166-1 alpha-2 code.
597
  * @param string $state_name The full name of the state that is to be search for its code.
598
  *
599
- * @return string|null
600
  */
601
  public static function get_state_code_by_name( $country_code = '', $state_name = '' ) {
602
  if ( empty( $country_code ) || empty( $state_name ) ) {
603
- return null;
604
  }
605
 
606
  $states = WC()->countries->get_states( $country_code );
@@ -618,7 +681,7 @@ class Digital_Wallet {
618
  }
619
  }
620
 
621
- return null;
622
  }
623
 
624
  /**
@@ -635,7 +698,11 @@ class Digital_Wallet {
635
  $shipping_address = array();
636
  $payment_request = array();
637
 
638
- if ( WC()->cart->needs_shipping() ) {
 
 
 
 
639
  if ( ! empty( $_POST['shipping_contact'] ) ) {
640
  $shipping_address = wp_parse_args(
641
  wc_clean( wp_unslash( $_POST['shipping_contact'] ) ),
@@ -701,12 +768,32 @@ class Digital_Wallet {
701
  }
702
  }
703
 
704
- WC()->cart->calculate_totals();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
705
 
706
- $payment_request['lineItems'] = $this->build_payment_request_line_items();
707
  $payment_request['total'] = array(
708
  'label' => get_bloginfo( 'name', 'display' ) . esc_html( $this->total_label_suffix ),
709
- 'amount' => number_format( WC()->cart->total, 2, '.', '' ),
710
  'pending' => false,
711
  );
712
 
@@ -740,6 +827,32 @@ class Digital_Wallet {
740
  return $posted_data;
741
  }
742
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743
  /**
744
  * Process the digital wallet checkout
745
  *
@@ -922,6 +1035,12 @@ class Digital_Wallet {
922
  * @return array
923
  */
924
  public function get_available_pages() {
 
 
 
 
 
 
925
  return apply_filters(
926
  'wc_square_display_digital_wallet_on_pages',
927
  array(
@@ -997,6 +1116,12 @@ class Digital_Wallet {
997
  * @return array
998
  */
999
  public function supported_product_types() {
 
 
 
 
 
 
1000
  return apply_filters(
1001
  'wc_square_digital_wallets_supported_product_types',
1002
  array(
@@ -1057,6 +1182,14 @@ class Digital_Wallet {
1057
  */
1058
  public function allowed_for_cart() {
1059
  foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
 
 
 
 
 
 
 
 
1060
  $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
1061
 
1062
  if ( ! in_array( $_product->get_type(), $this->supported_product_types(), true ) ) {
21
 
22
  defined( 'ABSPATH' ) || exit;
23
 
24
+ use WC_Form_Handler;
25
  use WooCommerce\Square\Plugin;
26
 
27
  class Digital_Wallet {
72
  // Calculate the value of option `wc_square_apple_pay_enabled` which is not stored in the DB for WC Admin inbox notifications
73
  add_filter( 'pre_option_wc_square_apple_pay_enabled', array( $this, 'get_option_is_apple_pay_enabled' ), 10, 1 );
74
  add_filter( 'woocommerce_checkout_posted_data', array( $this, 'filter_posted_data' ) );
75
+ add_filter( 'woocommerce_checkout_fields', array( $this, 'filter_checkout_fields' ) );
76
  }
77
 
78
  /**
111
  add_action( 'woocommerce_before_checkout_form', array( $this, 'render_button' ), 15 );
112
  }
113
 
114
+ if ( ( $is_user_logged_in || ! $is_registration_required || $is_registration_enabled ) && in_array( 'checkout', $available_pages, true ) && is_wc_endpoint_url( 'order-pay' ) ) {
115
+ add_action( 'before_woocommerce_pay', array( $this, 'render_button' ) );
116
+ }
117
+
118
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
119
  }
120
 
188
  $button_text = '';
189
  }
190
 
191
+ $apple_pay_classes[] = 'wc-square-wallet-button-' . $apple_button_style;
192
 
193
  ?>
194
  <div id="wc-square-digital-wallet" style="display:none;">
220
  wp_enqueue_script( 'wc-square-digital-wallet', $this->gateway->get_plugin()->get_plugin_url() . '/assets/js/frontend/wc-square-digital-wallet.min.js', array( 'jquery' ), Plugin::VERSION, true );
221
 
222
  try {
223
+ /**
224
+ * Hook to filter localized data for digital wallets.
225
+ *
226
+ * @param array Array of data for digital wallets.
227
+ * @since 2.3
228
+ */
229
  $args = apply_filters(
230
  'wc_square_digital_wallet_js_args',
231
  array(
243
  'process_checkout_nonce' => wp_create_nonce( 'woocommerce-process_checkout' ),
244
  'logging_enabled' => $this->gateway->debug_log(),
245
  'hide_button_options' => $this->get_hidden_button_options(),
 
246
  'google_pay_color' => $this->gateway->get_option( 'digital_wallets_google_pay_button_color', 'black' ),
247
  'apple_pay_color' => $this->gateway->get_option( 'digital_wallets_apple_pay_button_color', 'black' ),
248
+ 'is_pay_for_order_page' => is_wc_endpoint_url( 'order-pay' ),
249
+ 'order_id' => absint( get_query_var( 'order-pay' ) ),
250
  )
251
  );
252
 
268
  * @return array
269
  */
270
  public function get_payment_request_for_context( $context ) {
271
+ $payment_request = array();
272
+ $is_pay_for_order_page = isset( $_POST['is_pay_for_order_page'] ) ? 'true' === sanitize_text_field( $_POST['is_pay_for_order_page'] ) : is_wc_endpoint_url( 'order-pay' );
273
+ $order_id = isset( $_POST['order_id'] ) ? (integer) sanitize_text_field( $_POST['order_id'] ) : absint( get_query_var( 'order-pay' ) );
274
 
275
  switch ( $context ) {
276
  case 'product':
279
 
280
  case 'cart':
281
  case 'checkout':
282
+ if ( is_wc_endpoint_url( 'order-pay' ) || $is_pay_for_order_page ) {
283
+ $order = wc_get_order( $order_id );
284
+ $payment_request = $this->build_payment_request( $order->get_total(), array(
285
+ 'order_id' => $order_id,
286
+ 'is_pay_for_order_page' => $is_pay_for_order_page,
287
+ ) );
288
+ } elseif ( isset( WC()->cart ) && $this->allowed_for_cart() ) {
289
  WC()->cart->calculate_totals();
290
  $payment_request = $this->build_payment_request( WC()->cart->total );
291
  }
381
  * @return array
382
  */
383
  public function build_payment_request( $amount, $data = array() ) {
384
+ $is_pay_for_order_page = isset( $data['is_pay_for_order_page'] ) ? $data[ 'is_pay_for_order_page' ] : false;
385
+ $order_id = isset( $data['order_id'] ) ? $data[ 'order_id' ] : 0;
386
+
387
+ if ( $is_pay_for_order_page ) {
388
+ $request_shipping_contact = false;
389
+ } else {
390
+ $request_shipping_contact = isset( WC()->cart ) && WC()->cart->needs_shipping();
391
+ }
392
+
393
+ $order_data = array();
394
+ $data = wp_parse_args(
395
  $data,
396
  array(
397
+ 'requestShippingContact' => $request_shipping_contact,
398
  'requestEmailAddress' => true,
399
  'requestBillingContact' => true,
400
  'countryCode' => substr( get_option( 'woocommerce_default_country' ), 0, 2 ),
402
  )
403
  );
404
 
405
+ if ( $is_pay_for_order_page ) {
406
+ $order = wc_get_order( $order_id );
407
+ $order_data = array(
408
+ 'subtotal' => $order->get_subtotal(),
409
+ 'discount' => $order->get_discount_total(),
410
+ 'shipping' => $order->get_shipping_total(),
411
+ 'fees' => $order->get_total_fees(),
412
+ 'taxes' => $order->get_total_tax(),
413
+ );
414
+
415
+ unset( $data['is_pay_for_order_page'], $data['order_id'] );
416
+ }
417
+
418
  if ( count( WC()->shipping->get_packages() ) > 1 ) {
419
  throw new \Exception( __( 'This payment method cannot be used for multiple shipments.', 'woocommerce-square' ) );
420
  }
421
 
422
  if ( ! isset( $data['lineItems'] ) ) {
423
+ $data['lineItems'] = $this->build_payment_request_line_items( $order_data );
424
  }
425
 
426
  if ( true === $data['requestShippingContact'] ) {
447
  * Builds an array of line items/totals to be sent back to Square in the lineItems array.
448
  *
449
  * @since 2.3
450
+ * @param array $totals
451
  * @return array
452
  */
453
+ public function build_payment_request_line_items( $totals = array() ) {
454
+ $totals = empty( $totals ) ? $this->get_cart_totals() : $totals;
455
+ $line_items = array();
456
+ $order_id = isset( $_POST['order_id'] ) ? (integer) sanitize_text_field( $_POST['order_id'] ) : absint( get_query_var( 'order-pay' ) );
457
+
458
+ if ( $order_id ) {
459
+ $order = wc_get_order( $order_id );
460
+ $iterable = $order->get_items();
461
+ } else {
462
+ $iterable = WC()->cart->get_cart();
463
+ }
464
 
465
+ foreach ( $iterable as $item ) {
466
+ $amount = number_format( $order_id ? $order->get_subtotal() : $item['line_subtotal'], 2, '.', '' );
467
+
468
+ if ( $order_id ) {
469
+ $quantity_label = 1 < $item->get_quantity() ? ' x ' . $item->get_quantity() : '';
470
+ } else {
471
+ $quantity_label = 1 < $item['quantity'] ? ' x ' . $item['quantity'] : '';
472
+ }
473
 
474
  $item = array(
475
+ 'label' => $order_id ? $item->get_name() . $quantity_label : $item['data']->get_name() . $quantity_label,
476
  'amount' => $amount,
477
  'pending' => false,
478
  );
480
  $line_items[] = $item;
481
  }
482
 
483
+ if ( $totals['shipping'] > 0 ) {
484
  $line_items[] = array(
485
  'label' => __( 'Shipping', 'woocommerce-square' ),
486
+ 'amount' => number_format( $totals['shipping'], 2, '.', '' ),
487
  'pending' => false,
488
  );
489
  }
490
 
491
+ if ( $totals['taxes'] > 0 ) {
492
  $line_items[] = array(
493
  'label' => __( 'Tax', 'woocommerce-square' ),
494
+ 'amount' => number_format( $totals['taxes'], 2, '.', '' ),
495
  'pending' => false,
496
  );
497
  }
498
 
499
+ if ( $totals['discount'] > 0 ) {
500
  $line_items[] = array(
501
  'label' => __( 'Discount', 'woocommerce-square' ),
502
+ 'amount' => number_format( $totals['discount'], 2, '.', '' ),
503
  'pending' => false,
504
  );
505
  }
506
 
507
+ if ( $totals['fees'] > 0 ) {
508
  $line_items[] = array(
509
  'label' => __( 'Fees', 'woocommerce-square' ),
510
+ 'amount' => number_format( $totals['fees'], 2, '.', '' ),
511
  'pending' => false,
512
  );
513
  }
642
  }
643
  }
644
 
645
+ /**
646
+ * Hook to filter shipping packages.
647
+ *
648
+ * @param array Array of shipping packages.
649
+ * @since 2.3
650
+ */
651
  $packages = apply_filters( 'woocommerce_cart_shipping_packages', $packages );
652
 
653
  WC()->shipping->calculate_shipping( $packages );
659
  * @param string $country_code The country's 2 letter ISO 3166-1 alpha-2 code.
660
  * @param string $state_name The full name of the state that is to be search for its code.
661
  *
662
+ * @return string
663
  */
664
  public static function get_state_code_by_name( $country_code = '', $state_name = '' ) {
665
  if ( empty( $country_code ) || empty( $state_name ) ) {
666
+ return '';
667
  }
668
 
669
  $states = WC()->countries->get_states( $country_code );
681
  }
682
  }
683
 
684
+ return '';
685
  }
686
 
687
  /**
698
  $shipping_address = array();
699
  $payment_request = array();
700
 
701
+ $is_pay_for_order_page = isset( $_POST['is_pay_for_order_page'] ) ? 'true' === sanitize_text_field( $_POST['is_pay_for_order_page'] ) : is_wc_endpoint_url( 'order-pay' );
702
+ $order_id = isset( $_POST['order_id'] ) ? (integer) sanitize_text_field( $_POST['order_id'] ) : absint( get_query_var( 'order-pay' ) );
703
+ $order_data = array();
704
+
705
+ if ( WC()->cart->needs_shipping() || $is_pay_for_order_page ) {
706
  if ( ! empty( $_POST['shipping_contact'] ) ) {
707
  $shipping_address = wp_parse_args(
708
  wc_clean( wp_unslash( $_POST['shipping_contact'] ) ),
768
  }
769
  }
770
 
771
+ if ( ! $is_pay_for_order_page ) {
772
+ WC()->cart->calculate_totals();
773
+ }
774
+
775
+ if ( $is_pay_for_order_page ) {
776
+ $order = wc_get_order( $order_id );
777
+ $order_data = array(
778
+ 'subtotal' => $order->get_subtotal(),
779
+ 'discount' => $order->get_discount_total(),
780
+ 'shipping' => $order->get_shipping_total(),
781
+ 'fees' => $order->get_total_fees(),
782
+ 'taxes' => $order->get_total_tax(),
783
+ );
784
+ }
785
+
786
+ $payment_request['lineItems'] = $this->build_payment_request_line_items( $order_data );
787
+
788
+ if ( $is_pay_for_order_page ) {
789
+ $total_amount = $order->get_total();
790
+ } else {
791
+ $total_amount = WC()->cart->total;
792
+ }
793
 
 
794
  $payment_request['total'] = array(
795
  'label' => get_bloginfo( 'name', 'display' ) . esc_html( $this->total_label_suffix ),
796
+ 'amount' => number_format( $total_amount, 2, '.', '' ),
797
  'pending' => false,
798
  );
799
 
827
  return $posted_data;
828
  }
829
 
830
+ /**
831
+ * Filters checkout fields when Digital Wallet is used.
832
+ *
833
+ * @param array $fields Array of checkout fields.
834
+ *
835
+ * @return array
836
+ */
837
+ public function filter_checkout_fields( $fields ) {
838
+ /** Ignoring nonce verification as that is already taken care of in WC_Checkout::process_checkout. */
839
+ $wallet_type = isset( $_POST['wc-square-digital-wallet-type'] ) ? wc_clean( wp_unslash( $_POST['wc-square-digital-wallet-type'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Missing
840
+
841
+ if ( ! $wallet_type ) {
842
+ return $fields;
843
+ }
844
+
845
+ if ( isset( $fields['billing'] ) && isset( $fields['billing']['billing_company'] ) ) {
846
+ $fields['billing']['billing_company']['required'] = false;
847
+ }
848
+
849
+ if ( isset( $fields['shipping'] ) && isset( $fields['shipping']['shipping_company'] ) ) {
850
+ $fields['shipping']['shipping_company']['required'] = false;
851
+ }
852
+
853
+ return $fields;
854
+ }
855
+
856
  /**
857
  * Process the digital wallet checkout
858
  *
1035
  * @return array
1036
  */
1037
  public function get_available_pages() {
1038
+ /**
1039
+ * Hook to filter pages which should load digital wallets.
1040
+ *
1041
+ * @param array Array of page names.
1042
+ * @since 2.3
1043
+ */
1044
  return apply_filters(
1045
  'wc_square_display_digital_wallet_on_pages',
1046
  array(
1116
  * @return array
1117
  */
1118
  public function supported_product_types() {
1119
+ /**
1120
+ * Hook to filter array of post types that can support digital wallets.
1121
+ *
1122
+ * @param array Array of supported post types.
1123
+ * @since 2.3
1124
+ */
1125
  return apply_filters(
1126
  'wc_square_digital_wallets_supported_product_types',
1127
  array(
1182
  */
1183
  public function allowed_for_cart() {
1184
  foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
1185
+ /**
1186
+ * Hook to filter cart item product.
1187
+ *
1188
+ * @param array $cart_item['data] Product object.
1189
+ * @param array $cart_item Cart item.
1190
+ * @param string $cart_item_key Cart item key.
1191
+ * @since 2.3
1192
+ */
1193
  $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
1194
 
1195
  if ( ! in_array( $_product->get_type(), $this->supported_product_types(), true ) ) {
includes/Gateway/Payment_Form.php CHANGED
@@ -91,23 +91,20 @@ class Payment_Form extends Payment_Gateway_Payment_Form {
91
  $billing_data = array( 'billing_postcode' => $billing_data_source->get_billing_postcode() );
92
 
93
  // 3d secure requires the full billing info
94
- if ( $this->get_gateway()->is_3d_secure_enabled() ) {
95
-
96
- $billing_data = array_merge(
97
- $billing_data,
98
- array(
99
- 'billing_first_name' => $billing_data_source->get_billing_first_name(),
100
- 'billing_last_name' => $billing_data_source->get_billing_last_name(),
101
- 'billing_email' => $billing_data_source->get_billing_email(),
102
- 'billing_country' => $billing_data_source->get_billing_country(),
103
- 'billing_address_1' => $billing_data_source->get_billing_address_1(),
104
- 'billing_address_2' => $billing_data_source->get_billing_address_2(),
105
- 'billing_state' => $billing_data_source->get_billing_state(),
106
- 'billing_city' => $billing_data_source->get_billing_city(),
107
- 'billing_phone' => $billing_data_source->get_billing_phone(),
108
- )
109
- );
110
- }
111
  }
112
 
113
  foreach ( $billing_data as $key => $value ) {
@@ -147,9 +144,7 @@ class Payment_Form extends Payment_Gateway_Payment_Form {
147
  'payment-postcode',
148
  );
149
 
150
- if ( $this->get_gateway()->is_3d_secure_enabled() ) {
151
- $fields[] = 'buyer-verification-token';
152
- }
153
 
154
  foreach ( $fields as $field_id ) {
155
  echo '<input type="hidden" name="wc-' . esc_attr( $this->get_gateway()->get_id_dasherized() ) . '-' . esc_attr( $field_id ) . '" />';
@@ -238,7 +233,6 @@ class Payment_Form extends Payment_Gateway_Payment_Form {
238
  'general_error' => __( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
239
  'id' => $this->get_gateway()->get_id(),
240
  'id_dasherized' => $this->get_gateway()->get_id_dasherized(),
241
- 'is_3d_secure_enabled' => $this->get_gateway()->is_3d_secure_enabled(),
242
  'is_checkout_registration_enabled' => 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout', 'no' ),
243
  'is_user_logged_in' => is_user_logged_in(),
244
  'is_add_payment_method_page' => is_add_payment_method_page(),
91
  $billing_data = array( 'billing_postcode' => $billing_data_source->get_billing_postcode() );
92
 
93
  // 3d secure requires the full billing info
94
+ $billing_data = array_merge(
95
+ $billing_data,
96
+ array(
97
+ 'billing_first_name' => $billing_data_source->get_billing_first_name(),
98
+ 'billing_last_name' => $billing_data_source->get_billing_last_name(),
99
+ 'billing_email' => $billing_data_source->get_billing_email(),
100
+ 'billing_country' => $billing_data_source->get_billing_country(),
101
+ 'billing_address_1' => $billing_data_source->get_billing_address_1(),
102
+ 'billing_address_2' => $billing_data_source->get_billing_address_2(),
103
+ 'billing_state' => $billing_data_source->get_billing_state(),
104
+ 'billing_city' => $billing_data_source->get_billing_city(),
105
+ 'billing_phone' => $billing_data_source->get_billing_phone(),
106
+ )
107
+ );
 
 
 
108
  }
109
 
110
  foreach ( $billing_data as $key => $value ) {
144
  'payment-postcode',
145
  );
146
 
147
+ $fields[] = 'buyer-verification-token';
 
 
148
 
149
  foreach ( $fields as $field_id ) {
150
  echo '<input type="hidden" name="wc-' . esc_attr( $this->get_gateway()->get_id_dasherized() ) . '-' . esc_attr( $field_id ) . '" />';
233
  'general_error' => __( 'An error occurred, please try again or try an alternate form of payment.', 'woocommerce-square' ),
234
  'id' => $this->get_gateway()->get_id(),
235
  'id_dasherized' => $this->get_gateway()->get_id_dasherized(),
 
236
  'is_checkout_registration_enabled' => 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout', 'no' ),
237
  'is_user_logged_in' => is_user_logged_in(),
238
  'is_add_payment_method_page' => is_add_payment_method_page(),
includes/Handlers/Connection.php CHANGED
@@ -73,15 +73,15 @@ class Connection {
73
  */
74
  protected function add_hooks() {
75
 
76
- add_action( 'admin_action_wc_' . $this->get_plugin()->get_id() . '_connected', array( $this, 'handle_connected' ) );
77
 
78
- add_action( 'admin_action_wc_' . $this->get_plugin()->get_id() . '_disconnect', array( $this, 'handle_disconnect' ) );
79
 
80
  // refresh the connection, triggered by Action Scheduler
81
- add_action( 'wc_' . $this->get_plugin()->get_id() . '_refresh_connection', array( $this, 'refresh_connection' ) );
82
 
83
  // index customers, triggered by Action Scheduler
84
- add_action( 'wc_' . $this->get_plugin()->get_id() . '_index_customers', array( $this, 'index_customers' ) );
85
  }
86
 
87
 
@@ -97,7 +97,7 @@ class Connection {
97
  $nonce = isset( $_GET['_wpnonce'] ) ? wc_clean( $_GET['_wpnonce'] ) : '';
98
 
99
  // check the user role & nonce
100
- if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( $nonce, 'wc_' . $this->get_plugin()->get_id() . '_connected' ) ) {
101
  wp_die( __( 'Sorry, you do not have permission to manage the Square connection.', 'woocommerce-square' ) );
102
  }
103
 
@@ -160,12 +160,12 @@ class Connection {
160
  public function handle_disconnect() {
161
 
162
  // remove the refresh fail flag if previously set
163
- delete_option( 'wc_' . $this->get_plugin()->get_id() . '_refresh_failed' );
164
 
165
  $nonce = isset( $_GET['_wpnonce'] ) ? wc_clean( $_GET['_wpnonce'] ) : '';
166
 
167
  // check the user role & nonce
168
- if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( $nonce, 'wc_' . $this->get_plugin()->get_id() . '_disconnect' ) ) {
169
  wp_die( __( 'Sorry, you do not have permission to manage the Square connection.', 'woocommerce-square' ) );
170
  }
171
 
@@ -224,12 +224,12 @@ class Connection {
224
  *
225
  * @param int $interval refresh interval
226
  */
227
- $interval = apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_connection_refresh_interval', WEEK_IN_SECONDS );
228
 
229
  // Make sure that all refresh actions are cancelled before scheduling it.
230
  $this->unschedule_refresh();
231
 
232
- as_schedule_single_action( time() + $interval, 'wc_' . $this->get_plugin()->get_id() . '_refresh_connection', array(), $this->get_plugin()->get_id() );
233
  }
234
 
235
 
@@ -253,7 +253,7 @@ class Connection {
253
 
254
  if ( ! $refresh_token ) {
255
  $this->get_plugin()->log( 'No refresh token stored, cannot refresh connection.' );
256
- update_option( 'wc_' . $this->get_plugin()->get_id() . '_refresh_failed', 'yes' );
257
  wc_square()->get_email_handler()->get_access_token_email()->trigger();
258
  return;
259
  }
@@ -295,12 +295,12 @@ class Connection {
295
  }
296
 
297
  // in case this option was set
298
- delete_option( 'wc_' . $this->get_plugin()->get_id() . '_refresh_failed' );
299
  } catch ( \Exception $exception ) {
300
 
301
  $this->get_plugin()->log( 'Unable to refresh connection: ' . $exception->getMessage() );
302
 
303
- update_option( 'wc_' . $this->get_plugin()->get_id() . '_refresh_failed', 'yes' );
304
 
305
  wc_square()->get_email_handler()->get_access_token_email()->trigger();
306
  }
@@ -315,7 +315,7 @@ class Connection {
315
  * @since 2.0.0
316
  */
317
  protected function unschedule_refresh() {
318
- as_unschedule_all_actions( 'wc_' . $this->get_plugin()->get_id() . '_refresh_connection', array(), $this->get_plugin()->get_id() );
319
  }
320
 
321
 
@@ -359,8 +359,8 @@ class Connection {
359
  */
360
  protected function schedule_customer_index( $cursor = '' ) {
361
 
362
- if ( false === as_next_scheduled_action( 'wc_' . $this->get_plugin()->get_id() . '_index_customers', array( $cursor ), $this->get_plugin()->get_id() ) ) {
363
- as_schedule_single_action( time(), 'wc_' . $this->get_plugin()->get_id() . '_index_customers', array( $cursor ), $this->get_plugin()->get_id() );
364
  }
365
  }
366
 
@@ -432,9 +432,9 @@ class Connection {
432
  *
433
  * @param string $raw_url API URL
434
  */
435
- $url = (string) apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_api_url', $raw_url );
436
 
437
- $action = 'wc_' . $this->get_plugin()->get_id() . '_connected';
438
  $redirect_url = wp_nonce_url( add_query_arg( 'action', $action, admin_url() ), $action );
439
 
440
  $args = array(
@@ -455,7 +455,7 @@ class Connection {
455
  */
456
  protected function get_disconnect_url() {
457
 
458
- $action = 'wc_' . $this->get_plugin()->get_id() . '_disconnect';
459
  $url = add_query_arg( 'action', $action, admin_url() );
460
 
461
  return wp_nonce_url( $url, $action );
@@ -498,7 +498,7 @@ class Connection {
498
  'INVENTORY_WRITE',
499
  );
500
 
501
- return (array) apply_filters( 'wc_' . $this->get_plugin()->get_id() . '_connection_scopes', $scopes );
502
  }
503
 
504
 
73
  */
74
  protected function add_hooks() {
75
 
76
+ add_action( 'admin_action_wc_square_connected', array( $this, 'handle_connected' ) );
77
 
78
+ add_action( 'admin_action_wc_square_disconnect', array( $this, 'handle_disconnect' ) );
79
 
80
  // refresh the connection, triggered by Action Scheduler
81
+ add_action( 'wc_square_refresh_connection', array( $this, 'refresh_connection' ) );
82
 
83
  // index customers, triggered by Action Scheduler
84
+ add_action( 'wc_square_index_customers', array( $this, 'index_customers' ) );
85
  }
86
 
87
 
97
  $nonce = isset( $_GET['_wpnonce'] ) ? wc_clean( $_GET['_wpnonce'] ) : '';
98
 
99
  // check the user role & nonce
100
+ if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( $nonce, 'wc_square_connected' ) ) {
101
  wp_die( __( 'Sorry, you do not have permission to manage the Square connection.', 'woocommerce-square' ) );
102
  }
103
 
160
  public function handle_disconnect() {
161
 
162
  // remove the refresh fail flag if previously set
163
+ delete_option( 'wc_square_refresh_failed' );
164
 
165
  $nonce = isset( $_GET['_wpnonce'] ) ? wc_clean( $_GET['_wpnonce'] ) : '';
166
 
167
  // check the user role & nonce
168
+ if ( ! current_user_can( 'manage_woocommerce' ) || ! wp_verify_nonce( $nonce, 'wc_square_disconnect' ) ) {
169
  wp_die( __( 'Sorry, you do not have permission to manage the Square connection.', 'woocommerce-square' ) );
170
  }
171
 
224
  *
225
  * @param int $interval refresh interval
226
  */
227
+ $interval = apply_filters( 'wc_square_connection_refresh_interval', WEEK_IN_SECONDS );
228
 
229
  // Make sure that all refresh actions are cancelled before scheduling it.
230
  $this->unschedule_refresh();
231
 
232
+ as_schedule_single_action( time() + $interval, 'wc_square_refresh_connection', array(), 'square' );
233
  }
234
 
235
 
253
 
254
  if ( ! $refresh_token ) {
255
  $this->get_plugin()->log( 'No refresh token stored, cannot refresh connection.' );
256
+ update_option( 'wc_square_refresh_failed', 'yes' );
257
  wc_square()->get_email_handler()->get_access_token_email()->trigger();
258
  return;
259
  }
295
  }
296
 
297
  // in case this option was set
298
+ delete_option( 'wc_square_refresh_failed' );
299
  } catch ( \Exception $exception ) {
300
 
301
  $this->get_plugin()->log( 'Unable to refresh connection: ' . $exception->getMessage() );
302
 
303
+ update_option( 'wc_square_refresh_failed', 'yes' );
304
 
305
  wc_square()->get_email_handler()->get_access_token_email()->trigger();
306
  }
315
  * @since 2.0.0
316
  */
317
  protected function unschedule_refresh() {
318
+ as_unschedule_all_actions( 'wc_square_refresh_connection', array(), 'square' );
319
  }
320
 
321
 
359
  */
360
  protected function schedule_customer_index( $cursor = '' ) {
361
 
362
+ if ( false === as_next_scheduled_action( 'wc_square_index_customers', array( $cursor ), 'square' ) ) {
363
+ as_schedule_single_action( time(), 'wc_square_index_customers', array( $cursor ), 'square' );
364
  }
365
  }
366
 
432
  *
433
  * @param string $raw_url API URL
434
  */
435
+ $url = (string) apply_filters( 'wc_square_api_url', $raw_url );
436
 
437
+ $action = 'wc_square_connected';
438
  $redirect_url = wp_nonce_url( add_query_arg( 'action', $action, admin_url() ), $action );
439
 
440
  $args = array(
455
  */
456
  protected function get_disconnect_url() {
457
 
458
+ $action = 'wc_square_disconnect';
459
  $url = add_query_arg( 'action', $action, admin_url() );
460
 
461
  return wp_nonce_url( $url, $action );
498
  'INVENTORY_WRITE',
499
  );
500
 
501
+ return (array) apply_filters( 'wc_square_connection_scopes', $scopes );
502
  }
503
 
504
 
includes/Handlers/Product.php CHANGED
@@ -118,7 +118,20 @@ class Product {
118
 
119
  $variation->update_meta_data( self::SQUARE_VARIATION_ID_META_KEY, $catalog_variation->getId() );
120
 
121
- $variation->set_name( $catalog_variation->getItemVariationData()->getName() );
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  if ( $catalog_variation->getItemVariationData()->getPriceMoney() ) {
124
  $variation->set_regular_price( Money_Utility::cents_to_float( $catalog_variation->getItemVariationData()->getPriceMoney()->getAmount() ) );
@@ -162,8 +175,34 @@ class Product {
162
  }
163
  }
164
 
165
- $product->set_name( wc_clean( $catalog_item->getName() ) );
166
- $product->set_description( $catalog_item->getDescription() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
  $category_id = Category::get_category_id_by_square_id( $catalog_item->getCategoryId() );
169
 
@@ -494,10 +533,9 @@ class Product {
494
  public static function has_sku( \WC_Product $product ) {
495
  if ( $product->is_type( 'variable' ) && $product->has_child() ) {
496
  foreach ( $product->get_children() as $variation_id ) {
497
- $variation = wc_get_product( $variation_id );
498
- $variation_sku = $variation->get_sku( 'edit' );
499
 
500
- if ( $variation instanceof \WC_Product && empty( $variation_sku ) ) {
501
  return false;
502
  }
503
  }
118
 
119
  $variation->update_meta_data( self::SQUARE_VARIATION_ID_META_KEY, $catalog_variation->getId() );
120
 
121
+ /**
122
+ * Allow overriding variation name during product import from Square
123
+ *
124
+ * @param string $variation_name Variation name to update.
125
+ * @param \SquareConnect\Model\CatalogObject $catalog_variation Catalog item variation being imported.
126
+ * @param \SquareConnect\Model\CatalogItem $catalog_item Catalog item being imported.
127
+ * @param \WC_Product_Variation $variation Variation being updated.
128
+ * @return false|string String to override the variation name, false to disable updating
129
+ * and keep existing name.
130
+ */
131
+ $variation_name = apply_filters( 'wc_square_update_product_set_variation_name', $catalog_variation->getItemVariationData()->getName(), $catalog_variation, $catalog_item, $variation );
132
+ if ( false !== $variation_name ) {
133
+ $variation->set_name( $variation_name );
134
+ }
135
 
136
  if ( $catalog_variation->getItemVariationData()->getPriceMoney() ) {
137
  $variation->set_regular_price( Money_Utility::cents_to_float( $catalog_variation->getItemVariationData()->getPriceMoney()->getAmount() ) );
175
  }
176
  }
177
 
178
+ /**
179
+ * Allow overriding product name during import from Square
180
+ *
181
+ * @param string $product_name Product name to update.
182
+ * @param \SquareConnect\Model\CatalogItem $catalog_item Catalog item being imported.
183
+ * @param \WC_Product $product Product being updated.
184
+ * @return false|string String to override the product name, false to disable updating
185
+ * and keep existing name.
186
+ */
187
+ $product_name = apply_filters( 'wc_square_update_product_set_name', $catalog_item->getName(), $catalog_item, $product );
188
+ if ( false !== $product_name ) {
189
+ $product->set_name( wc_clean( $product_name ) );
190
+ }
191
+
192
+ /**
193
+ * Allow overriding product description during import from Square
194
+ *
195
+ * @param string $product_description Product description to update.
196
+ * @param \SquareConnect\Model\CatalogItem $catalog_item Catalog item being imported.
197
+ * @param \WC_Product $product Product being updated.
198
+ *
199
+ * @return false|string String to override the product description, false to disable updating
200
+ * and keep existing description.
201
+ */
202
+ $product_description = apply_filters( 'wc_square_update_product_set_description', $catalog_item->getDescription(), $catalog_item, $product );
203
+ if ( false !== $product_description ) {
204
+ $product->set_description( $product_description );
205
+ }
206
 
207
  $category_id = Category::get_category_id_by_square_id( $catalog_item->getCategoryId() );
208
 
533
  public static function has_sku( \WC_Product $product ) {
534
  if ( $product->is_type( 'variable' ) && $product->has_child() ) {
535
  foreach ( $product->get_children() as $variation_id ) {
536
+ $variation = wc_get_product( $variation_id );
 
537
 
538
+ if ( $variation instanceof \WC_Product && empty( $variation->get_sku( 'edit' ) ) ) {
539
  return false;
540
  }
541
  }
includes/Handlers/Product/Woo_SOR.php CHANGED
@@ -211,7 +211,17 @@ class Woo_SOR extends \WooCommerce\Square\Handlers\Product {
211
 
212
  $variation_data->setPricingType( 'FIXED_PRICING' );
213
 
214
- $variation_data->setName( $product->get_name() );
 
 
 
 
 
 
 
 
 
 
215
 
216
  if ( wc_square()->get_settings_handler()->is_inventory_sync_enabled() ) {
217
  $variation_data->setTrackInventory( true );
211
 
212
  $variation_data->setPricingType( 'FIXED_PRICING' );
213
 
214
+ /**
215
+ * Simple products have only 1 variation and the name of the variation
216
+ * is derived from CatalogItem::name. For variable products, each variation
217
+ * can have its own name, so we put a condition to only set the name for
218
+ * variation.
219
+ *
220
+ * @see https://github.com/woocommerce/woocommerce-square/issues/570
221
+ */
222
+ if ( 'variation' === $product->get_type() ) {
223
+ $variation_data->setName( $product->get_name() );
224
+ }
225
 
226
  if ( wc_square()->get_settings_handler()->is_inventory_sync_enabled() ) {
227
  $variation_data->setTrackInventory( true );
includes/Handlers/Sync.php CHANGED
@@ -57,7 +57,7 @@ class Sync {
57
 
58
  $this->plugin = $plugin;
59
 
60
- $this->sync_scheduled_event_name = 'wc_' . $this->get_plugin()->get_id() . '_sync';
61
 
62
  $this->add_hooks();
63
  }
@@ -110,7 +110,7 @@ class Sync {
110
  return;
111
  }
112
 
113
- $plugin_id = $this->get_plugin()->get_id();
114
  $interval = $this->get_sync_schedule_interval();
115
 
116
  if ( false === as_next_scheduled_action( $this->sync_scheduled_event_name, array(), $plugin_id ) ) {
@@ -126,7 +126,7 @@ class Sync {
126
  */
127
  public function unschedule_sync() {
128
 
129
- as_unschedule_action( $this->sync_scheduled_event_name, array(), $this->get_plugin()->get_id() );
130
  }
131
 
132
  /**
57
 
58
  $this->plugin = $plugin;
59
 
60
+ $this->sync_scheduled_event_name = 'wc_square_sync';
61
 
62
  $this->add_hooks();
63
  }
110
  return;
111
  }
112
 
113
+ $plugin_id = 'square';
114
  $interval = $this->get_sync_schedule_interval();
115
 
116
  if ( false === as_next_scheduled_action( $this->sync_scheduled_event_name, array(), $plugin_id ) ) {
126
  */
127
  public function unschedule_sync() {
128
 
129
+ as_unschedule_action( $this->sync_scheduled_event_name, array(), 'square' );
130
  }
131
 
132
  /**
includes/Plugin.php CHANGED
@@ -43,7 +43,7 @@ class Plugin extends Payment_Gateway_Plugin {
43
 
44
 
45
  /** plugin version number */
46
- const VERSION = '3.2.0';
47
 
48
  /** plugin ID */
49
  const PLUGIN_ID = 'square';
@@ -157,8 +157,8 @@ class Plugin extends Payment_Gateway_Plugin {
157
  */
158
  public function add_api_request_logging() {
159
 
160
- if ( ! has_action( 'wc_' . $this->get_id() . '_api_request_performed' ) ) {
161
- add_action( 'wc_' . $this->get_id() . '_api_request_performed', array( $this, 'log_api_request' ), 10, 2 );
162
  }
163
  }
164
 
@@ -282,7 +282,7 @@ class Plugin extends Payment_Gateway_Plugin {
282
  $this->get_message_handler()->show_messages();
283
 
284
  // display a notice if the auto-refresh failed
285
- if ( get_option( 'wc_' . $this->get_id() . '_refresh_failed', false ) ) {
286
 
287
  $message = sprintf(
288
  __( 'Heads up! There may be a problem with your connection to Square. In order to continue accepting payments, please %1$sdisconnect and re-connect your site%2$s.', 'woocommerce-square' ),
43
 
44
 
45
  /** plugin version number */
46
+ const VERSION = WC_SQUARE_PLUGIN_VERSION;
47
 
48
  /** plugin ID */
49
  const PLUGIN_ID = 'square';
157
  */
158
  public function add_api_request_logging() {
159
 
160
+ if ( ! has_action( 'wc_square_api_request_performed' ) ) {
161
+ add_action( 'wc_square_api_request_performed', array( $this, 'log_api_request' ), 10, 2 );
162
  }
163
  }
164
 
282
  $this->get_message_handler()->show_messages();
283
 
284
  // display a notice if the auto-refresh failed
285
+ if ( get_option( 'wc_square_refresh_failed', false ) ) {
286
 
287
  $message = sprintf(
288
  __( 'Heads up! There may be a problem with your connection to Square. In order to continue accepting payments, please %1$sdisconnect and re-connect your site%2$s.', 'woocommerce-square' ),
includes/Sync/Manual_Synchronization.php CHANGED
@@ -506,7 +506,7 @@ class Manual_Synchronization extends Stepped_Job {
506
  $products_map = Product::get_square_meta( $product_ids, 'square_item_id' );
507
 
508
  if ( ! empty( $in_progress['unprocessed_search_response'] ) ) {
509
- $search_response = ApiHelper::deserialize( $in_progress['unprocessed_search_response'] );
510
  } else {
511
 
512
  $response = wc_square()->get_api()->search_catalog_objects(
@@ -783,7 +783,7 @@ class Manual_Synchronization extends Stepped_Job {
783
  $upsert_response = null;
784
 
785
  if ( null !== $in_progress['unprocessed_upsert_response'] ) {
786
- $upsert_response = ApiHelper::deserialize( $in_progress['unprocessed_upsert_response'] );
787
  }
788
 
789
  if ( ! $upsert_response instanceof BatchUpsertCatalogObjectsResponse ) {
@@ -950,12 +950,11 @@ class Manual_Synchronization extends Stepped_Job {
950
  * @return CatalogObject
951
  */
952
  protected function convert_to_catalog_object( $object_data ) {
 
 
953
 
954
- if ( ! is_string( $object_data ) ) {
955
- $object_data = wp_json_encode( $object_data );
956
- }
957
-
958
- $object = ApiHelper::deserialize( $object_data );
959
 
960
  return $object instanceof CatalogObject ? $object : null;
961
  }
@@ -1121,7 +1120,7 @@ class Manual_Synchronization extends Stepped_Job {
1121
 
1122
  } else {
1123
 
1124
- $response_data = ApiHelper::deserialize( $response_data );
1125
  }
1126
 
1127
  if ( ! $response_data instanceof SearchCatalogObjectsResponse ) {
@@ -1299,7 +1298,7 @@ class Manual_Synchronization extends Stepped_Job {
1299
 
1300
  // if a response was never cleared, we likely had a timeout
1301
  if ( null !== $in_progress['response_data'] ) {
1302
- $response_data = ApiHelper::deserialize( $in_progress['response_data'] );
1303
  }
1304
 
1305
  // if the saved response was somehow corrupted, start over
@@ -1368,17 +1367,18 @@ class Manual_Synchronization extends Stepped_Job {
1368
  continue;
1369
  }
1370
 
1371
- // Square can return multiple "types" of counts, WooCommerce only distinguishes whether a product is in stock or not
1372
- if ( 'IN_STOCK' === $count->getState() ) {
1373
-
1374
- $product = Product::get_product_by_square_variation_id( $count->getCatalogObjectId() );
1375
 
1376
- if ( $product instanceof \WC_Product ) {
 
 
1377
  $product->set_manage_stock( true );
1378
  $product->set_stock_quantity( $count->getQuantity() );
1379
- $product->save();
 
1380
  }
1381
 
 
1382
  $in_progress['processed_variation_ids'][] = $count->getCatalogObjectId();
1383
  }
1384
 
506
  $products_map = Product::get_square_meta( $product_ids, 'square_item_id' );
507
 
508
  if ( ! empty( $in_progress['unprocessed_search_response'] ) ) {
509
+ $search_response = ApiHelper::deserialize( $in_progress['unprocessed_search_response'], new SearchCatalogObjectsResponse() );
510
  } else {
511
 
512
  $response = wc_square()->get_api()->search_catalog_objects(
783
  $upsert_response = null;
784
 
785
  if ( null !== $in_progress['unprocessed_upsert_response'] ) {
786
+ $upsert_response = ApiHelper::deserialize( $in_progress['unprocessed_upsert_response'], new BatchUpsertCatalogObjectsResponse() );
787
  }
788
 
789
  if ( ! $upsert_response instanceof BatchUpsertCatalogObjectsResponse ) {
950
  * @return CatalogObject
951
  */
952
  protected function convert_to_catalog_object( $object_data ) {
953
+ $object_data_string = is_string( $object_data ) ? $object_data : wp_json_encode( $object_data );
954
+ $object_data_obj = is_string( $object_data ) ? json_decode( $object_data ) : $object_data;
955
 
956
+ $catalog_object = new CatalogObject( $object_data_obj->type, $object_data_obj->id );
957
+ $object = ApiHelper::deserialize( $object_data_string, $catalog_object );
 
 
 
958
 
959
  return $object instanceof CatalogObject ? $object : null;
960
  }
1120
 
1121
  } else {
1122
 
1123
+ $response_data = ApiHelper::deserialize( $response_data, new SearchCatalogObjectsResponse() );
1124
  }
1125
 
1126
  if ( ! $response_data instanceof SearchCatalogObjectsResponse ) {
1298
 
1299
  // if a response was never cleared, we likely had a timeout
1300
  if ( null !== $in_progress['response_data'] ) {
1301
+ $response_data = ApiHelper::deserialize( $in_progress['response_data'], new BatchRetrieveInventoryCountsResponse() );
1302
  }
1303
 
1304
  // if the saved response was somehow corrupted, start over
1367
  continue;
1368
  }
1369
 
1370
+ $product = Product::get_product_by_square_variation_id( $count->getCatalogObjectId() );
 
 
 
1371
 
1372
+ if ( $product instanceof \WC_Product ) {
1373
+ // Square can return multiple "types" of counts, WooCommerce only distinguishes whether a product is in stock or not
1374
+ if ( 'IN_STOCK' === $count->getState() ) {
1375
  $product->set_manage_stock( true );
1376
  $product->set_stock_quantity( $count->getQuantity() );
1377
+ } else {
1378
+ $product->set_stock_quantity( 0 );
1379
  }
1380
 
1381
+ $product->save();
1382
  $in_progress['processed_variation_ids'][] = $count->getCatalogObjectId();
1383
  }
1384
 
includes/Sync/Product_Import.php CHANGED
@@ -270,8 +270,11 @@ class Product_Import extends Stepped_Job {
270
 
271
  if ( $product && $product instanceof \WC_Product ) {
272
 
273
- $product->set_stock_quantity( $inventory_count->getQuantity() );
274
- $product->save();
 
 
 
275
  }
276
  }
277
  }
270
 
271
  if ( $product && $product instanceof \WC_Product ) {
272
 
273
+ if ( 'IN_STOCK' === $inventory_count->getState() ) {
274
+ $product->set_manage_stock( true );
275
+ $product->set_stock_quantity( $inventory_count->getQuantity() );
276
+ $product->save();
277
+ }
278
  }
279
  }
280
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: credit card, square, woocommerce, inventory sync
4
  Requires at least: 4.6
5
  Tested up to: 6.0
6
  Requires PHP: 7.2
7
- Stable tag: 3.2.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -71,6 +71,30 @@ 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
  = 3.2.0 - 2022-09-14 =
75
  * Add - Ensure the `via WooCommerce` text can be translated and introduce a new filter to update that text while paying with Apple Pay.
76
  * Add - Missing square_customers table.
4
  Requires at least: 4.6
5
  Tested up to: 6.0
6
  Requires PHP: 7.2
7
+ Stable tag: 3.3.0
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
+ = 3.3.0 - 2022-11-07 =
75
+ * Add - Adds digital wallet buttons in the Pay for Order page.
76
+ * Add - Declare support for High-performance Order Systems ("HPOS").
77
+ * Add - Digital Wallet support for Australia.
78
+ * Add - Filter 'wc_square_update_product_set_description' to override product description during update from Square.
79
+ * Add - Filter 'wc_square_update_product_set_name' to override product name during update from Square.
80
+ * Add - Filter 'wc_square_update_product_set_variation_name' to override variation name during update from Square.
81
+ * Add - Support to store transaction ID while using High-performance Order Storage ("HPOS") (formerly known as Custom Order Tables, "COT").
82
+ * Dev - Plugin version constant added to the main file.
83
+ * Fix - Broken detailed decline messages after migration to Payments API.
84
+ * Fix - Checkout without required state field being empty.
85
+ * Fix - Digital wallet errors on Checkout page.
86
+ * Fix - Error caused while fetching variation SKU.
87
+ * Fix - Failed payment due to 3D secure errors.
88
+ * Fix - Fixes variations shown for WooCommerce simple products in Square dashboard.
89
+ * Fix - Inability to sync products created in both Square and WooCommerce.
90
+ * Fix - Incorrectly set quantity during Product Import.
91
+ * Fix - Issue with checkout using digital wallet when company name is required.
92
+ * Fix - Issue with stock status during product import when the inventory count is 0.
93
+ * Fix - Manage stock value of variation products when the product is not synced with Square.
94
+ * Fix - Stock status visibility under inventory for variable products.
95
+ * Update - Replaces dynamic strings with string literals.
96
+ * Update - WC tested up to 7.1
97
+
98
  = 3.2.0 - 2022-09-14 =
99
  * Add - Ensure the `via WooCommerce` text can be translated and introduce a new filter to update that text while paying with Apple Pay.
100
  * Add - Missing square_customers table.
vendor/autoload.php CHANGED
@@ -3,10 +3,23 @@
3
  // autoload.php @generated by Composer
4
 
5
  if (PHP_VERSION_ID < 50600) {
6
- echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
7
- exit(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
 
10
  require_once __DIR__ . '/composer/autoload_real.php';
11
 
12
- return ComposerAutoloaderInit0f8c28c28637f6e40856be06392fc25b::getLoader();
3
  // autoload.php @generated by Composer
4
 
5
  if (PHP_VERSION_ID < 50600) {
6
+ if (!headers_sent()) {
7
+ header('HTTP/1.1 500 Internal Server Error');
8
+ }
9
+ $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10
+ if (!ini_get('display_errors')) {
11
+ if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12
+ fwrite(STDERR, $err);
13
+ } elseif (!headers_sent()) {
14
+ echo $err;
15
+ }
16
+ }
17
+ trigger_error(
18
+ $err,
19
+ E_USER_ERROR
20
+ );
21
  }
22
 
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
 
25
+ return ComposerAutoloaderInit7c14f19059e2f8ed732f587baee6be06::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit0f8c28c28637f6e40856be06392fc25b
6
  {
7
  private static $loader;
8
 
@@ -24,12 +24,12 @@ class ComposerAutoloaderInit0f8c28c28637f6e40856be06392fc25b
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
- spl_autoload_register(array('ComposerAutoloaderInit0f8c28c28637f6e40856be06392fc25b', 'loadClassLoader'), true, true);
28
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29
- spl_autoload_unregister(array('ComposerAutoloaderInit0f8c28c28637f6e40856be06392fc25b', 'loadClassLoader'));
30
 
31
  require __DIR__ . '/autoload_static.php';
32
- call_user_func(\Composer\Autoload\ComposerStaticInit0f8c28c28637f6e40856be06392fc25b::getInitializer($loader));
33
 
34
  $loader->register(true);
35
 
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit7c14f19059e2f8ed732f587baee6be06
6
  {
7
  private static $loader;
8
 
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
+ spl_autoload_register(array('ComposerAutoloaderInit7c14f19059e2f8ed732f587baee6be06', 'loadClassLoader'), true, true);
28
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29
+ spl_autoload_unregister(array('ComposerAutoloaderInit7c14f19059e2f8ed732f587baee6be06', 'loadClassLoader'));
30
 
31
  require __DIR__ . '/autoload_static.php';
32
+ call_user_func(\Composer\Autoload\ComposerStaticInit7c14f19059e2f8ed732f587baee6be06::getInitializer($loader));
33
 
34
  $loader->register(true);
35
 
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit0f8c28c28637f6e40856be06392fc25b
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'a' =>
@@ -45,10 +45,10 @@ class ComposerStaticInit0f8c28c28637f6e40856be06392fc25b
45
  public static function getInitializer(ClassLoader $loader)
46
  {
47
  return \Closure::bind(function () use ($loader) {
48
- $loader->prefixLengthsPsr4 = ComposerStaticInit0f8c28c28637f6e40856be06392fc25b::$prefixLengthsPsr4;
49
- $loader->prefixDirsPsr4 = ComposerStaticInit0f8c28c28637f6e40856be06392fc25b::$prefixDirsPsr4;
50
- $loader->prefixesPsr0 = ComposerStaticInit0f8c28c28637f6e40856be06392fc25b::$prefixesPsr0;
51
- $loader->classMap = ComposerStaticInit0f8c28c28637f6e40856be06392fc25b::$classMap;
52
 
53
  }, null, ClassLoader::class);
54
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit7c14f19059e2f8ed732f587baee6be06
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'a' =>
45
  public static function getInitializer(ClassLoader $loader)
46
  {
47
  return \Closure::bind(function () use ($loader) {
48
+ $loader->prefixLengthsPsr4 = ComposerStaticInit7c14f19059e2f8ed732f587baee6be06::$prefixLengthsPsr4;
49
+ $loader->prefixDirsPsr4 = ComposerStaticInit7c14f19059e2f8ed732f587baee6be06::$prefixDirsPsr4;
50
+ $loader->prefixesPsr0 = ComposerStaticInit7c14f19059e2f8ed732f587baee6be06::$prefixesPsr0;
51
+ $loader->classMap = ComposerStaticInit7c14f19059e2f8ed732f587baee6be06::$classMap;
52
 
53
  }, null, ClassLoader::class);
54
  }
vendor/composer/installed.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php return array(
2
  'root' => array(
3
  'name' => 'woocommerce/woocommerce-square',
4
- 'pretty_version' => 'dev-release/3.2.0',
5
- 'version' => 'dev-release/3.2.0',
6
- 'reference' => 'd315f1e6d95bba25999e90c55404d24ec009c620',
7
  'type' => 'library',
8
  'install_path' => __DIR__ . '/../../',
9
  'aliases' => array(),
@@ -47,9 +47,9 @@
47
  'dev_requirement' => false,
48
  ),
49
  'woocommerce/woocommerce-square' => array(
50
- 'pretty_version' => 'dev-release/3.2.0',
51
- 'version' => 'dev-release/3.2.0',
52
- 'reference' => 'd315f1e6d95bba25999e90c55404d24ec009c620',
53
  'type' => 'library',
54
  'install_path' => __DIR__ . '/../../',
55
  'aliases' => array(),
1
  <?php return array(
2
  'root' => array(
3
  'name' => 'woocommerce/woocommerce-square',
4
+ 'pretty_version' => 'dev-trunk',
5
+ 'version' => 'dev-trunk',
6
+ 'reference' => '0fa0bbaf537fc5f02c8665fd95c544458f9b6fe2',
7
  'type' => 'library',
8
  'install_path' => __DIR__ . '/../../',
9
  'aliases' => array(),
47
  'dev_requirement' => false,
48
  ),
49
  'woocommerce/woocommerce-square' => array(
50
+ 'pretty_version' => 'dev-trunk',
51
+ 'version' => 'dev-trunk',
52
+ 'reference' => '0fa0bbaf537fc5f02c8665fd95c544458f9b6fe2',
53
  'type' => 'library',
54
  'install_path' => __DIR__ . '/../../',
55
  'aliases' => array(),
woocommerce-square.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
- * Version: 3.2.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
@@ -19,7 +19,7 @@
19
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
20
  *
21
  * WC requires at least: 3.0
22
- * WC tested up to: 6.3
23
  * Tested up to: 6.0
24
  */
25
 
@@ -27,6 +27,10 @@ defined( 'ABSPATH' ) || exit;
27
 
28
  require_once plugin_dir_path( __FILE__ ) . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
29
 
 
 
 
 
30
  if ( ! defined( 'WC_SQUARE_PLUGIN_URL' ) ) {
31
  define( 'WC_SQUARE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
32
  }
@@ -82,6 +86,7 @@ class WooCommerce_Square_Loader {
82
  if ( $this->is_environment_compatible() ) {
83
  add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
84
  add_action( 'woocommerce_blocks_payment_method_type_registration', array( $this, 'register_payment_method_block_integrations' ), 5, 1 );
 
85
  }
86
  }
87
 
@@ -379,6 +384,15 @@ class WooCommerce_Square_Loader {
379
  return $is_php_valid && $is_opcache_config_valid;
380
  }
381
 
 
 
 
 
 
 
 
 
 
382
  /**
383
  * Returns true if opcache.save_comments is enabled.
384
  *
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
+ * Version: 3.3.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
19
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
20
  *
21
  * WC requires at least: 3.0
22
+ * WC tested up to: 7.1
23
  * Tested up to: 6.0
24
  */
25
 
27
 
28
  require_once plugin_dir_path( __FILE__ ) . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
29
 
30
+ if ( ! defined( 'WC_SQUARE_PLUGIN_VERSION' ) ) {
31
+ define( 'WC_SQUARE_PLUGIN_VERSION', '3.3.0' ); // WRCS: DEFINED_VERSION.
32
+ }
33
+
34
  if ( ! defined( 'WC_SQUARE_PLUGIN_URL' ) ) {
35
  define( 'WC_SQUARE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
36
  }
86
  if ( $this->is_environment_compatible() ) {
87
  add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
88
  add_action( 'woocommerce_blocks_payment_method_type_registration', array( $this, 'register_payment_method_block_integrations' ), 5, 1 );
89
+ add_action( 'before_woocommerce_init', array( $this, 'declare_hpos_compatibility' ) );
90
  }
91
  }
92
 
384
  return $is_php_valid && $is_opcache_config_valid;
385
  }
386
 
387
+ /**
388
+ * Declares support for HPOS.
389
+ */
390
+ public function declare_hpos_compatibility() {
391
+ if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
392
+ \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
393
+ }
394
+ }
395
+
396
  /**
397
  * Returns true if opcache.save_comments is enabled.
398
  *