diff --git a/CHANGELOG.md b/CHANGELOG.md index 270688e6d..cfbef47ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.6.2] - 2021-01-06 +### Changed + - Changed loading of Mercado Pago SDK at custom checkout. ## [4.6.1] - 2021-01-04 ### Added - Add support to LearnPress diff --git a/assets/js/credit-card.js b/assets/js/credit-card.js index af25ac524..00bf0c544 100644 --- a/assets/js/credit-card.js +++ b/assets/js/credit-card.js @@ -10,11 +10,11 @@ public_key: wc_mercadopago_params.public_key }; - var sdkTagScript = document.createElement('script'); - sdkTagScript.src = 'https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js?_=wc' + wc_mercadopago_params.plugin_version; - sdkTagScript.onload = function () { + // Set mercadopago public_key + $.getScript('https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js').done(function () { + // Set Public_key Mercadopago.setPublishableKey(seller.public_key); - }; + }); var coupon_of_discounts = { discount_action_url: wc_mercadopago_params.discount_action_url, @@ -66,7 +66,7 @@ function showPaymentsLink() { var frame_payments = document.querySelector('#mp-frame-payments'); $('#button-show-payments').on('click', function () { - frame_payments.style.display = frame_payments.style.display === 'inline-block' ? 'none' : 'inline-block'; + frame_payments.style.display = frame_payments.style.display === 'inline-block' ? 'none' : 'inline-block'; }); } @@ -170,40 +170,40 @@ * Check what information is necessary to pay and show inputs */ function additionalInfoHandler() { - if (additionalInfoNeeded.cardholder_name) { - document.getElementById('mp-card-holder-div').style.display = 'block'; - } else { - document.getElementById('mp-card-holder-div').style.display = 'none'; - } + if (additionalInfoNeeded.cardholder_name) { + document.getElementById('mp-card-holder-div').style.display = 'block'; + } else { + document.getElementById('mp-card-holder-div').style.display = 'none'; + } - if (additionalInfoNeeded.issuer) { - document.getElementById('mp-issuer-div').style.display = 'block'; - document.getElementById('installments-div').classList.remove('mp-col-md-12'); - document.getElementById('installments-div').classList.add('mp-col-md-8'); - Mercadopago.getIssuers(objPaymentMethod.id, getBin(), issuersHandler); - } else { - clearIssuer(); - setInstallments(); - } + if (additionalInfoNeeded.issuer) { + document.getElementById('mp-issuer-div').style.display = 'block'; + document.getElementById('installments-div').classList.remove('mp-col-md-12'); + document.getElementById('installments-div').classList.add('mp-col-md-8'); + Mercadopago.getIssuers(objPaymentMethod.id, getBin(), issuersHandler); + } else { + clearIssuer(); + setInstallments(); + } - if (additionalInfoNeeded.cardholder_identification_type) { - document.getElementById('mp-doc-div').style.display = 'inline-block'; - document.getElementById('mp-doc-type-div').style.display = 'block'; - Mercadopago.getIdentificationTypes(); - } else { - document.getElementById('mp-doc-type-div').style.display = 'none'; - } + if (additionalInfoNeeded.cardholder_identification_type) { + document.getElementById('mp-doc-div').style.display = 'inline-block'; + document.getElementById('mp-doc-type-div').style.display = 'block'; + Mercadopago.getIdentificationTypes(); + } else { + document.getElementById('mp-doc-type-div').style.display = 'none'; + } - if (additionalInfoNeeded.cardholder_identification_number) { - document.getElementById('mp-doc-div').style.display = 'inline-block'; - document.getElementById('mp-doc-number-div').style.display = 'block'; - } else { - document.getElementById('mp-doc-number-div').style.display = 'none'; - } + if (additionalInfoNeeded.cardholder_identification_number) { + document.getElementById('mp-doc-div').style.display = 'inline-block'; + document.getElementById('mp-doc-number-div').style.display = 'block'; + } else { + document.getElementById('mp-doc-number-div').style.display = 'none'; + } - if (!additionalInfoNeeded.cardholder_identification_type && !additionalInfoNeeded.cardholder_identification_number) { - document.getElementById('mp-doc-div').style.display = 'none'; - } + if (!additionalInfoNeeded.cardholder_identification_type && !additionalInfoNeeded.cardholder_identification_number) { + document.getElementById('mp-doc-div').style.display = 'none'; + } } /** @@ -742,23 +742,23 @@ */ function currencyIdToCurrency(currency_id) { if (currency_id === 'ARS') { - return '$'; + return '$'; } else if (currency_id === 'BRL') { - return 'R$'; + return 'R$'; } else if (currency_id === 'COP') { - return '$'; + return '$'; } else if (currency_id === 'CLP') { - return '$'; + return '$'; } else if (currency_id === 'MXN') { - return '$'; + return '$'; } else if (currency_id === 'VEF') { - return 'Bs'; + return 'Bs'; } else if (currency_id === 'PEN') { - return 'S/'; + return 'S/'; } else if (currency_id === 'UYU') { - return '$U'; + return '$U'; } else { - return '$'; + return '$'; } } @@ -802,9 +802,5 @@ $('form#order_review').submit(function () { return mercadoPagoFormHandler(); }); - - window.addEventListener('load', function() { - document.querySelector('body').append(sdkTagScript); - }); }); }(jQuery)); diff --git a/assets/js/credit-card.min.js b/assets/js/credit-card.min.js index 25239e78e..3a3d549f1 100644 --- a/assets/js/credit-card.min.js +++ b/assets/js/credit-card.min.js @@ -1 +1 @@ -!function(L){"use strict";L(function(){var t=!1,d={site_id:wc_mercadopago_params.site_id,public_key:wc_mercadopago_params.public_key},e=document.createElement("script");e.src="https://secure.mlstatic.com/sdk/javascript/v1/mercadopago.js?_=wc"+wc_mercadopago_params.plugin_version,e.onload=function(){Mercadopago.setPublishableKey(d.public_key)};var n={discount_action_url:wc_mercadopago_params.discount_action_url,payer_email:wc_mercadopago_params.payer_email,activated:wc_mercadopago_params.coupon_mode,status:!1},c={},r={};function o(){0!==document.getElementById("mp-card-number").value&&(document.getElementById("mp-card-number").value="",i(),y(),_(),g(),f())}function a(){var e=document.querySelector("#mp-frame-payments");L("#button-show-payments").on("click",function(){e.style.display="inline-block"===e.style.display?"none":"inline-block"})}function l(){return document.getElementById("mp-card-number").value.replace(/[ .-]/g,"").slice(0,6)}function u(){return(document.getElementById("mp-amount").value-document.getElementById("mp-discount").value)*document.getElementById("currency_ratio").value}function m(e,o){200===e?(c=o[0],o=c.id,document.getElementById("paymentMethodId").value=o,o=c.secure_thumbnail,document.getElementById("mp-card-number").style.background="url("+o+") 98% 50% no-repeat #fff",function(e){r={issuer:!1,cardholder_name:!1,cardholder_identification_type:!1,cardholder_identification_number:!1};for(var o=0;o'+wc_mercadopago_params.choose+"...",n=[],r=0;r"+(n[c].recommended_message||n[c].installments)+"";e.innerHTML=t,"MLA"===d.site_id&&(_(),L("body").on("change","#mp-installments",s))}else y(),_()}function s(){var e=document.querySelector("#mp-installments"),o=e.options[e.selectedIndex].getAttribute("data-tax"),t="",e="";null!=o&&(t=(o=o.split("|"))[0].replace("_"," "),e=o[1].replace("_"," "),"CFT 0,00%"===t&&"TEA 0,00%"===e&&(e=t="")),document.querySelector("#mp-tax-cft-text").innerHTML=t,document.querySelector("#mp-tax-tea-text").innerHTML=e}function y(){document.getElementById("mp-installments").innerHTML=""}function _(){document.querySelector("#mp-tax-cft-text").innerHTML="",document.querySelector("#mp-tax-tea-text").innerHTML=""}function g(){document.getElementById("mp-issuer-div").style.display="none",document.getElementById("installments-div").classList.remove("mp-col-md-8"),document.getElementById("installments-div").classList.add("mp-dis-md-12"),document.getElementById("mp-issuer").innerHTML=""}function f(){document.getElementById("mp-doc-div").style.display="none",document.getElementById("mp-doc-type-div").style.display="none",document.getElementById("docType").innerHTML="",document.getElementById("docNumber").value=""}function v(){for(var e={},o=u(),t=!1,n=0;n"+C(e.response.currency_id)+" "+Math.round(100*e.response.coupon_amount)/100+" "+wc_mercadopago_params.discount_info2+" "+e.response.name+".
"+wc_mercadopago_params.discount_info3+" "+C(e.response.currency_id)+" "+Math.round(100*document.querySelector("#mp-amount").value)/100+"
"+wc_mercadopago_params.discount_info4+" "+C(e.response.currency_id)+" "+Math.round(100*u())/100+"*
"+wc_mercadopago_params.discount_info5+'
'+wc_mercadopago_params.discount_info6+"",document.querySelector("#mpCouponError").style.display="none",document.querySelector("#couponCode").style.background=null,document.querySelector("#couponCode").style.background="url("+wc_mercadopago_params.check+") 94% 50% no-repeat #fff",document.querySelector("#couponCode").style.border="1px solid #cecece",document.querySelector("#applyCoupon").value=wc_mercadopago_params.remove,document.querySelector("#campaign_id").value=e.response.id,document.querySelector("#campaign").value=e.response.name):(n.status=!1,document.querySelector("#mpCouponApplyed").style.display="none",document.querySelector("#mpCouponError").style.display="block",document.querySelector("#mpCouponError").innerHTML=e.response.message,document.querySelector("#couponCode").style.background=null,document.querySelector("#couponCode").style.background="url("+wc_mercadopago_params.error+") 94% 50% no-repeat #fff",document.querySelector("#applyCoupon").value=wc_mercadopago_params.apply,document.querySelector("#mp-discount").value=0),document.querySelector("#applyCoupon").disabled=!1}})}())}function C(e){return"ARS"===e?"$":"BRL"===e?"R$":"COP"===e||"CLP"===e||"MXN"===e?"$":"VEF"===e?"Bs":"PEN"===e?"S/":"UYU"===e?"$U":"$"}function w(){return t?!(t=!1):!document.getElementById("payment_method_woo-mercado-pago-custom").checked||!!S()&&function(){E(),document.querySelector("#mp-box-loading").style.background="url("+wc_mercadopago_params.loading+") 0 50% no-repeat #fff";var e=h();return Mercadopago.createToken(e,k),!1}()}0'+wc_mercadopago_params.choose+"...",n=[],r=0;r"+(n[c].recommended_message||n[c].installments)+"";e.innerHTML=t,"MLA"===d.site_id&&(y(),w("body").on("change","#mp-installments",p))}else s(),y()}function p(){var e=document.querySelector("#mp-installments"),o=e.options[e.selectedIndex].getAttribute("data-tax"),t="",e="";null!=o&&(t=(o=o.split("|"))[0].replace("_"," "),e=o[1].replace("_"," "),"CFT 0,00%"===t&&"TEA 0,00%"===e&&(e=t="")),document.querySelector("#mp-tax-cft-text").innerHTML=t,document.querySelector("#mp-tax-tea-text").innerHTML=e}function s(){document.getElementById("mp-installments").innerHTML=""}function y(){document.querySelector("#mp-tax-cft-text").innerHTML="",document.querySelector("#mp-tax-tea-text").innerHTML=""}function g(){document.getElementById("mp-issuer-div").style.display="none",document.getElementById("installments-div").classList.remove("mp-col-md-8"),document.getElementById("installments-div").classList.add("mp-dis-md-12"),document.getElementById("mp-issuer").innerHTML=""}function _(){document.getElementById("mp-doc-div").style.display="none",document.getElementById("mp-doc-type-div").style.display="none",document.getElementById("docType").innerHTML="",document.getElementById("docNumber").value=""}function f(){for(var e={},o=l(),t=!1,n=0;n"+B(e.response.currency_id)+" "+Math.round(100*e.response.coupon_amount)/100+" "+wc_mercadopago_params.discount_info2+" "+e.response.name+".
"+wc_mercadopago_params.discount_info3+" "+B(e.response.currency_id)+" "+Math.round(100*document.querySelector("#mp-amount").value)/100+"
"+wc_mercadopago_params.discount_info4+" "+B(e.response.currency_id)+" "+Math.round(100*l())/100+"*
"+wc_mercadopago_params.discount_info5+'
'+wc_mercadopago_params.discount_info6+"",document.querySelector("#mpCouponError").style.display="none",document.querySelector("#couponCode").style.background=null,document.querySelector("#couponCode").style.background="url("+wc_mercadopago_params.check+") 94% 50% no-repeat #fff",document.querySelector("#couponCode").style.border="1px solid #cecece",document.querySelector("#applyCoupon").value=wc_mercadopago_params.remove,document.querySelector("#campaign_id").value=e.response.id,document.querySelector("#campaign").value=e.response.name):(n.status=!1,document.querySelector("#mpCouponApplyed").style.display="none",document.querySelector("#mpCouponError").style.display="block",document.querySelector("#mpCouponError").innerHTML=e.response.message,document.querySelector("#couponCode").style.background=null,document.querySelector("#couponCode").style.background="url("+wc_mercadopago_params.error+") 94% 50% no-repeat #fff",document.querySelector("#applyCoupon").value=wc_mercadopago_params.apply,document.querySelector("#mp-discount").value=0),document.querySelector("#applyCoupon").disabled=!1}})}())}function B(e){return"ARS"===e?"$":"BRL"===e?"R$":"COP"===e||"CLP"===e||"MXN"===e?"$":"VEF"===e?"Bs":"PEN"===e?"S/":"UYU"===e?"$U":"$"}function C(){return t?!(t=!1):!document.getElementById("payment_method_woo-mercado-pago-custom").checked||!!h()&&function(){q(),document.querySelector("#mp-box-loading").style.background="url("+wc_mercadopago_params.loading+") 0 50% no-repeat #fff";var e=b();return Mercadopago.createToken(e,I),!1}()}0Public Key production credential is invalid. Review the field to receive real payments." msgstr "" -#: includes/payments/hooks/WC_WooMercadoPago_Hook_Abstract.php:334 +#: includes/payments/hooks/WC_WooMercadoPago_Hook_Abstract.php:318 msgid "Public Key test credential is invalid. Review the field to perform tests in your store." msgstr "" -#: includes/payments/hooks/WC_WooMercadoPago_Hook_Abstract.php:344 +#: includes/payments/hooks/WC_WooMercadoPago_Hook_Abstract.php:328 msgid "Access Token production credential is invalid. Remember that it must be complete to receive real payments." msgstr "" -#: includes/payments/hooks/WC_WooMercadoPago_Hook_Abstract.php:354 +#: includes/payments/hooks/WC_WooMercadoPago_Hook_Abstract.php:338 msgid "Access Token test credential is invalid. Review the field to perform tests in your store." msgstr "" diff --git a/includes/module/config/WC_WooMercadoPago_Constants.php b/includes/module/config/WC_WooMercadoPago_Constants.php index fcaa2ad24..63df38c5f 100644 --- a/includes/module/config/WC_WooMercadoPago_Constants.php +++ b/includes/module/config/WC_WooMercadoPago_Constants.php @@ -12,7 +12,7 @@ class WC_WooMercadoPago_Constants const PRODUCT_ID_DESKTOP = 'BT7OF5FEOO6G01NJK3QG'; const PRODUCT_ID_MOBILE = 'BT7OFH09QS3001K5A0H0'; const PLATAFORM_ID = 'bo2hnr2ic4p001kbgpt0'; - const VERSION = '4.6.1'; + const VERSION = '4.6.2'; const MIN_PHP = 5.6; const API_MP_BASE_URL = 'https://api.mercadopago.com'; } diff --git a/readme.txt b/readme.txt index 62968e2ff..bf43ca9ab 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: ecommerce, mercadopago, woocommerce Requires at least: 4.9.10 Tested up to: 5.6 Requires PHP: 5.6 -Stable tag: 4.6.1 +Stable tag: 4.6.2 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -116,8 +116,11 @@ Set up both the plugin and the checkouts you want to activate on your payment av Check out our official documentation for more information on the specific fields to configure. == Changelog == -= v4.6.1 (04/01/2021) = += v4.6.2 (06/01/2021) = +* Bug fixes + - Changed loading of Mercado Pago SDK at custom checkout += v4.6.1 (04/01/2021) = * Features - Add support to LearnPress - Compatibility with Wordpress v5.6 and WooCommerce v4.8 diff --git a/woocommerce-mercadopago.php b/woocommerce-mercadopago.php index 11a26f2b8..e50f57b96 100644 --- a/woocommerce-mercadopago.php +++ b/woocommerce-mercadopago.php @@ -4,7 +4,7 @@ * Plugin Name: Mercado Pago payments for WooCommerce * Plugin URI: https://github.com/mercadopago/cart-woocommerce * Description: Configure the payment options and accept payments with cards, ticket and money of Mercado Pago account. - * Version: 4.6.1 + * Version: 4.6.2 * Author: Mercado Pago * Author URI: https://developers.mercadopago.com/ * Text Domain: woocommerce-mercadopago