Skip to content

Commit

Permalink
fix: pix logo in checkout and success page
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateus Picoloto committed Mar 5, 2024
1 parent 836a804 commit 72a7757
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 7 deletions.
28 changes: 25 additions & 3 deletions Block/Payment/Pix.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Framework\View\Asset\Repository;
use Magento\Sales\Api\Data\OrderInterface as Order;
use Magento\Sales\Api\Data\OrderPaymentInterface as Payment;
use Pagarme\Pagarme\Helper\Payment\Pix as PixHelper;
Expand All @@ -38,14 +39,27 @@ class Pix extends Template
private $pixHelper;

/**
* Link constructor.
* @var Repository
*/
private $assetRepository;

/**
* Pix constructor
*
* @param Context $context
* @param CheckoutSession $checkoutSession
* @param PixHelper $pixHelper
* @param Repository $assetRepository
*/
public function __construct(Context $context, CheckoutSession $checkoutSession, PixHelper $pixHelper)
{
public function __construct(
Context $context,
CheckoutSession $checkoutSession,
PixHelper $pixHelper,
Repository $assetRepository
) {
$this->checkoutSession = $checkoutSession;
$this->pixHelper = $pixHelper;
$this->assetRepository = $assetRepository;
parent::__construct($context, []);
}

Expand Down Expand Up @@ -87,6 +101,14 @@ public function showPixInformation()
return !empty($this->getPixInfo());
}

/**
* @return string
*/
public function getLogoSrc()
{
return $this->assetRepository->getUrl(PixHelper::LOGO_URL);
}

/**
* @return string
*/
Expand Down
2 changes: 2 additions & 0 deletions Helper/Payment/Pix.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

class Pix
{
const LOGO_URL = "Pagarme_Pagarme::images/logo-pix.svg";

private $qrCodeUrl;
private $qrCode;

Expand Down
11 changes: 10 additions & 1 deletion Model/Ui/Pix/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();
}
Expand All @@ -31,6 +39,7 @@ public function getConfig()
self::CODE => [
'active' => $this->pixConfig->isEnabled(),
'title' => $this->pixConfig->getTitle(),
'logo' => $this->assetRepository->getUrl(PixHelper::LOGO_URL)
]
]
];
Expand Down
1 change: 1 addition & 0 deletions view/base/web/images/logo-pix.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions view/frontend/templates/payment/pix.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if ($block->showPixInformation()):
<div class="pix-wrapper">
<div class="pix-logo-wrapper">
<img
width="150"
src="https://cdn.mundipagg.com/assets/images/site/illustrations/pix-bc-logo-2.png"
class="pagarme-pix-logo"
src="<?= $block->getLogoSrc(); ?>"
alt="pix logo"
/>
</div>
Expand Down
4 changes: 4 additions & 0 deletions view/frontend/web/css/pagarme_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@
.field .control .cc_owner {
width: 225px;
}

.pagarme-pix-logo {
width: 120px;
}
4 changes: 4 additions & 0 deletions view/frontend/web/css/pagarme_success_page.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@
padding: 10px 15px;
margin-top: 10px;
}

.pagarme-pix-logo {
width: 120px;
}
3 changes: 3 additions & 0 deletions view/frontend/web/js/view/payment/pix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()];
Expand Down
2 changes: 1 addition & 1 deletion view/frontend/web/template/payment/pix-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
</div>

<img src="https://cdn.mundipagg.com/assets/images/site/illustrations/pix-bc-logo-2.png" width="200" />
<img class="pagarme-pix-logo" data-bind="attr:{src: getLogoSrc()}" />

<div class="checkout-text-block">
<span><!-- ko i18n: getText()--><!-- /ko --></span>
Expand Down

0 comments on commit 72a7757

Please sign in to comment.