Skip to content

Commit

Permalink
Prevent providing BLIK code longer than 6 characters and with non-digits
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubtobiasz committed Oct 31, 2024
1 parent a22da86 commit d055d10
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions assets/shop/checkout_complete_entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import './scss/style.scss';
import './js/_pay_by_link';
import './js/_visa_mobile';
import './js/apple_pay';
import './js/blik_code';
import {CardForm} from "./js/card_form";

document.addEventListener('DOMContentLoaded', () => {
Expand Down
19 changes: 19 additions & 0 deletions assets/shop/js/blik_code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
document.addEventListener('DOMContentLoaded', () => {
const BLIK_CODE_LENGTH = 6;

let blikCode = document.querySelector('[data-blik-code-input]');

if (null === blikCode) {
return;
}

blikCode.addEventListener('keypress', function(e) {
if (!/[0-9]/.test(e.key)) {
e.preventDefault();
}

if (blikCode.value.length + 1 > BLIK_CODE_LENGTH) {
e.preventDefault();
}
});
});
1 change: 1 addition & 0 deletions assets/shop/order_show_entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './js/retry_payment';
import './scss/style.scss';
import './js/_pay_by_link';
import './js/blik_code';
import {CardForm} from "./js/card_form";

document.addEventListener('DOMContentLoaded', () => {
Expand Down
2 changes: 1 addition & 1 deletion templates/shop/payment/_blik.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="ui small icon message">
<i class="payment icon"></i>
<div class="content">
{{ form_row(form.tpay.blik_token) }}
{{ form_row(form.tpay.blik_token, { 'attr': { 'data-blik-code-input': '' } }) }}
{% include '@CommerceWeaversSyliusTpayPlugin/shop/partial/_policies.html.twig' %}
</div>
</div>
Expand Down

0 comments on commit d055d10

Please sign in to comment.