diff --git a/Block/Payment/Billet.php b/Block/Payment/Billet.php index db232e8b..1b4cda19 100644 --- a/Block/Payment/Billet.php +++ b/Block/Payment/Billet.php @@ -67,6 +67,7 @@ protected function getPayment() public function getBilletUrl() { $billetHelper = new BilletHelper(); - return $billetHelper->getBilletUrl($this->getPayment()); + $pagarmeTransaction = $this->checkoutSession->getPixOrBilletTransaction(); + return $billetHelper->getBilletUrl($this->getPayment(), $pagarmeTransaction); } } diff --git a/Block/Payment/Pix.php b/Block/Payment/Pix.php index ee71fea9..66eea890 100644 --- a/Block/Payment/Pix.php +++ b/Block/Payment/Pix.php @@ -1,6 +1,6 @@ checkoutSession = $checkoutSession; $this->pixHelper = $pixHelper; + $this->assetRepository = $assetRepository; parent::__construct($context, []); } @@ -85,6 +101,14 @@ public function showPixInformation() return !empty($this->getPixInfo()); } + /** + * @return string + */ + public function getLogoSrc() + { + return $this->assetRepository->getUrl(PixHelper::LOGO_URL); + } + /** * @return string */ @@ -94,7 +118,7 @@ public function getErrorCopyMessage() } /** - * @return string + * @return Phrase */ public function getSuccessMessage() { @@ -103,11 +127,13 @@ public function getSuccessMessage() /** * @return PixHelper + * @throws Exception */ public function getPixInfo() { + $pagarmeTransaction = $this->checkoutSession->getPixOrBilletTransaction(); if (empty($this->pixInfo)) { - $this->pixInfo = $this->pixHelper->getInfo($this->getPayment()); + $this->pixInfo = $this->pixHelper->getInfo($this->getPayment(), $pagarmeTransaction); } return $this->pixInfo; diff --git a/Concrete/Magento2PlatformOrderDecorator.php b/Concrete/Magento2PlatformOrderDecorator.php index e32b537b..6db33ffb 100644 --- a/Concrete/Magento2PlatformOrderDecorator.php +++ b/Concrete/Magento2PlatformOrderDecorator.php @@ -1122,30 +1122,11 @@ private function extractPaymentDataFromPagarmeBilletCreditcard( $paymentData[$creditCardDataIndex][] = $newPaymentData; - //boleto - - $newPaymentData = new stdClass(); - - $amount = str_replace( - ['.', ','], - "", - $additionalInformation["cc_billet_amount"] ?? '' + $this->extractPaymentDataFromPagarmeBillet( + $additionalInformation, + $paymentData, + $payment ); - - $newPaymentData->amount = - $this->moneyService->floatToCents($amount / 100); - - $boletoDataIndex = BoletoPayment::getBaseCode(); - if (!isset($paymentData[$boletoDataIndex])) { - $paymentData[$boletoDataIndex] = []; - } - - $newPaymentData->customer = $this->extractMultibuyerData( - 'billet', - $additionalInformation - ); - - $paymentData[$boletoDataIndex][] = $newPaymentData; } private function extractPaymentDataFromPagarmeBillet( @@ -1154,17 +1135,21 @@ private function extractPaymentDataFromPagarmeBillet( $payment ) { $newPaymentData = new stdClass(); + $amount = $this->platformOrder->getGrandTotal(); + if (isset($additionalInformation["cc_billet_amount"])) { + $amount = $this->moneyService->removeSeparators($additionalInformation["cc_billet_amount"]) / 100; + } $newPaymentData->amount = - $this->moneyService->floatToCents($this->platformOrder->getGrandTotal()); + $this->moneyService->floatToCents($amount); $moduleConfiguration = MPSetup::getModuleConfiguration(); $newPaymentData->instructions = $moduleConfiguration->getBoletoInstructions(); $bankConfig = new Bank(); - $bankNumber = $bankConfig->getBankNumber(MPSetup::getModuleConfiguration()->getBoletoBankCode()); + $bankNumber = $bankConfig->getBankNumber($moduleConfiguration->getBoletoBankCode()); if ($bankNumber) { $newPaymentData->bank = $bankNumber; } $expirationDate = new \DateTime(); - $days = MPSetup::getModuleConfiguration()->getBoletoDueDays(); + $days = $moduleConfiguration->getBoletoDueDays(); if ($days) { $expirationDate->modify("+{$days} day"); } diff --git a/Gateway/Transaction/Base/Command/InitializeCommand.php b/Gateway/Transaction/Base/Command/InitializeCommand.php index 4b540498..359291cd 100755 --- a/Gateway/Transaction/Base/Command/InitializeCommand.php +++ b/Gateway/Transaction/Base/Command/InitializeCommand.php @@ -12,6 +12,7 @@ namespace Pagarme\Pagarme\Gateway\Transaction\Base\Command; +use Magento\Checkout\Model\Session as CheckoutSession; use Magento\Payment\Gateway\Helper\SubjectReader; use Magento\Sales\Model\Order; use Magento\Sales\Api\Data\OrderInterface; @@ -28,25 +29,27 @@ use Pagarme\Pagarme\Model\Ui\TwoCreditCard\ConfigProvider as TwoCreditCardConfigProvider; use Magento\Framework\Phrase; use Magento\Framework\Webapi\Exception as M2WebApiException; -use Pagarme\Pagarme\Helper\RecurrenceProductHelper; -use Pagarme\Pagarme\Gateway\Transaction\Base\Config\Config; use Pagarme\Pagarme\Service\Transaction\ThreeDSService; class InitializeCommand implements CommandInterface { - protected $config; /** * @var ThreeDSService */ protected $threeDSService; + /** + * @var CheckoutSession + */ + protected $checkoutSession; public function __construct( - Config $config, - ThreeDSService $threeDSService - ){ - $this->config = $config; + ThreeDSService $threeDSService, + CheckoutSession $checkoutSession + ) + { $this->threeDSService = $threeDSService; + $this->checkoutSession = $checkoutSession; } /** @@ -110,10 +113,7 @@ public function execute(array $commandSubject) /** @return AbstractPlatformOrderDecorator */ private function doCoreDetour($payment) { - $order = $payment->getOrder(); - if($this->config->getAlwaysCreateOrder()){ - $order->save(); - } + $order = $payment->getOrder(); $log = new OrderLogService(); Magento2CoreSetup::bootstrap(); @@ -168,7 +168,11 @@ private function doCoreDetour($payment) if (!$isSubscription) { $orderService = new OrderService(); - $orderService->createOrderAtPagarme($orderDecorator); + $pagarmeOrder = current($orderService->createOrderAtPagarme($orderDecorator)); + $transaction = $pagarmeOrder->getPixOrBilletTransaction(); + if (!is_null($transaction)) { + $this->checkoutSession->setPixOrBilletTransaction($transaction); + } } $orderDecorator->save(); diff --git a/Helper/Payment/Billet.php b/Helper/Payment/Billet.php index 81ca0f9d..20f5b1c7 100644 --- a/Helper/Payment/Billet.php +++ b/Helper/Payment/Billet.php @@ -9,25 +9,25 @@ use Pagarme\Core\Recurrence\Repositories\SubscriptionRepository; class Billet { - - public function getBilletUrl($info) + + public function getBilletUrl($info, $transaction = null) { $method = $info->getMethod(); if (strpos($method, "pagarme_billet") === false) { return; } - + Magento2CoreSetup::bootstrap(); - $boletoUrl = $this->getBoletoLinkFromOrder($info); + $boletoUrl = $this->getBoletoLinkFromOrder($info, $transaction); if (!$boletoUrl) { $boletoUrl = $this->getBoletoLinkFromSubscription($info); } - + return $boletoUrl; } - private function getBoletoLinkFromOrder($info) + private function getBoletoLinkFromOrder($info, $transaction = null) { $lastTransId = $info->getLastTransId(); $orderId = null; @@ -35,6 +35,10 @@ private function getBoletoLinkFromOrder($info) $orderId = substr($lastTransId, 0, 19); } + if (!$orderId && !is_null($transaction)) { + return $transaction->getBoletoUrl(); + } + if (!$orderId) { return null; } @@ -79,4 +83,4 @@ private function getBoletoLinkFromSubscription($info) return null; } - } \ No newline at end of file + } diff --git a/Helper/Payment/Pix.php b/Helper/Payment/Pix.php index 19d66213..83f9e761 100644 --- a/Helper/Payment/Pix.php +++ b/Helper/Payment/Pix.php @@ -2,19 +2,23 @@ namespace Pagarme\Pagarme\Helper\Payment; +use Exception; use Pagarme\Pagarme\Concrete\Magento2CoreSetup; use Pagarme\Core\Kernel\ValueObjects\Id\OrderId; use Pagarme\Core\Payment\Services\OrderService; class Pix { + const LOGO_URL = "Pagarme_Pagarme::images/logo-pix.svg"; + private $qrCodeUrl; private $qrCode; /** * @return $this + * @throws Exception */ - public function getInfo($info) + public function getInfo($info, $transaction = null) { $orderId = null; $method = $info->getMethod(); @@ -27,6 +31,12 @@ public function getInfo($info) $orderId = substr($lastTransId, 0, 19); } + if (!$orderId && !is_null($transaction)) { + $this->setQrCode($transaction->getPostData()->qr_code); + $this->setQrCodeUrl($transaction->getPostData()->qr_code_url); + return $this; + } + Magento2CoreSetup::bootstrap(); $orderService = new OrderService(); $qrCodeData = $orderService->getPixQrCodeInfoFromOrder(new OrderId($orderId)); diff --git a/Model/Notifications.php b/Model/Notifications.php index 9680ae10..28a946b2 100644 --- a/Model/Notifications.php +++ b/Model/Notifications.php @@ -212,7 +212,7 @@ private function addDashSettingsMessages() CoreAccount::DOMAIN_INCORRECT => sprintf( __('The registered domain is different from the URL of your website. Please correct the ' . 'domain configured on the %s to be able to process payment in your store.'), - $this->buildDashLink($linkLabel, $linkAccount), + $this->buildDashLink($linkLabel, $linkAccount) ), CoreAccount::WEBHOOK_INCORRECT => sprintf( __('The URL for receiving webhooks registered in Pagar.me Dash is different from the URL of ' diff --git a/Model/Ui/Pix/ConfigProvider.php b/Model/Ui/Pix/ConfigProvider.php index 655e6f41..799c1646 100644 --- a/Model/Ui/Pix/ConfigProvider.php +++ b/Model/Ui/Pix/ConfigProvider.php @@ -3,8 +3,10 @@ namespace Pagarme\Pagarme\Model\Ui\Pix; use Magento\Checkout\Model\ConfigProviderInterface; +use Magento\Framework\View\Asset\Repository; use Pagarme\Core\Kernel\ValueObjects\Configuration\PixConfig; use Pagarme\Pagarme\Concrete\Magento2CoreSetup as MPSetup; +use Pagarme\Pagarme\Helper\Payment\Pix as PixHelper; final class ConfigProvider implements ConfigProviderInterface { @@ -15,10 +17,16 @@ final class ConfigProvider implements ConfigProviderInterface */ private $pixConfig; - public function __construct() + /** + * @var Repository + */ + private $assetRepository; + + public function __construct(Repository $assetRepository) { MPSetup::bootstrap(); $moduleConfig = MPSetup::getModuleConfiguration(); + $this->assetRepository = $assetRepository; if (!empty($moduleConfig->getPixConfig())) { $this->pixConfig = $moduleConfig->getPixConfig(); } @@ -31,6 +39,7 @@ public function getConfig() self::CODE => [ 'active' => $this->pixConfig->isEnabled(), 'title' => $this->pixConfig->getTitle(), + 'logo' => $this->assetRepository->getUrl(PixHelper::LOGO_URL) ] ] ]; diff --git a/composer.json b/composer.json index bab98d0d..973348f4 100755 --- a/composer.json +++ b/composer.json @@ -1,12 +1,12 @@ { "name": "pagarme/pagarme-magento2-module", "license": "MIT", - "version": "2.4.0", + "version": "2.4.1", "type": "magento2-module", "description": "Magento 2 Module Pagar.me", "require": { "php": ">=7.1", - "pagarme/ecommerce-module-core": "2.4.*" + "pagarme/ecommerce-module-core": "~2.4.1" }, "require-dev": { "phpunit/phpunit": "^5 | ^6 | ^7 | ^8 | ^9", diff --git a/etc/module.xml b/etc/module.xml index cf6ccf1d..2e09252e 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -9,7 +9,7 @@ */ --> - + diff --git a/view/base/web/images/logo-pix.svg b/view/base/web/images/logo-pix.svg new file mode 100644 index 00000000..fd11eba6 --- /dev/null +++ b/view/base/web/images/logo-pix.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/view/frontend/templates/payment/pix.phtml b/view/frontend/templates/payment/pix.phtml index b5ed2f6e..0f0bcc49 100644 --- a/view/frontend/templates/payment/pix.phtml +++ b/view/frontend/templates/payment/pix.phtml @@ -8,8 +8,8 @@ if ($block->showPixInformation()):
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 @@
- +