Skip to content

Commit

Permalink
release 3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiano-mallmann authored Jul 2, 2024
2 parents 0dc7084 + 33ccc31 commit 45c03c3
Show file tree
Hide file tree
Showing 24 changed files with 535 additions and 324 deletions.
142 changes: 100 additions & 42 deletions assets/javascripts/admin/pagarme_payments.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,18 @@
/* jshint esversion: 6 */
(function ($) {
const installmentsTypeSelect = $('[data-element="installments-type-select"]');
const installmentsMax = $('[data-field="installments-maximum"]');
const installmentsInterest = $('[data-field="installments-interest"]');
const installmentsMinAmount = $('[data-field="installments-min-amount"]');
const installmentsByFlag = $('[data-field="installments-by-flag"]');
const installmentsWithoutInterest = $('[data-field="installments-without-interest"]');
const installmentsInterestIncrease = $('[data-field="installments-interest-increase"]');
const flagsSelect = $('[data-element="flags-select"]');
const installmentsMaxByFlags = $('[data-field="installments-maximum-by-flag"]');

$.jMaskGlobals.watchDataMask = true;
handleInstallmentFieldsVisibility(installmentsTypeSelect.val());
addEventListener();

function handleInstallmentFieldsVisibility(value) {
const installmentsMaxContainer = installmentsMax.closest('tr'),
installmentsInterestContainer = installmentsInterest.closest('tr'),
installmentsMinAmountContainer = installmentsMinAmount.closest("tr"),
installmentsByFlagContainer = installmentsByFlag.closest('tr'),
installmentsWithoutInterestContainer = installmentsWithoutInterest.closest('tr'),
installmentsInterestIncreaseContainer = installmentsInterestIncrease.closest('tr');

if (parseInt(value) === 1) {
installmentsMaxContainer.show();
installmentsMinAmountContainer.show();
installmentsInterestContainer.show();
installmentsInterestIncreaseContainer.show();
installmentsWithoutInterestContainer.show();
installmentsByFlagContainer.hide();
} else {
if (flagsSelect.val()) {
installmentsByFlagContainer.show();
setInstallmentsByFlags(null, true);
}
installmentsMaxContainer.hide();
installmentsMinAmountContainer.hide();
installmentsInterestContainer.hide();
installmentsInterestIncreaseContainer.hide();
installmentsWithoutInterestContainer.hide();
}
}
const
installmentsTypeSelect = $('[data-element="installments-type-select"]'),
installmentsMax = $('[data-field="installments-maximum"]'),
installmentsInterest = $('[data-field="installments-interest"]'),
installmentsInterestLegacy = $('[data-field="installments-interest-legacy"]'),
installmentsMinAmount = $('[data-field="installments-min-amount"]'),
installmentsByFlag = $('[data-field="installments-by-flag"]'),
installmentsWithoutInterest = $('[data-field="installments-without-interest"]'),
installmentsInterestIncrease = $('[data-field="installments-interest-increase"]'),
flagsSelect = $('[data-element="flags-select"]'),
installmentsMaxByFlags = $('[data-field="installments-maximum-by-flag"]'),

INSTALLMENTS_LEGACY = '3';

function toggleItemWhenItemFlagIsInFlags(flags, item) {
if (!flags.includes(item.data('flag'))) {
Expand Down Expand Up @@ -98,6 +71,58 @@
}
}

function handleInstallmentFieldsVisibility(value) {
const installmentsMaxContainer = installmentsMax.closest('tr'),
installmentsInterestContainer = installmentsInterest.closest('tr'),
installmentsInterestLegacyContainer = installmentsInterestLegacy.closest('tr'),
installmentsMinAmountContainer = installmentsMinAmount.closest("tr"),
installmentsByFlagContainer = installmentsByFlag.closest('tr'),
installmentsWithoutInterestContainer = installmentsWithoutInterest.closest('tr'),
installmentsInterestIncreaseContainer = installmentsInterestIncrease.closest('tr');

switch (parseInt(value)) {
case 1:
installmentsMaxContainer.show();
installmentsMinAmountContainer.show();
installmentsInterestContainer.show();
installmentsInterestIncreaseContainer.show();
installmentsInterestLegacyContainer.hide();
installmentsWithoutInterestContainer.show();
installmentsByFlagContainer.hide();
break;
case 2:
if (flagsSelect.val()) {
installmentsByFlagContainer.show();
setInstallmentsByFlags(null, true);
}
installmentsMaxContainer.hide();
installmentsMinAmountContainer.hide();
installmentsInterestContainer.hide();
installmentsInterestIncreaseContainer.hide();
installmentsInterestLegacyContainer.hide();
installmentsWithoutInterestContainer.hide();
break;
case 3:
installmentsMaxContainer.show();
installmentsMinAmountContainer.show();
installmentsInterestContainer.hide();
installmentsInterestIncreaseContainer.hide();
installmentsInterestLegacyContainer.show();
installmentsWithoutInterestContainer.show();
installmentsByFlagContainer.hide();
break;
default:
installmentsMaxContainer.hide();
installmentsMinAmountContainer.hide();
installmentsInterestContainer.hide();
installmentsInterestIncreaseContainer.hide();
installmentsInterestLegacyContainer.hide();
installmentsWithoutInterestContainer.hide();
installmentsByFlagContainer.hide();
break;
}
}

const setLowestValueToElement = (element, value) => {
const elementValueGreaterThanNewValue = parseInt(value) < parseInt(element.val());
if (elementValueGreaterThanNewValue) {
Expand Down Expand Up @@ -130,6 +155,26 @@
installmentsWithoutInterestByFlag.attr('max', parseInt(value));
};

const fillLegacyInstallmentInterests = () => {
if (installmentsTypeSelect.find(":selected").val() !== INSTALLMENTS_LEGACY) {
return;
}

let legacyInterest = installmentsInterestLegacy.val();

if (legacyInterest === '') {
installmentsInterest.val('');
installmentsInterestIncrease.val('');
return;
}

legacyInterest = parseInt(legacyInterest);
const noInterest = parseInt(installmentsWithoutInterest.val());

installmentsInterest.val(legacyInterest * (noInterest + 1));
installmentsInterestIncrease.val(legacyInterest);
};

installmentsMax.each(() => {
handleInstallmentWithoutInterestMaxValue($(installmentsMax).val());
});
Expand All @@ -146,15 +191,28 @@
handleInstallmentWithoutInterestMaxValue(event.currentTarget.value);
});
installmentsMaxByFlags.on('change', function (event) {
handleInstallmentsWithoutInterestFlagMaxValue($(this), event.currentTarget.value)
handleInstallmentsWithoutInterestFlagMaxValue($(this), event.currentTarget.value);
});
flagsSelect.on('select2:unselecting', function (event) {
setInstallmentsByFlags(event, false);
});
flagsSelect.on('select2:selecting', function (event) {
setInstallmentsByFlags(event, false);
});
installmentsTypeSelect.on('change', function() {
fillLegacyInstallmentInterests();
});
installmentsInterestLegacy.on('change', function() {
fillLegacyInstallmentInterests();
});
installmentsWithoutInterest.on('change', function() {
fillLegacyInstallmentInterests();
});
}

