Skip to content

Commit 989bc47

Browse files
authored
Release 2.4.2 (#331)
Release 2.4.2
2 parents 72cf07a + b9b9fa4 commit 989bc47

File tree

6 files changed

+192
-178
lines changed

6 files changed

+192
-178
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "pagarme/pagarme-magento2-module",
33
"license": "MIT",
4-
"version": "2.4.1",
4+
"version": "2.4.2",
55
"type": "magento2-module",
66
"description": "Magento 2 Module Pagar.me",
77
"require": {

e2e/helper/pagarme_helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const locators = {
88
}
99

1010

11-
const selectCreditCardOPtion = async page => {
11+
const selectCreditCardOption = async page => {
1212
await page.getByLabel('Pagar.me Credit Card').check();
1313
await page.waitForTimeout(1000); //ninguem gosta disso, imagina ter que usar ne?
1414
}
@@ -39,7 +39,7 @@ const finalizeCheckout = async page => {
3939

4040

4141
module.exports = {
42-
selectCreditCardOPtion,
42+
selectCreditCardOption,
4343
informCreditCartNumber,
4444
informCreditCartName,
4545
selectExpireDate,

e2e/tests/cartao-de-credito.e2e.test.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
const { test, expect } = require('@playwright/test')
2-
const { searchProduct,
3-
selectProduct,
4-
addToCart,
2+
const { searchProduct,
3+
selectProduct,
4+
addToCart,
55
proceedCheckout } = require('../helper/product_helper')
6-
const { informEmail,
7-
informFirstAndLastName,
8-
informCompany,
9-
informAddress,
10-
selectState,
11-
selectCountry,
12-
informCEP,
13-
informCity,
14-
informPhoneNumber,
15-
informVatNumber,
6+
const { informEmail,
7+
informFirstAndLastName,
8+
informCompany,
9+
informAddress,
10+
selectState,
11+
selectCountry,
12+
informCEP,
13+
informCity,
14+
informPhoneNumber,
15+
informVatNumber,
1616
goToCheckoutNextPage } = require('../helper/checkout_helper')
17-
const { selectCreditCardOPtion,
18-
informCreditCartNumber,
19-
informCreditCartName,
20-
selectExpireDate,
21-
informCVV,
17+
const { selectCreditCardOption,
18+
informCreditCartNumber,
19+
informCreditCartName,
20+
selectExpireDate,
21+
informCVV,
2222
finalizeCheckout } = require('../helper/pagarme_helper')
23-
const { user_information,
23+
const { user_information,
2424
address_information,
25-
vat_information,
25+
vat_information,
2626
credit_card_information_valid } = require('../helper/data_helper')
2727

2828
test.describe('Cartão de Crédito', () => {
@@ -51,13 +51,13 @@ test.describe('Cartão de Crédito', () => {
5151
await informPhoneNumber(page, user.phone_number)
5252
await informVatNumber(page, vat.valid_cpf)
5353
await goToCheckoutNextPage(page)
54-
await selectCreditCardOPtion(page)
54+
await selectCreditCardOption(page)
5555
await informCreditCartNumber(page, credit_card.credit_card_number)
5656
await informCreditCartName(page, user.first_name)
5757
await selectExpireDate(page, '3', credit_card.credit_card_year)
5858
await informCVV(page, credit_card.credit_card_cvv)
5959
await finalizeCheckout(page)
60-
await expect(page.getByText('Thank you for your purchase!')).toBeVisible();
60+
await expect(page.getByText('Thank you for your purchase!')).toBeVisible();
6161
})
6262

6363
test('Criar pedido com CNPJ', async ({page}) => {
@@ -80,12 +80,12 @@ test.describe('Cartão de Crédito', () => {
8080
await informPhoneNumber(page, user.phone_number)
8181
await informVatNumber(page, vat.valid_cnpj)
8282
await goToCheckoutNextPage(page)
83-
await selectCreditCardOPtion(page)
83+
await selectCreditCardOption(page)
8484
await informCreditCartNumber(page, credit_card.credit_card_number)
8585
await informCreditCartName(page, user.first_name)
8686
await selectExpireDate(page, '3', credit_card.credit_card_year)
8787
await informCVV(page, credit_card.credit_card_cvv)
8888
await finalizeCheckout(page)
89-
await expect(page.getByText('Thank you for your purchase!')).toBeVisible();
89+
await expect(page.getByText('Thank you for your purchase!')).toBeVisible();
9090
})
9191
})

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
-->
1111
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
12-
<module name="Pagarme_Pagarme" setup_version="2.4.1">
12+
<module name="Pagarme_Pagarme" setup_version="2.4.2">
1313
<sequence>
1414
<module name="Magento_Sales" />
1515
<module name="Magento_Payment" />

view/frontend/web/js/core/checkout/PaymentMethodController.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ define([
9292
subscribeTotal() {
9393
const _self = this;
9494

95-
this.platformConfig.updateTotals.totals.subscribe(function(){
95+
this.platformConfig.updateTotals.totals.subscribe(function () {
9696
if (_self.methodCode === 'twocreditcards' || _self.methodCode === 'boletoCreditcard') {
9797
let totalAmount = 0;
9898
const separator = '.';
@@ -373,7 +373,7 @@ define([
373373

374374
});
375375

376-
formObject.inputAmount.on('keyup', function(){
376+
formObject.inputAmount.on('keyup', function () {
377377
const element = $(this);
378378

379379
const originalValue = paymentMethodController.platformConfig.updateTotals.getTotals()().grand_total;
@@ -435,10 +435,11 @@ define([
435435
|| element.attr('name').startsWith('payment[cc_exp_year]')
436436
) {
437437
paymentMethodController.validateCcExpDateField(formObject);
438-
return;
438+
439439
}
440440
});
441441
}
442+
442443
addCreditCardNumberListener(formObject) {
443444

444445
const paymentMethodController = this;
@@ -459,8 +460,8 @@ define([
459460
formObject.creditCardNumber.on('change', function () {
460461
const element = $(this);
461462

462-
setTimeout(function() {
463-
paymentMethodController.setBin(binObj, element, formObject);
463+
setTimeout(function () {
464+
paymentMethodController.setBin(binObj, element, formObject);
464465
}, 300);
465466
});
466467
}
@@ -481,7 +482,7 @@ define([
481482
sumTotal = (sumTotal + sumInterestTotal).toString();
482483
sumInterestTotal = sumInterestTotal.toString();
483484

484-
return { sumTotal, sumInterestTotal };
485+
return {sumTotal, sumInterestTotal};
485486
}
486487

487488
boletoCreditCardTotal(paymentMethod) {
@@ -500,7 +501,7 @@ define([
500501
}
501502
sumInterestTotal = sumInterestTotal.toString();
502503

503-
return { sumTotal, sumInterestTotal };
504+
return {sumTotal, sumInterestTotal};
504505
}
505506

506507
updateTotalByPaymentMethod(paymentMethod, event) {
@@ -557,7 +558,7 @@ define([
557558
formHandler.init(formObject);
558559

559560

560-
formObject.savedCreditCardSelect.on('change', function() {
561+
formObject.savedCreditCardSelect.on('change', function () {
561562
const value = $(this).val();
562563
const currentSavedCardBrand = $(this).find(optionSelectedSelector).attr('brand');
563564

@@ -718,7 +719,7 @@ define([
718719
url: installmentsUrl,
719720
method: 'GET',
720721
cache: true,
721-
}).done(function(data) {
722+
}).done(function (data) {
722723
formHandler = new FormHandler();
723724

724725
if (!data.length) return;
@@ -731,6 +732,7 @@ define([
731732
formHandler.switchBrand(selectedBrand);
732733
});
733734
}
735+
734736
fillBrandList(formObject, method) {
735737
if (method == undefined) {
736738
method = 'pagarme_creditcard';
@@ -751,14 +753,15 @@ define([
751753
amount = amount.replace(separator, this.platformConfig.currency.decimalSeparator);
752754

753755
if (card === 1) {
754-
const orderAmountOriginal = amount.replace(this.platformConfig.currency.decimalSeparator, ".");
756+
const orderAmountOriginal = amount.replace(this.platformConfig.currency.decimalSeparator, ".");
755757
const amountBalance = (this.platformConfig.updateTotals.getTotals()().grand_total - orderAmountOriginal).toFixed(2);
756758
formObject.inputAmount.val(amountBalance.replace(".", this.platformConfig.currency.decimalSeparator));
757759
return;
758760
}
759761

760762
formObject.inputAmount.val(amount);
761763
}
764+
762765
validateCcNumberField(element, formObject) {
763766
if (element.val() === '') {
764767
formObject.creditCardBrand.val('');
@@ -768,12 +771,14 @@ define([
768771
formHandler.switchBrand('');
769772
}
770773
}
774+
771775
validateCcExpDateField(formObject) {
772776
const cardExpirationMonth = formObject.creditCardExpMonth;
773777
const cardExpirationYear = formObject.creditCardExpYear;
774778

775-
const cardDate = new Date(cardExpirationYear.val(), cardExpirationMonth.val() -1);
776-
const dateNow = new Date();
779+
const cardDate = new Date(cardExpirationYear.val(), cardExpirationMonth.val() - 1);
780+
let dateNow = new Date();
781+
dateNow = new Date(dateNow.getFullYear(), dateNow.getMonth());
777782

778783
const monthParentsElements = cardExpirationMonth.parent().parent();
779784
const yearParentsElements = cardExpirationYear.parent().parent();
@@ -817,6 +822,7 @@ define([
817822

818823
return false;
819824
}
825+
820826
setBin(binObj, creditCardNumberElement, formObject) {
821827

822828
const bin = binObj;
@@ -838,13 +844,13 @@ define([
838844
this.fillInstallments(formObject);
839845
}
840846

841-
return;
847+
842848
}
843849

844850
limitCharacters(element, limit) {
845851
const val = element.val();
846852

847-
if(val != "" && val.length > limit) {
853+
if (val != "" && val.length > limit) {
848854
element.val(val.substring(0, limit));
849855
}
850856
}

0 commit comments

Comments
 (0)