Skip to content

Commit

Permalink
Release 2.6.1
Browse files Browse the repository at this point in the history
Release 2.6.1
  • Loading branch information
fabiano-mallmann authored Nov 13, 2024
2 parents 157c5b6 + 2d22dea commit bc6bda0
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 145 deletions.
13 changes: 12 additions & 1 deletion Concrete/Magento2PlatformOrderDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,17 @@ public function getQuote()
return $this->quote;
}

/** @return AbstractPayment[] */
/**
* @uses self::extractPaymentDataFromPagarmeCreditCard
* @uses self::extractPaymentDataFromPagarmeVoucher
* @uses self::extractPaymentDataFromPagarmeDebit
* @uses self::extractPaymentDataFromPagarmeTwoCreditCard
* @uses self::extractPaymentDataFromPagarmeBilletCreditcard
* @uses self::extractPaymentDataFromPagarmeGooglePay
* @uses self::extractPaymentDataFromPagarmePix
* @uses self::extractPaymentdataFromPagarmeBillet
* @return AbstractPayment[]
* */
public function getPaymentMethodCollection()
{
$payments = $this->getPaymentCollection();
Expand Down Expand Up @@ -1206,6 +1216,7 @@ private function extractPaymentDataFromPagarmeGooglepay(
$this->moneyService->floatToCents($this->platformOrder->getGrandTotal());
$newPaymentData->googlepayData = $additionalInformation['googlepayData'];
$newPaymentData->additionalInformation = ["googlepayData" => $additionalInformation['googlepayData']];
$newPaymentData->billing_address = $this->getAddress($this->getQuote()->getBillingAddress())->convertToSDKRequest();
$googlepayIndex = 'googlepay';
if (!isset($paymentData[$googlepayIndex])) {
$paymentData[$googlepayIndex] = [];
Expand Down
4 changes: 2 additions & 2 deletions Model/Source/Vouchertype.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*
* @link https://pagar.me
*/

class Vouchertype extends \Magento\Payment\Model\Source\Cctype
{
/**
Expand All @@ -22,7 +21,8 @@ public function getAllowedTypes()
return [
'VR',
'Alelo',
'Sodexo'
'Sodexo',
'Ticket'
];
}
}
161 changes: 38 additions & 123 deletions Model/Ui/Base/GenericInstallmentsConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

namespace Pagarme\Pagarme\Model\Ui\Base;

use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Asset\Repository;
use Pagarme\Pagarme\Model\Installments\Config\ConfigInterface;
use Magento\Store\Model\StoreManagerInterface;
use Pagarme\Pagarme\Gateway\Transaction\Base\Config\ConfigInterface as BaseConfig;
use Magento\Checkout\Model\ConfigProviderInterface;
use \Magento\Store\Model\StoreManagerInterface;
use Pagarme\Pagarme\Model\Installments\Config\ConfigInterface;

abstract class GenericInstallmentsConfigProvider implements ConfigProviderInterface
{
Expand Down Expand Up @@ -48,11 +49,12 @@ abstract class GenericInstallmentsConfigProvider implements ConfigProviderInterf
protected $storageManager;

public function __construct(
Repository $assetRepo,
ConfigInterface $config,
BaseConfig $baseConfig,
Repository $assetRepo,
ConfigInterface $config,
BaseConfig $baseConfig,
StoreManagerInterface $storeManager
) {
)
{
$this->assetRepo = $assetRepo;
$this->baseConfig = $baseConfig;
$this->storageManager = $storeManager;
Expand All @@ -70,129 +72,32 @@ public function getConfig()
'value' => 0,
],
'pk_token' => $this->baseConfig->getPublicKey(),
'icons' => [
'Visa' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Visa.png")
],
'Elo' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Elo.png")
],
'Discover' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Discover.png")
],
'Diners' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Diners.png")
],
'Credz' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Credz.png")
],
'Hipercard' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Hipercard.png")
],
'HiperCard' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Hipercard.png")
],
'Mastercard' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Mastercard.png")
],
'Sodexo' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Sodexo.png")
],
'SodexoAlimentacao' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/SodexoAlimentacao.png")
],
'SodexoCombustivel' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/SodexoCombustivel.png")
],
'SodexoCultura' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/SodexoCultura.png")
],
'SodexoGift' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/SodexoGift.png")
],
'SodexoPremium' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/SodexoPremium.png")
],
'SodexoRefeicao' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/SodexoRefeicao.png")
],
'Cabal' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Cabal.png")
],
'Aura' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Aura.png")
],
'Amex' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Amex.png")
],
'Alelo' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Alelo.png")
],
'VR' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/VR.png")
],
'Banese' => [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/Banese.png")
],
],
'icons' => $this->getBrandImages(),
]
],
'is_multi_buyer_enabled' => $this->_getConfig()->getMultiBuyerActive(),
'region_states' => $this->getRegionStates()
];
}



/**
* @param ConfigInterface $config
* @return $this
* Return all brands and their respective images
* @return array{height: int, width: int, url: string}
*/
protected function setConfig(ConfigInterface $config)
private function getBrandImages()
{
$this->config = $config;
return $this;
$possibleBrands = ["Visa", "Elo", "Discover", "Diners", "Credz", "Hipercard", "HiperCard", "Mastercard",
"Sodexo", "SodexoAlimentacao", "SodexoCombustivel", "SodexoCultura", "SodexoGift", "SodexoPremium",
"SodexoRefeicao", "Cabal", "Aura", "Amex", "Alelo", "VR", "Banese", "Ticket"];
$brands = [];
foreach ($possibleBrands as $brand) {
$brands[$brand] = [
'height' => 30,
'width' => 46,
'url' => $this->assetRepo->getUrl("Pagarme_Pagarme::images/cc/".$brand.".png")
];
}
return $brands;
}

/**
Expand All @@ -203,10 +108,20 @@ protected function _getConfig()
return $this->config;
}

/**
* @param ConfigInterface $config
* @return $this
*/
protected function setConfig(ConfigInterface $config)
{
$this->config = $config;
return $this;
}

protected function getRegionStates()
{
/** @fixme Get current country **/
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/** @fixme Get current country * */
$objectManager = ObjectManager::getInstance();
$states = $objectManager
->create('Magento\Directory\Model\RegionFactory')
->create()->getCollection()->addFieldToFilter('country_id', 'BR');
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "pagarme/pagarme-magento2-module",
"license": "MIT",
"version": "2.6.0",
"version": "2.6.1",
"type": "magento2-module",
"description": "Magento 2 Module Pagar.me",
"require": {
"php": ">=7.1",
"pagarme/ecommerce-module-core": "2.6.*"
"pagarme/ecommerce-module-core": "2.7.0"
},
"require-dev": {
"phpunit/phpunit": "^5 | ^6 | ^7 | ^8 | ^9",
Expand Down
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.6.0">
<module name="Pagarme_Pagarme" setup_version="2.6.1">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down
6 changes: 5 additions & 1 deletion etc/payment.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" ?>
<payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Payment:etc/payment.xsd">
<payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Payment:etc/payment.xsd">

<methods>
<method name="pagarme_billet">
Expand Down Expand Up @@ -95,6 +96,9 @@
<type id="Sodexo" order="20">
<label>Sodexo</label>
</type>
<type id="Ticket" order="21">
<label>Ticket</label>
</type>

<!-- Billet -->
<type id="Itau" order="28">
Expand Down
Binary file added view/base/web/images/cc/Ticket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions view/frontend/web/js/core/checkout/PaymentMethodController.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ define([
totalAmount += parseFloat(amount);
}

if (totalAmount === _self.platformConfig.updateTotals.getTotals()().grand_total) {
if (totalAmount === _self.platformConfig.updateTotals.getTotals()().base_grand_total) {
return;
}

Expand Down Expand Up @@ -392,7 +392,7 @@ define([
formObject.inputAmount.on('keyup', function () {
const element = $(this);

const originalValue = paymentMethodController.platformConfig.updateTotals.getTotals()().grand_total;
const originalValue = paymentMethodController.platformConfig.updateTotals.getTotals()().base_grand_total;
let orderAmount = (originalValue).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
orderAmount = orderAmount.replace(/[^0-9]/g, '');
orderAmount = Number(orderAmount);
Expand Down Expand Up @@ -754,7 +754,7 @@ define([
}

fillCardAmount(formObject, count, card = null) {
const orderAmount = this.platformConfig.updateTotals.getTotals()().grand_total / count;
const orderAmount = this.platformConfig.updateTotals.getTotals()().base_grand_total / count;

let amount = orderAmount.toFixed(this.platformConfig.currency.precision);
const separator = ".";
Expand All @@ -763,7 +763,7 @@ define([

if (card === 1) {
const orderAmountOriginal = amount.replace(this.platformConfig.currency.decimalSeparator, ".");
const amountBalance = (this.platformConfig.updateTotals.getTotals()().grand_total - orderAmountOriginal).toFixed(2);
const amountBalance = (this.platformConfig.updateTotals.getTotals()().base_grand_total - orderAmountOriginal).toFixed(2);
formObject.inputAmount.val(amountBalance.replace(".", this.platformConfig.currency.decimalSeparator));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/core/checkout/Tds.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ define([
phones : customerPhones,
card_expiry_date : cardExpiryDate,
purchase : {
amount : quote.totals().grand_total * 100,
amount : quote.totals().base_grand_total * 100,
date :
new Date().toISOString()
,
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/core/models/CreditCardModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ define([
const configCard = window.checkoutConfig.payment.pagarme_creditcard;

return configCard['tds_active'] === true
&& quote.totals().grand_total * 100 >= configCard['tds_min_amount'] * 100
&& quote.totals().base_grand_total * 100 >= configCard['tds_min_amount'] * 100
&& this.brandIsVisaOrMaster();
}
brandIsVisaOrMaster() {
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/js/view/payment/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ define(
const platFormConfig = window.checkoutConfig;
platFormConfig.moduleUrls = {};
const installmentsUrl = installmentsAction();
platFormConfig.grand_total = quote.getTotals()().grand_total;
platFormConfig.grand_total = quote.getTotals()().base_grand_total;

const baseUrl = platFormConfig.payment.ccform.base_url;

Expand Down
Loading

0 comments on commit bc6bda0

Please sign in to comment.