$.jMaskGlobals.watchDataMask = true;
handleInstallmentFieldsVisibility(installmentsTypeSelect.val());
addEventListener();

}(jQuery)
);
26 changes: 24 additions & 2 deletions assets/javascripts/front/checkout/model/payment/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ let pagarmeCard = {
}
return paymentSelected.indexOf('pagarme');
},
preventSpecialCharacter: function (element) {
let selectionStart = element.selectionStart;
const regex = /[^a-z ]/gi;
const val = jQuery(element).val();

if(regex.test(val)) {
jQuery(element).val(val.replace(regex, ''));
selectionStart--;
}

element.setSelectionRange(selectionStart, selectionStart);
},
keyEventHandlerCard: function (event) {
this.clearToken(event);
this.loadBrand(event);
Expand Down Expand Up @@ -350,7 +362,7 @@ let pagarmeCard = {

if (typeof formattedEvent.unblock === 'function') {
formattedEvent.unblock();
return;
return;
}

if (typeof jQuery.unblockUI === 'function') {
Expand All @@ -368,7 +380,7 @@ let pagarmeCard = {
opacity: 0.6
}
});
return;
return;
}

if (typeof jQuery.blockUI === 'function') {
Expand Down Expand Up @@ -484,9 +496,15 @@ let pagarmeCard = {
jQuery(this.billingCpfId).on('change', function () {
pagarmeCard.onChangeBillingCpf();
});

jQuery(this.cardHolderNameTarget).on('input', function () {
pagarmeCard.preventSpecialCharacter(this);
});

jQuery(this.cardNumberTarget).on('change', function (event) {
pagarmeCard.keyEventHandlerCard(event);
});

jQuery(`${this.fieldsetCardElements} input`).on('change', function () {
pagarmeCard.clearErrorMessages();
});
Expand All @@ -504,6 +522,10 @@ let pagarmeCard = {
if (typeof pagarmeOrderValue == 'object') {
pagarmeOrderValue.start();
}

jQuery(this.cardHolderNameTarget).on('input', function () {
pagarmeCard.preventSpecialCharacter(this);
});
},
start: function () {
jQuery(document).ready(function () {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pagarme/woocommerce-pagarme-payments",
"description": "Pagar.me module for Woocommerce",
"type": "wordpress-plugin",
"version": "3.3.0",
"version": "3.3.1",
"license": "GPL",
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function wc_pagarme_define($name, $value)

wc_pagarme_define('WCMP_SLUG', 'woo-pagarme-payments');
wc_pagarme_define('WCMP_PREFIX', 'pagarme');
wc_pagarme_define('WCMP_VERSION', '3.3.0');
wc_pagarme_define('WCMP_VERSION', '3.3.1');
wc_pagarme_define('WCMP_ROOT_PATH', dirname(__FILE__) . '/');
wc_pagarme_define('WCMP_ROOT_SRC', WCMP_ROOT_PATH . 'src/');
wc_pagarme_define('WCMP_ROOT_FILE', WCMP_ROOT_PATH . WCMP_SLUG . '.php');
Expand Down
Binary file modified languages/woo-pagarme-payments-pt_BR.mo
Binary file not shown.
56 changes: 37 additions & 19 deletions languages/woo-pagarme-payments-pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ msgstr "Configurações de Cartão de crédito"

#: src/Controller/Gateways.php:390
msgid "Soft descriptor"
msgstr "Soft descriptor"
msgstr "Identificação na fatura do cartão"

#: src/Controller/Gateways.php:392
msgid "Maximum of 13 characters"
Expand Down Expand Up @@ -929,20 +929,30 @@ msgstr "Configurações que só funcionam para clientes Gateway que têm contrat
msgid "Enable card wallet"
msgstr "Habilitar card wallet"

msgid "Description that appears on the credit card bill."
msgstr "Descrição que aparece na fatura do cartão de crédito."
msgid "Name that will appear on the buyer's card bill."
msgstr "Nome que aparecerá na fatura do cartão do comprador."

msgid "Description that appears on the voucher bill."
msgstr "Descrição que aparece na fatura do cartão de voucher."
msgid "Name that will appear on the buyer's voucher bill."
msgstr "Nome que aparecerá na fatura do voucher do comprador."

msgid "Installment configuration"
msgstr "Configuração de parcelamento"
msgid "Subscription settings"
msgstr "Configurações de assinatura"

msgid "Installment settings"
msgstr "Configurações de parcelamento"

msgid "Do you have any questions about these settings? For more information and examples, visit our %sdocumentation »%s"
msgstr ""
"Está com alguma dúvida sobre essas configurações? Para mais informações e exemplos, acesse nossa %sdocumentação »%s"

msgid "For all card brands"
msgstr "Para todas as bandeiras de cartão"

msgid "By card brand"
msgstr "Por cada bandeira de cartão"
msgstr "Por bandeira de cartão"

msgid "Use default 1.0"
msgstr "Usar padrão 1.0"

msgid "Max number of installments"
msgstr "Número máximo de parcelas"
Expand All @@ -953,14 +963,25 @@ msgstr "Taxa de juros inicial (%)"
msgid "Incremental interest rate (%)"
msgstr "Taxa de juros incremental (%)"

msgid "Allows for cards to be saved for future purchases."
msgstr "Permite que os cartões sejam salvos para compras futuras."
msgid "Interest rate (%)"
msgstr "Taxa de juros (%)"

msgid "Interest rate applied starting with the first installment with interest."
msgstr "Taxa de juros aplicada a partir da primeira parcela com juros."
msgid ""
"Allows users to pay for a new order with cards saved from previous orders. Card details are saved on Pagar.me and not "
"in your store."
msgstr ""
"Permite que os usuários paguem um novo pedido com dados de cartões salvos de pedidos anteriores. Os detalhes do "
"cartão são salvos no Pagar.me e não na sua loja."

msgid "Interest rate added for each installment with interest."
msgstr "Taxa de juros adicionada para cada parcela com juros."
msgid "Fee that will be charged from the first installment with interest."
msgstr "Taxa que será cobrada a partir da primeira parcela com juros."

msgid ""
"Fee that will be charged increasingly from the second installment with interest added to the initial interest rate."
msgstr "Taxa que será cobrada de forma crescente a partir da segunda parcela com juros somada a taxa de juros inicial."

msgid "Fee that will be charged increasingly to all installments."
msgstr "Taxa de juros padrão a ser aplicada de forma crescente a todas as parcelas."

msgid "Number of installments without interest"
msgstr "Quantidade de parcelas sem juros"
Expand Down Expand Up @@ -1082,11 +1103,8 @@ msgstr "Não"
msgid "Pagar.me integration"
msgstr "Integração Pagar.me"

msgid "Card Wallet"
msgstr "Carteira"

msgid "Card wallet"
msgstr "Carteira"
msgid "Allow payments with saved cards"
msgstr "Permitir pagamentos com cartões salvos"

msgid "Cancel"
msgstr "Cancelar"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woo-pagarme-payments",
"version": "3.3.0",
"version": "3.3.1",
"description": "Pagar.me module for Woocommerce",
"main": "woo-pagarme-payments.php",
"devDependencies": {
Expand Down
21 changes: 10 additions & 11 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ Nosso processo de instalação é simples e bem detalhado:
== Changelog ==
Lançamos versões regularmente com melhorias, correções e atualizações.

= 3.3.1 (02/07/2024) =
Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.3.1)

* **Melhorias:**
* Adição nova lógica de juros 1.0

* **Correções:**
* Campo "Nome impresso no cartão" aceitando carácter especial
* Cobrar imposto quando preço do produto não incluir a taxa

= 3.3.0 (20/06/2024) =
Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.3.0)

Expand All @@ -43,16 +53,5 @@ Você pode conferir essas atualizações aqui: [Github](https://github.com/pagar
* Remoção de readonly em configurações no painel administrativo;
* Não acessar mais variáveis diretamente.

= 3.2.2 (16/04/2024) =
Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.2.2)

* **Correções:**
* Atualização do SweetAlert para 11.10.1
* Compra com número 0 no endereço
* Remoção de campo vazio no admin para Pix e Boleto
* Webhook URL com o path da loja
* Remoção da modal de preencha dados obrigatórios


== Upgrade Notice ==
Nosso plugin agora é compatível com Woocommerce Subscriptions
Loading

0 comments on commit 45c03c3

Please sign in to comment.