diff --git a/view/frontend/web/css/pagarme_style.css b/view/frontend/web/css/pagarme_style.css
index 64340703..917eaaa4 100644
--- a/view/frontend/web/css/pagarme_style.css
+++ b/view/frontend/web/css/pagarme_style.css
@@ -23,7 +23,8 @@
display: none;
}
-.hidden-element {
+.field.hidden-element,
+.field-error.hidden-element {
display: none;
}
@@ -36,3 +37,7 @@
.field .control .cc_owner {
width: 225px;
}
+
+.pagarme-pix-logo {
+ width: 120px;
+}
\ No newline at end of file
diff --git a/view/frontend/web/css/pagarme_success_page.css b/view/frontend/web/css/pagarme_success_page.css
index 5a44a7ad..8a5cdcb4 100644
--- a/view/frontend/web/css/pagarme_success_page.css
+++ b/view/frontend/web/css/pagarme_success_page.css
@@ -63,3 +63,7 @@
padding: 10px 15px;
margin-top: 10px;
}
+
+.pagarme-pix-logo {
+ width: 120px;
+}
\ No newline at end of file
diff --git a/view/frontend/web/js/action/creditcard/create-card-id.js b/view/frontend/web/js/action/creditcard/create-card-id.js
deleted file mode 100644
index 1ce14395..00000000
--- a/view/frontend/web/js/action/creditcard/create-card-id.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * @author Open Source Team
- * @copyright 2021 Pagar.me (https://pagar.me)
- * @license https://pagar.me Copyright
- *
- * @link https://pagar.me
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'mage/storage',
- 'Magento_Checkout/js/model/url-builder',
- 'mage/url'
- ],
- function (
- $,
- storage,
- urlBuilder,
- mageUrl
- ) {
-
- return function (data, customer_id) {
- var serviceUrl = 'https://api.mundipagg.com/core/v1/customers/' + customer_id + '/cards';
-
- return $.ajax({
- method: "POST",
- beforeSend: function(request) {
- request.setRequestHeader("Content-type", 'application/json');
- request.setRequestHeader("Accept", 'application/json');
- request.setRequestHeader("Authorization", 'Basic c2tfdGVzdF83WjRrYWtkUGhtc1FyQUdtOg==');
- request.setRequestHeader("Access-Control-Allow-Origin", '*');
- // request.setRequestHeader("Access-Control-Request-Headers", 'Content-Type, Authorization');
- // Access-Control-Request-Headers: Content-Type, Authorization'
- },
- url: serviceUrl,
- cache: false,
- crossDomain: true,
- data: data
- });
- };
- }
-);
diff --git a/view/frontend/web/js/action/creditcard/customer-create.js b/view/frontend/web/js/action/creditcard/customer-create.js
deleted file mode 100644
index ece4ce39..00000000
--- a/view/frontend/web/js/action/creditcard/customer-create.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @author Open Source Team
- * @copyright 2021 Pagar.me (https://pagar.me)
- * @license https://pagar.me Copyright
- *
- * @link https://pagar.me
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'mage/storage',
- 'Magento_Checkout/js/model/url-builder',
- 'mage/url'
- ],
- function (
- $,
- storage,
- urlBuilder,
- mageUrl
- ) {
-
- return function (data) {
- var serviceUrl;
- serviceUrl = urlBuilder.createUrl('/pagarme/customer/create/', {});
-
- return $.ajax({
- method: "POST",
- beforeSend: function(request) {
- request.setRequestHeader("Content-type", 'application/json');
- },
- url: mageUrl.build(serviceUrl),
- cache: false,
- data: JSON.stringify(data)
- });
- };
- }
-);
diff --git a/view/frontend/web/js/action/creditcard/token.js b/view/frontend/web/js/action/creditcard/token.js
deleted file mode 100644
index d53bcb1f..00000000
--- a/view/frontend/web/js/action/creditcard/token.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * @author Open Source Team
- * @copyright 2021 Pagar.me (https://pagar.me)
- * @license https://pagar.me Copyright
- *
- * @link https://pagar.me
- */
-/*browser:true*/
-/*global define*/
-define(
- [
- 'jquery',
- 'mage/storage',
- 'Magento_Checkout/js/model/url-builder'
- ],
- function (
- $,
- storage,
- urlBuilder
- ) {
- return function (dataJson, successCallback, failCallback) {
- var self = this;
- var serviceUrl = 'https://api.mundipagg.com/core/v1/tokens?appId=' + window.checkoutConfig.payment.ccform.pk_token;
-
- var getAPIData = function(url, data, success, fail) {
- var xhr = new XMLHttpRequest();
- xhr.open('POST', url);
- xhr.onreadystatechange = function() {
- if (xhr.readyState < 4) {
- return;
- }
- if (xhr.status === 200) {
- success.call(self, JSON.parse(xhr.responseText));
- } else {
- var errorObj = JSON.parse(xhr.response);
- errorObj.statusCode = xhr.status;
- fail.call(null, errorObj);
- }
- };
- xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
- xhr.send(JSON.stringify(data));
- return xhr;
- };
-
- getAPIData(serviceUrl, dataJson, successCallback, failCallback);
- };
- }
-);
diff --git a/view/frontend/web/js/core/checkout/PaymentMethodController.js b/view/frontend/web/js/core/checkout/PaymentMethodController.js
index d2879915..9bc6c10a 100644
--- a/view/frontend/web/js/core/checkout/PaymentMethodController.js
+++ b/view/frontend/web/js/core/checkout/PaymentMethodController.js
@@ -45,7 +45,7 @@ define([
}
formObject(formObject) {
- this.formObject = formObject
+ this.formObject = formObject;
}
formValidation() {
@@ -94,6 +94,22 @@ define([
this.platformConfig.updateTotals.totals.subscribe(function(){
if (_self.methodCode === 'twocreditcards' || _self.methodCode === 'boletoCreditcard') {
+ let totalAmount = 0;
+ const separator = '.';
+ for (let i = 0, len = _self.formObject.numberOfPaymentForms; i < len; i++) {
+ let amount = _self.formObject[i].inputAmount.val();
+ if (amount === undefined) {
+ continue;
+ }
+ amount = amount.replace(_self.platformConfig.currency.decimalSeparator, separator);
+
+ totalAmount += parseFloat(amount);
+ }
+
+ if (totalAmount === _self.platformConfig.updateTotals.getTotals()().grand_total) {
+ return;
+ }
+
for (let i = 0, len = _self.formObject.numberOfPaymentForms; i < len; i++) {
_self.fillCardAmount(_self.formObject[i], 2, i);
_self.fillInstallments(_self.formObject[i]);
@@ -360,7 +376,7 @@ define([
formObject.inputAmount.on('keyup', function(){
const element = $(this);
- const originalValue = paymentMethodController.platformConfig.updateTotals.getTotals()().grand_total
+ const originalValue = paymentMethodController.platformConfig.updateTotals.getTotals()().grand_total;
let orderAmount = (originalValue).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
orderAmount = orderAmount.replace(/[^0-9]/g, '');
orderAmount = Number(orderAmount);
@@ -479,6 +495,9 @@ define([
let sumTotal = (parseFloat(valueCard) + parseFloat(valueBoleto));
sumTotal = (sumTotal + parseFloat(sumInterestTotal)).toString();
+ if (sumInterestTotal === undefined) {
+ sumInterestTotal = 0.0;
+ }
sumInterestTotal = sumInterestTotal.toString();
return { sumTotal, sumInterestTotal };
@@ -683,7 +702,7 @@ define([
let amount = form.inputAmount.val();
if (!selectedBrand || selectedBrand === 'default') {
formHandler.updateInstallmentSelect([], form.creditCardInstallments);
- return
+ return;
}
if (typeof amount == "undefined") {
diff --git a/view/frontend/web/js/core/checkout/PaymentModuleBootstrap.js b/view/frontend/web/js/core/checkout/PaymentModuleBootstrap.js
index 879d8fbb..c0e4344b 100644
--- a/view/frontend/web/js/core/checkout/PaymentModuleBootstrap.js
+++ b/view/frontend/web/js/core/checkout/PaymentModuleBootstrap.js
@@ -44,7 +44,7 @@ define([
);
PagarmeCore.paymentMethod[model].placeOrder(platformOrderPlace);
} catch (e) {
- console.log(e)
+ console.log(e);
}
}
diff --git a/view/frontend/web/js/core/checkout/PlatformFormHandler.js b/view/frontend/web/js/core/checkout/PlatformFormHandler.js
index df4c8da1..0f4321de 100644
--- a/view/frontend/web/js/core/checkout/PlatformFormHandler.js
+++ b/view/frontend/web/js/core/checkout/PlatformFormHandler.js
@@ -132,7 +132,7 @@ define(['jquery'], ($) => {
}
fillSavedCreditCardsSelect = function (platformConfig, formObject) {
let html = '';
- const cards = platformConfig.savedAllCards[formObject.savedCardSelectUsed]
+ const cards = platformConfig.savedAllCards[formObject.savedCardSelectUsed];
let firstOptionValue = null;
const brands = [];
diff --git a/view/frontend/web/js/core/checkout/Tds.js b/view/frontend/web/js/core/checkout/Tds.js
index d6d611a6..1a4ff403 100644
--- a/view/frontend/web/js/core/checkout/Tds.js
+++ b/view/frontend/web/js/core/checkout/Tds.js
@@ -24,7 +24,7 @@ define([
}
callTdsFunction(tdsToken, tdsData, callbackTds) {
- const challengeWindowSize = '03'
+ const challengeWindowSize = '03';
Script3ds.init3ds(tdsToken, tdsData, callbackTds, challengeWindowSize);
}
@@ -45,24 +45,24 @@ define([
addTdsAttributeData() {
const cardForm = this.formObject;
- jQuery(cardForm.containerSelector).attr("data-pagarmecheckout-form", "")
- cardForm.creditCardHolderName.attr("data-pagarmecheckout-element", "holder_name")
- cardForm.creditCardNumber.attr("data-pagarmecheckout-element", "number")
- cardForm.creditCardBrand.attr("data-pagarmecheckout-element", "brand")
- cardForm.creditCardExpMonth.attr("data-pagarmecheckout-element", "exp_month")
- cardForm.creditCardExpYear.attr("data-pagarmecheckout-element", "exp_year")
- cardForm.creditCardCvv.attr("data-pagarmecheckout-element", "cvv")
+ jQuery(cardForm.containerSelector).attr("data-pagarmecheckout-form", "");
+ cardForm.creditCardHolderName.attr("data-pagarmecheckout-element", "holder_name");
+ cardForm.creditCardNumber.attr("data-pagarmecheckout-element", "number");
+ cardForm.creditCardBrand.attr("data-pagarmecheckout-element", "brand");
+ cardForm.creditCardExpMonth.attr("data-pagarmecheckout-element", "exp_month");
+ cardForm.creditCardExpYear.attr("data-pagarmecheckout-element", "exp_year");
+ cardForm.creditCardCvv.attr("data-pagarmecheckout-element", "cvv");
}
removeTdsAttributeData() {
const cardForm = this.formObject;
- jQuery(cardForm.containerSelector).removeAttr("data-pagarmecheckout-form")
- cardForm.creditCardHolderName.removeAttr("data-pagarmecheckout-element")
- cardForm.creditCardNumber.removeAttr("data-pagarmecheckout-element")
- cardForm.creditCardBrand.removeAttr("data-pagarmecheckout-element")
- cardForm.creditCardExpMonth.removeAttr("data-pagarmecheckout-element")
- cardForm.creditCardExpYear.removeAttr("data-pagarmecheckout-element")
- cardForm.creditCardCvv.removeAttr("data-pagarmecheckout-element")
+ jQuery(cardForm.containerSelector).removeAttr("data-pagarmecheckout-form");
+ cardForm.creditCardHolderName.removeAttr("data-pagarmecheckout-element");
+ cardForm.creditCardNumber.removeAttr("data-pagarmecheckout-element");
+ cardForm.creditCardBrand.removeAttr("data-pagarmecheckout-element");
+ cardForm.creditCardExpMonth.removeAttr("data-pagarmecheckout-element");
+ cardForm.creditCardExpYear.removeAttr("data-pagarmecheckout-element");
+ cardForm.creditCardCvv.removeAttr("data-pagarmecheckout-element");
}
getTdsData(acctType, cardExpiryDate) {
@@ -82,7 +82,7 @@ define([
let customerEmail = window.checkoutConfig.customerData?.email;
if(quote.guestEmail) {
- customerEmail = quote.guestEmail
+ customerEmail = quote.guestEmail;
}
const customerPhones =
diff --git a/view/frontend/web/js/core/models/BoletoCreditcardModel.js b/view/frontend/web/js/core/models/BoletoCreditcardModel.js
index a5ad6101..0b64f1e0 100644
--- a/view/frontend/web/js/core/models/BoletoCreditcardModel.js
+++ b/view/frontend/web/js/core/models/BoletoCreditcardModel.js
@@ -116,12 +116,6 @@ define([
'cc_cc_amount': this.formObject[1].inputAmount.val(),
'cc_cc_tax_amount': this.formObject[1].creditCardInstallments.find(':selected').attr('interest'),
'cc_type': this.formObject[1].creditCardBrand.val(),
- 'cc_last_4': this.getLastFourNumbers(1),
- 'cc_cid': this.formObject[1].creditCardCvv.val(),
- 'cc_ss_start_year': this.formObject[1].creditCardExpYear.val(),
- 'cc_ss_start_month': this.formObject[1].creditCardExpMonth.val(),
- 'cc_number': this.formObject[1].creditCardNumber.val(),
- 'cc_owner': this.formObject[1].creditCardHolderName.val(),
'cc_savecard': saveThiscard,
'cc_saved_card': this.formObject[1].savedCreditCardSelect.val(),
'cc_installments': this.formObject[1].creditCardInstallments.val(),
diff --git a/view/frontend/web/js/core/models/CreditCardModel.js b/view/frontend/web/js/core/models/CreditCardModel.js
index 593e757c..31b245d2 100644
--- a/view/frontend/web/js/core/models/CreditCardModel.js
+++ b/view/frontend/web/js/core/models/CreditCardModel.js
@@ -26,12 +26,12 @@ define([
}
if(this.canTdsRun()) {
- const tds = new Tds(this.formObject)
+ const tds = new Tds(this.formObject);
tds.addTdsAttributeData();
jQuery('body').trigger('processStart');
this.getCreditCardTdsToken(
function (tdsToken) {
- _self.initTds(tdsToken)
+ _self.initTds(tdsToken);
},
function(error) {
jQuery('body').trigger('processStop');
@@ -87,17 +87,17 @@ define([
return configCard['tds_active'] === true
&& quote.totals().grand_total * 100 >= configCard['tds_min_amount'] * 100
- && this.brandIsVisaOrMaster()
+ && this.brandIsVisaOrMaster();
}
brandIsVisaOrMaster() {
return this.formObject.creditCardBrand.val() === "visa"
- || this.formObject.creditCardBrand.val() === "mastercard"
+ || this.formObject.creditCardBrand.val() === "mastercard";
}
initTds(tdsToken) {
- const modelTds = new Tds(this.formObject)
- const expYear = this.formObject.creditCardExpYear.val()
- const expMonth = this.formObject.creditCardExpMonth.val().padStart(2, '0')
- const cardExpiryDate = `${expYear}-${expMonth}`
+ const modelTds = new Tds(this.formObject);
+ const expYear = this.formObject.creditCardExpYear.val();
+ const expMonth = this.formObject.creditCardExpMonth.val().padStart(2, '0');
+ const cardExpiryDate = `${expYear}-${expMonth}`;
const tdsData = modelTds.getTdsData('02', cardExpiryDate);
modelTds.callTdsFunction(tdsToken, tdsData, this.callbackTds.bind(this));
}
diff --git a/view/frontend/web/js/core/models/TwoCreditcardsModel.js b/view/frontend/web/js/core/models/TwoCreditcardsModel.js
index 72500e98..6eefa103 100644
--- a/view/frontend/web/js/core/models/TwoCreditcardsModel.js
+++ b/view/frontend/web/js/core/models/TwoCreditcardsModel.js
@@ -166,12 +166,6 @@ define([
'cc_first_card_amount': this.formObject[0].inputAmount.val(),
'cc_first_card_tax_amount': this.formObject[0].creditCardInstallments.find(':selected').attr('interest'),
'cc_type_first': this.formObject[0].creditCardBrand.val(),
- 'cc_last_4_first': this.getLastFourNumbers(0),
- 'cc_cid_first': this.formObject[0].creditCardCvv.val(),
- 'cc_exp_year_first': this.formObject[0].creditCardExpYear.val(),
- 'cc_exp_month_first': this.formObject[0].creditCardExpMonth.val(),
- 'cc_number_first': this.formObject[0].creditCardNumber.val(),
- 'cc_owner_first': this.formObject[0].creditCardHolderName.val(),
'cc_savecard_first' : saveFirstCard,
'cc_saved_card_first' : this.formObject[0].savedCreditCardSelect.val(),
'cc_installments_first': this.formObject[0].creditCardInstallments.val(),
@@ -180,12 +174,6 @@ define([
'cc_second_card_amount': this.formObject[1].inputAmount.val(),
'cc_second_card_tax_amount': this.formObject[1].creditCardInstallments.find(':selected').attr('interest'),
'cc_type_second': this.formObject[1].creditCardBrand.val(),
- 'cc_last_4_second': this.getLastFourNumbers(1),
- 'cc_cid_second': this.formObject[1].creditCardCvv.val(),
- 'cc_exp_year_second': this.formObject[1].creditCardExpYear.val(),
- 'cc_exp_month_second': this.formObject[1].creditCardExpMonth.val(),
- 'cc_number_second': this.formObject[1].creditCardNumber.val(),
- 'cc_owner_second': this.formObject[1].creditCardHolderName.val(),
'cc_savecard_second' : saveSecondCard,
'cc_saved_card_second' : this.formObject[1].savedCreditCardSelect.val(),
'cc_installments_second': this.formObject[1].creditCardInstallments.val(),
diff --git a/view/frontend/web/js/view/payment/default.js b/view/frontend/web/js/view/payment/default.js
index 0b9498d1..80800615 100644
--- a/view/frontend/web/js/view/payment/default.js
+++ b/view/frontend/web/js/view/payment/default.js
@@ -72,7 +72,7 @@ define(
typeof quote.billingAddress() != "undefined" &&
quote.billingAddress().vatId == ""
) {
- quote.billingAddress().vatId = platFormConfig.customerData.taxvat
+ quote.billingAddress().vatId = platFormConfig.customerData.taxvat;
}
platFormConfig.base_url = baseUrl;
@@ -117,7 +117,7 @@ define(
},
getKey : function() {
- return window.checkoutConfig.payment.ccform.pk_token
+ return window.checkoutConfig.payment.ccform.pk_token;
},
/**
diff --git a/view/frontend/web/js/view/payment/pix.js b/view/frontend/web/js/view/payment/pix.js
index 4229a85a..d0604c37 100644
--- a/view/frontend/web/js/view/payment/pix.js
+++ b/view/frontend/web/js/view/payment/pix.js
@@ -37,6 +37,9 @@ define(
getModel: function () {
return 'pix';
},
+ getLogoSrc: function() {
+ return window.checkoutConfig.payment.pagarme_pix.logo;
+ },
getData: function () {
var paymentMethod = PagarmeCore.paymentMethod[this.getModel()];
diff --git a/view/frontend/web/template/payment/pix-form.html b/view/frontend/web/template/payment/pix-form.html
index ea16b1eb..baf63485 100644
--- a/view/frontend/web/template/payment/pix-form.html
+++ b/view/frontend/web/template/payment/pix-form.html
@@ -12,7 +12,7 @@
-