Skip to content

Commit

Permalink
Release 2.4.2 (#331)
Browse files Browse the repository at this point in the history
Release 2.4.2
  • Loading branch information
RafaMelazzo authored Apr 25, 2024
2 parents 72cf07a + b9b9fa4 commit 989bc47
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 178 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pagarme/pagarme-magento2-module",
"license": "MIT",
"version": "2.4.1",
"version": "2.4.2",
"type": "magento2-module",
"description": "Magento 2 Module Pagar.me",
"require": {
Expand Down
4 changes: 2 additions & 2 deletions e2e/helper/pagarme_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const locators = {
}


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


module.exports = {
selectCreditCardOPtion,
selectCreditCardOption,
informCreditCartNumber,
informCreditCartName,
selectExpireDate,
Expand Down
48 changes: 24 additions & 24 deletions e2e/tests/cartao-de-credito.e2e.test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
const { test, expect } = require('@playwright/test')
const { searchProduct,
selectProduct,
addToCart,
const { searchProduct,
selectProduct,
addToCart,
proceedCheckout } = require('../helper/product_helper')
const { informEmail,
informFirstAndLastName,
informCompany,
informAddress,
selectState,
selectCountry,
informCEP,
informCity,
informPhoneNumber,
informVatNumber,
const { informEmail,
informFirstAndLastName,
informCompany,
informAddress,
selectState,
selectCountry,
informCEP,
informCity,
informPhoneNumber,
informVatNumber,
goToCheckoutNextPage } = require('../helper/checkout_helper')
const { selectCreditCardOPtion,
informCreditCartNumber,
informCreditCartName,
selectExpireDate,
informCVV,
const { selectCreditCardOption,
informCreditCartNumber,
informCreditCartName,
selectExpireDate,
informCVV,
finalizeCheckout } = require('../helper/pagarme_helper')
const { user_information,
const { user_information,
address_information,
vat_information,
vat_information,
credit_card_information_valid } = require('../helper/data_helper')

test.describe('Cartão de Crédito', () => {
Expand Down Expand Up @@ -51,13 +51,13 @@ test.describe('Cartão de Crédito', () => {
await informPhoneNumber(page, user.phone_number)
await informVatNumber(page, vat.valid_cpf)
await goToCheckoutNextPage(page)
await selectCreditCardOPtion(page)
await selectCreditCardOption(page)
await informCreditCartNumber(page, credit_card.credit_card_number)
await informCreditCartName(page, user.first_name)
await selectExpireDate(page, '3', credit_card.credit_card_year)
await informCVV(page, credit_card.credit_card_cvv)
await finalizeCheckout(page)
await expect(page.getByText('Thank you for your purchase!')).toBeVisible();
await expect(page.getByText('Thank you for your purchase!')).toBeVisible();
})

test('Criar pedido com CNPJ', async ({page}) => {
Expand All @@ -80,12 +80,12 @@ test.describe('Cartão de Crédito', () => {
await informPhoneNumber(page, user.phone_number)
await informVatNumber(page, vat.valid_cnpj)
await goToCheckoutNextPage(page)
await selectCreditCardOPtion(page)
await selectCreditCardOption(page)
await informCreditCartNumber(page, credit_card.credit_card_number)
await informCreditCartName(page, user.first_name)
await selectExpireDate(page, '3', credit_card.credit_card_year)
await informCVV(page, credit_card.credit_card_cvv)
await finalizeCheckout(page)
await expect(page.getByText('Thank you for your purchase!')).toBeVisible();
await expect(page.getByText('Thank you for your purchase!')).toBeVisible();
})
})
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pagarme_Pagarme" setup_version="2.4.1">
<module name="Pagarme_Pagarme" setup_version="2.4.2">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down
34 changes: 20 additions & 14 deletions view/frontend/web/js/core/checkout/PaymentMethodController.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ define([
subscribeTotal() {
const _self = this;

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

});

formObject.inputAmount.on('keyup', function(){
formObject.inputAmount.on('keyup', function () {
const element = $(this);

const originalValue = paymentMethodController.platformConfig.updateTotals.getTotals()().grand_total;
Expand Down Expand Up @@ -435,10 +435,11 @@ define([
|| element.attr('name').startsWith('payment[cc_exp_year]')
) {
paymentMethodController.validateCcExpDateField(formObject);
return;

}
});
}

addCreditCardNumberListener(formObject) {

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

setTimeout(function() {
paymentMethodController.setBin(binObj, element, formObject);
setTimeout(function () {
paymentMethodController.setBin(binObj, element, formObject);
}, 300);
});
}
Expand All @@ -481,7 +482,7 @@ define([
sumTotal = (sumTotal + sumInterestTotal).toString();
sumInterestTotal = sumInterestTotal.toString();

return { sumTotal, sumInterestTotal };
return {sumTotal, sumInterestTotal};
}

boletoCreditCardTotal(paymentMethod) {
Expand All @@ -500,7 +501,7 @@ define([
}
sumInterestTotal = sumInterestTotal.toString();

return { sumTotal, sumInterestTotal };
return {sumTotal, sumInterestTotal};
}

updateTotalByPaymentMethod(paymentMethod, event) {
Expand Down Expand Up @@ -557,7 +558,7 @@ define([
formHandler.init(formObject);


formObject.savedCreditCardSelect.on('change', function() {
formObject.savedCreditCardSelect.on('change', function () {
const value = $(this).val();
const currentSavedCardBrand = $(this).find(optionSelectedSelector).attr('brand');

Expand Down Expand Up @@ -718,7 +719,7 @@ define([
url: installmentsUrl,
method: 'GET',
cache: true,
}).done(function(data) {
}).done(function (data) {
formHandler = new FormHandler();

if (!data.length) return;
Expand All @@ -731,6 +732,7 @@ define([
formHandler.switchBrand(selectedBrand);
});
}

fillBrandList(formObject, method) {
if (method == undefined) {
method = 'pagarme_creditcard';
Expand All @@ -751,14 +753,15 @@ define([
amount = amount.replace(separator, this.platformConfig.currency.decimalSeparator);

if (card === 1) {
const orderAmountOriginal = amount.replace(this.platformConfig.currency.decimalSeparator, ".");
const orderAmountOriginal = amount.replace(this.platformConfig.currency.decimalSeparator, ".");
const amountBalance = (this.platformConfig.updateTotals.getTotals()().grand_total - orderAmountOriginal).toFixed(2);
formObject.inputAmount.val(amountBalance.replace(".", this.platformConfig.currency.decimalSeparator));
return;
}

formObject.inputAmount.val(amount);
}

validateCcNumberField(element, formObject) {
if (element.val() === '') {
formObject.creditCardBrand.val('');
Expand All @@ -768,12 +771,14 @@ define([
formHandler.switchBrand('');
}
}

validateCcExpDateField(formObject) {
const cardExpirationMonth = formObject.creditCardExpMonth;
const cardExpirationYear = formObject.creditCardExpYear;

const cardDate = new Date(cardExpirationYear.val(), cardExpirationMonth.val() -1);
const dateNow = new Date();
const cardDate = new Date(cardExpirationYear.val(), cardExpirationMonth.val() - 1);
let dateNow = new Date();
dateNow = new Date(dateNow.getFullYear(), dateNow.getMonth());

const monthParentsElements = cardExpirationMonth.parent().parent();
const yearParentsElements = cardExpirationYear.parent().parent();
Expand Down Expand Up @@ -817,6 +822,7 @@ define([

return false;
}

setBin(binObj, creditCardNumberElement, formObject) {

const bin = binObj;
Expand All @@ -838,13 +844,13 @@ define([
this.fillInstallments(formObject);
}

return;

}

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

if(val != "" && val.length > limit) {
if (val != "" && val.length > limit) {
element.val(val.substring(0, limit));
}
}
Expand Down
Loading

0 comments on commit 989bc47

Please sign in to comment.