diff --git a/assets/js/scripts-boleto.js b/assets/js/scripts-boleto.js
old mode 100755
new mode 100644
index 0dca931..3e6b0f5
--- a/assets/js/scripts-boleto.js
+++ b/assets/js/scripts-boleto.js
@@ -1,164 +1,166 @@
- jQuery(document).ready(
- function ($) {
-
- if(!document.getElementById('swalCss')){
- let swalCss = $( "" ).html( ".colored-toast .swal2-title {color: white;}.colored-toast .swal2-close {color: white;}.colored-toast .swal2-html-container {color: white;}.colored-toast.swal2-icon-error {background-color: #f27474 !important;}" )
- $( "#payment" ).after( swalCss );
- }
-
- if (document.getElementById("gn_boleto_cpf_cnpj")) {
- $('#gn_boleto_cpf_cnpj').keyup(
- function () {
- $('#gn_boleto_cpf_cnpj').val().length > 14 ? VMasker(document.querySelector("#gn_boleto_cpf_cnpj")).maskPattern("99.999.999/9999-99") : VMasker(document.querySelector("#gn_boleto_cpf_cnpj")).maskPattern("999.999.999-99");
- }
- )
- $('#gn_boleto_cpf_cnpj').blur(
- function () {
- var cpf_cnpj = $('#gn_boleto_cpf_cnpj').val();
-
- if (!validate_cpf_cnpj(cpf_cnpj)) {
- $('#gn_boleto_cpf_cnpj').css('border', '1px solid red');
- customError("CPF/CNPJ Inválido");
- } else {
- $('#gn_boleto_cpf_cnpj').css('border', '1px solid green');
- }
- }
- )
- }
-
- // Esconder campos caso haja o brazillian market
-
- if (typeof $('#billing_cpf').val() !== 'undefined') {
-
- // cpf_cnpj boleto
- if (typeof $('#gn_boleto_cpf_cnpj').val() !== 'undefined') {
- $('#gn_boleto_cpf_cnpj').val($('#billing_cpf').val())
- $('#gn_field_boleto').hide();
- }
-
- $('#billing_cpf').keyup(function () {
-
- if (typeof $('#gn_boleto_cpf_cnpj').val() !== 'undefined') {
- // cpf_cnpj boleto
- $('#gn_boleto_cpf_cnpj').val($('#billing_cpf').val())
- $('#gn_field_boleto').hide();
- }
- }
- )
- }
-
- if (typeof $('#billing_cnpj').val() !== 'undefined') {
- $('#billing_cnpj').keyup(
- function () {
- // cpf_cnpj boleto
- $('#gn_boleto_cpf_cnpj').val($('#billing_cnpj').val())
- $('#gn_field_boleto').hide();
- }
- )
- }
-
- // Bairro obrigatório
- if (typeof $('#billing_neighborhood_field > label > span').html() !== 'undefined') {
- $('#billing_neighborhood_field > label > span').html($('#billing_neighborhood_field > label > span').html().replace('opcional', 'obrigatório'))
- }
-
- }
- );
-
- function validate_cpf_cnpj(cpf_cnpj) {
-
- cpf_cnpj = cpf_cnpj.trim().replace(/\./g, '').replace('-', '').replace('/', '');
-
- if (cpf_cnpj < 11) {
- return false;
- }
-
- if (cpf_cnpj.length == 11) {
- var remnant, sum = 0;
-
- for (i = 1; i <= 9; i++) {
- sum = sum + parseInt(cpf_cnpj.substring(i - 1, i)) * (11 - i);
- }
- remnant = (sum * 10) % 11;
-
- if ((remnant == 10) || (remnant == 11)) {
- remnant = 0;
- }
- if (remnant != parseInt(cpf_cnpj.substring(9, 10))) {
- return false;
- }
-
- sum = 0;
-
- for (i = 1; i <= 10; i++) {
- sum = sum + parseInt(cpf_cnpj.substring(i - 1, i)) * (12 - i);
- }
- remnant = (sum * 10) % 11;
-
- if ((remnant == 10) || (remnant == 11)) {
- remnant = 0;
- }
- if (remnant != parseInt(cpf_cnpj.substring(10, 11))) {
- return false;
- }
- return true;
-
- } else if (cpf_cnpj.length == 14) {
- var tam = cpf_cnpj.length - 2
- var numbers = cpf_cnpj.substring(0, tam);
- var digits = cpf_cnpj.substring(tam);
- var sum = 0;
- var pos = tam - 7;
-
- for (i = tam; i >= 1; i--) {
- sum += numbers.charAt(tam - i) * pos--;
- if (pos < 2) {
- pos = 9;
- }
- }
-
- var result = sum % 11 < 2 ? 0 : 11 - sum % 11;
-
- if (result != digits.charAt(0)) {
- return false;
- }
-
- tam = tam + 1;
- numbers = cpf_cnpj.substring(0, tam);
- sum = 0;
- pos = tam - 7;
-
- for (i = tam; i >= 1; i--) {
- sum += numbers.charAt(tam - i) * pos--;
- if (pos < 2) {
- pos = 9;
- }
- }
-
- result = sum % 11 < 2 ? 0 : 11 - sum % 11;
-
- if (result != digits.charAt(1)) {
- return false;
- }
-
- return true;
- }
-
- }
-
- function customError(msg) {
- Swal.mixin(
- {
- toast: true,
- position: 'top-right',
- iconColor: 'white',
- customClass: {
- popup: 'colored-toast'
- },
- showConfirmButton: false,
- timer: 5000,
- timerProgressBar: true
- }
- ).fire({ icon: 'error', title: msg })
- }
-
+ jQuery(document).ready(
+ function ($) {
+
+ if(!document.getElementById('swalCss')){
+ let swalCss = $( "" ).html( ".colored-toast .swal2-title {color: white;}.colored-toast .swal2-close {color: white;}.colored-toast .swal2-html-container {color: white;}.colored-toast.swal2-icon-error {background-color: #f27474 !important;}" )
+ $( "#payment" ).after( swalCss );
+ }
+
+ if (document.getElementById("gn_boleto_cpf_cnpj")) {
+ $('#gn_boleto_cpf_cnpj').keyup(
+ function () {
+ $('#gn_boleto_cpf_cnpj').val().length > 14 ? VMasker(document.querySelector("#gn_boleto_cpf_cnpj")).maskPattern("99.999.999/9999-99") : VMasker(document.querySelector("#gn_boleto_cpf_cnpj")).maskPattern("999.999.999-99");
+ }
+ )
+ $('#gn_boleto_cpf_cnpj').blur(
+ function () {
+ var cpf_cnpj = $('#gn_boleto_cpf_cnpj').val();
+
+ if(cpf_cnpj != "") {
+ if (!validate_cpf_cnpj(cpf_cnpj)) {
+ $('#gn_boleto_cpf_cnpj').css('border', '1px solid red');
+ customError("CPF/CNPJ Inv谩lido");
+ } else {
+ $('#gn_boleto_cpf_cnpj').css('border', '1px solid green');
+ }
+ }
+ }
+ )
+ }
+
+ // Esconder campos caso haja o brazillian market
+
+ if (typeof $('#billing_cpf').val() !== 'undefined') {
+
+ // cpf_cnpj boleto
+ if (typeof $('#gn_boleto_cpf_cnpj').val() !== 'undefined') {
+ $('#gn_boleto_cpf_cnpj').val($('#billing_cpf').val())
+ $('#gn_field_boleto').hide();
+ }
+
+ $('#billing_cpf').keyup(function () {
+
+ if (typeof $('#gn_boleto_cpf_cnpj').val() !== 'undefined') {
+ // cpf_cnpj boleto
+ $('#gn_boleto_cpf_cnpj').val($('#billing_cpf').val())
+ $('#gn_field_boleto').hide();
+ }
+ }
+ )
+ }
+
+ if (typeof $('#billing_cnpj').val() !== 'undefined') {
+ $('#billing_cnpj').keyup(
+ function () {
+ // cpf_cnpj boleto
+ $('#gn_boleto_cpf_cnpj').val($('#billing_cnpj').val())
+ $('#gn_field_boleto').hide();
+ }
+ )
+ }
+
+ // Bairro obrigat贸rio
+ if (typeof $('#billing_neighborhood_field > label > span').html() !== 'undefined') {
+ $('#billing_neighborhood_field > label > span').html($('#billing_neighborhood_field > label > span').html().replace('opcional', 'obrigat贸rio'))
+ }
+
+ }
+ );
+
+ function validate_cpf_cnpj(cpf_cnpj) {
+
+ cpf_cnpj = cpf_cnpj.trim().replace(/\./g, '').replace('-', '').replace('/', '');
+
+ if (cpf_cnpj < 11) {
+ return false;
+ }
+
+ if (cpf_cnpj.length == 11) {
+ var remnant, sum = 0;
+
+ for (i = 1; i <= 9; i++) {
+ sum = sum + parseInt(cpf_cnpj.substring(i - 1, i)) * (11 - i);
+ }
+ remnant = (sum * 10) % 11;
+
+ if ((remnant == 10) || (remnant == 11)) {
+ remnant = 0;
+ }
+ if (remnant != parseInt(cpf_cnpj.substring(9, 10))) {
+ return false;
+ }
+
+ sum = 0;
+
+ for (i = 1; i <= 10; i++) {
+ sum = sum + parseInt(cpf_cnpj.substring(i - 1, i)) * (12 - i);
+ }
+ remnant = (sum * 10) % 11;
+
+ if ((remnant == 10) || (remnant == 11)) {
+ remnant = 0;
+ }
+ if (remnant != parseInt(cpf_cnpj.substring(10, 11))) {
+ return false;
+ }
+ return true;
+
+ } else if (cpf_cnpj.length == 14) {
+ var tam = cpf_cnpj.length - 2
+ var numbers = cpf_cnpj.substring(0, tam);
+ var digits = cpf_cnpj.substring(tam);
+ var sum = 0;
+ var pos = tam - 7;
+
+ for (i = tam; i >= 1; i--) {
+ sum += numbers.charAt(tam - i) * pos--;
+ if (pos < 2) {
+ pos = 9;
+ }
+ }
+
+ var result = sum % 11 < 2 ? 0 : 11 - sum % 11;
+
+ if (result != digits.charAt(0)) {
+ return false;
+ }
+
+ tam = tam + 1;
+ numbers = cpf_cnpj.substring(0, tam);
+ sum = 0;
+ pos = tam - 7;
+
+ for (i = tam; i >= 1; i--) {
+ sum += numbers.charAt(tam - i) * pos--;
+ if (pos < 2) {
+ pos = 9;
+ }
+ }
+
+ result = sum % 11 < 2 ? 0 : 11 - sum % 11;
+
+ if (result != digits.charAt(1)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ }
+
+ function customError(msg) {
+ Swal.mixin(
+ {
+ toast: true,
+ position: 'top-right',
+ iconColor: 'white',
+ customClass: {
+ popup: 'colored-toast'
+ },
+ showConfirmButton: false,
+ timer: 5000,
+ timerProgressBar: true
+ }
+ ).fire({ icon: 'error', title: msg })
+ }
+
diff --git a/assets/js/scripts-cartao.js b/assets/js/scripts-cartao.js
old mode 100755
new mode 100644
index c5bdb37..b9b7aee
--- a/assets/js/scripts-cartao.js
+++ b/assets/js/scripts-cartao.js
@@ -1,348 +1,353 @@
-jQuery(document).ready(function ($) {
-
- if (!document.getElementById('swalCss')) {
- let swalCss = $("").html(".colored-toast .swal2-title {color: white;}.colored-toast .swal2-close {color: white;}.colored-toast .swal2-html-container {color: white;}.colored-toast.swal2-icon-error {background-color: #f27474 !important;}")
- $("#payment").after(swalCss);
- }
-
-
-
- // Gerar Payment Token
- jQuery("#gn_cartao_expiration").on('keyup', function () {
- let cardExpiration = jQuery("#gn_cartao_expiration").val().split("/");
-
- if (jQuery("#gn_cartao_expiration").val().length >= 7) {
-
- Swal.fire({
- title: 'Por favor, aguarde...',
- text: '',
- showConfirmButton: false,
- })
-
- EfiJs.CreditCard
- // .debugger(true)
- .setCardNumber(jQuery("#gn_cartao_number").val())
- .verifyCardBrand()
- .then(brand => {
- if (brand !== 'undefined') {
- EfiJs.CreditCard
- //.debugger(true)
- .setAccount(options.payeeCode)
- .setEnvironment(options.enviroment) // 'production' or 'homologation'
- .setCreditCardData({
- brand: brand,
- number: jQuery("#gn_cartao_number").val(),
- cvv: jQuery("#gn_cartao_cvv").val(),
- expirationMonth: cardExpiration[0],
- expirationYear: cardExpiration[1]
- })
- .getPaymentToken()
- .then(data => {
- // Trata a resposta
- jQuery('#gn_payment_token').val(data.payment_token);
- swal.close()
- }).catch(err => {
- swalError(err);
- throw new Error(`Something went wrong in getPaymentToken(.\n ${err}`);
- });
- }
- }).catch(err => {
- swalError(err);
- throw new Error(`Something went wrong in verifyCardBrand(.\n ${err}`);
- });
- }
-
- });
-
-
- // Buscar Parcelas
- jQuery("#gn_cartao_number").on('keyup mouseout', function () {
-
- let total = document.querySelector("#gn_payment_total").value;
- total = parseInt(total.replace('.', ''));
- console.log(total);
-
- if (jQuery("#gn_cartao_number").val().length >= 15) {
-
- EfiJs.CreditCard
- // .debugger(true)
- .setCardNumber(jQuery("#gn_cartao_number").val())
- .verifyCardBrand()
- .then(brand => {
- if (brand !== 'undefined') {
- EfiJs.CreditCard
- //.debugger(true)
- .setAccount(options.payeeCode)
- .setEnvironment(options.enviroment) // 'production' or 'homologation'
- .setBrand(brand)
- .setTotal(total)
- .getInstallments()
- .then(response => {
- jQuery('#gn_cartao_no_installments').hide();
- jQuery('#gn_cartao_installments')
- .find('option')
- .remove()
-
- response.installments.forEach(element => {
- jQuery('#gn_cartao_installments').append(jQuery('