Skip to content

Commit

Permalink
fix: allow only letters and space in holder name field #451
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaMelazzo authored Jun 24, 2024
2 parents 39c5431 + 0ad26cb commit 905b9b9
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 15 deletions.
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.2.2",
"version": "3.3.0",
"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.2.2');
wc_pagarme_define('WCMP_VERSION', '3.3.0');
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.
2 changes: 1 addition & 1 deletion languages/woo-pagarme-payments-pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: WooCommerce Pagar.me Payments 1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-pagarme-payments\n"
"POT-Creation-Date: 2018-06-22 13:58-0300\n"
"PO-Revision-Date: 2024-05-29 16:16-0300\n"
"PO-Revision-Date: 2024-06-20 15:37-0300\n"
"Last-Translator: Pagar.me\n"
"Language-Team: \n"
"Language: pt_BR\n"
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.2.2",
"version": "3.3.0",
"description": "Pagar.me module for Woocommerce",
"main": "woo-pagarme-payments.php",
"devDependencies": {
Expand Down
24 changes: 18 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ Nosso processo de instalação é simples e bem detalhado:
== Changelog ==
Lançamos versões regularmente com melhorias, correções e atualizações.

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

* **Novas funcionalidades:**
* [3DS 2.0](https://pagar.me/blog/3ds-2-0/);
* [Pedido Manual](https://woocommerce.com/document/como-gerenciar-pedidos/#section-16);
* Compatibilização com o [Checkout Blocks](https://docs.pagar.me/docs/requisitos-de-instala%C3%A7%C3%A3o-woocommerce#campos-do-checkout).

* **Melhorias:**
* [Estorno automático](https://woocommerce.com/document/woocommerce-refunds/#automatic-refunds) (fluxo padrão do Woocommerce);
* Status de pedidos não autorizados que antes iriam para cancelado, agora vão para Malsucedido conforme o [fluxo padrão do Woocommerce](https://woocommerce.com/document/como-gerenciar-pedidos/#section-2).
* Adição de um [filter para extensão](https://github.com/pagarme/woocommerce/blob/master/docs/filters-actions/split.md) de Split.

* **Correções:**
* Traduções do cartão de crédito;
* 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)

Expand All @@ -36,11 +54,5 @@ Você pode conferir essas atualizações aqui: [Github](https://github.com/pagar
* Remoção da modal de preencha dados obrigatórios


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

* **Correções:**
* Parcelamento de cartão de crédito

== Upgrade Notice ==
Nosso plugin agora é compatível com Woocommerce Subscriptions
4 changes: 2 additions & 2 deletions templates/checkout/form/card.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ wp_localize_script(
<span class="required">*</span>
</label>
<input type="text" id="<?= $this->getElementId('card-holder-name'); ?>"
onkeydown="return /[a-z, ]/i.test(event.key)" data-element="card-holder-name"
data-required="true" class="input-text" data-pagarme-element="holder_name">
data-element="card-holder-name" data-required="true" class="input-text"
data-pagarme-element="holder_name">
</p>
<p class="form-row form-row-wide pagarme-card-number-row">
<label for="<?= $this->getElementId('card-number'); ?>">
Expand Down
2 changes: 1 addition & 1 deletion woo-pagarme-payments.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Plugin Name: Pagar.me for Woocommerce
* Version: 3.2.2
* Version: 3.3.0
* Author: Pagar.me
* Author URI: https://pagar.me
* License: GPL2
Expand Down

0 comments on commit 905b9b9

Please sign in to comment.