Skip to content

Commit

Permalink
Release 2.2.5 (#259)
Browse files Browse the repository at this point in the history
* refactoring Invoice block and template

* removing target attribute

* fixing names and translations

* adding NumberFormatHelper

* refactoring BilletCreditCard block and template

* removing line break elements and changing to use paragraph elements

* changing to return type be in comment section

* changing to return type be in comment section

* Refactoring creditCard.phtml template

* Refactoring creditCard.phtml template

* Refactoring creditCard.phtml template

* Refactoring creditCard.phtml template

* refactoring order_charge block and template

* removing unnecessary return statement

* changing space location in html generator

* Refactoring twoCreditCard info class and phtml

* refactoring pix block and template

* removing unnecessary parameter passage

* injecting PixHelper via di

* fixing text and adding space between use statements and class declaration

* refactor: Refactoring billet info class and phtml

* refactor: pix in the admin and customer view

(#212)

* refactor: html elements be in template in order_charge and invoice blocks

(#210)

* refactor: removing unused priceFinal template

(#211)

* compatibilization with magento 2.4.6 and PHP 8.2

* Revert "compatibilization with magento 2.4.6 and PHP 8.2"

This reverts commit 86f779e.

* feat: compatibilization with magento 2.4.6 and PHP 8.2

(#214)

* refactor: showing cycle option value in cart 

(#213)

* Feat: Clear checkout error messages on field change (#216)

* Feat: Clear checkout error messages on field change

* Changed var to const

* Defined constants instead of duplicating literals

* ⬆️ Bump word-wrap from 1.2.3 to 1.2.5 in /e2e

(#218)

* feat: compatibilization with bundle js 

(#217)

* improve: add recurence items in catalog menu (#219)

* improve: add day cycle in recurring product 

(#220)

* cd: add new images to cd

 (#215)

* Fix: Added translations admin menu items (#222)

* Fix: Removed domain protocol from csp_whitellist.xml (#223)

* Refactor: Improve observers code (#224)

* Improve observers code

* Removinh unnecessary else

* refactor: new function to remove if

* added function to remove if

* Fix: translations (#225)

* cd: add marketplace on images

* cd: fix test image

* cd: add composer allow root

* feat: removing string extraction from recurrence 

(#226)

* feat: added pix informations to graphql (#227)

* Added pix informations to graphql

* Remove the unused function parameter "$subject"

* fix: adding subject parameter in plugin

---------

Co-authored-by: Mateus Picoloto <mateus.picoloto@pagar.me>

* refactor: moving inline css to css file

(#230)

* build: changing module core version (#231)

* build: changing module core version (#232)

* build: changing module core version

* build: changing minimum stability

* fix: set area code only if is not setted

(#233)

* cd: refactory cd (#235)

* refactor: admin creditCard block and template

(#236)

* fix: changing to use emulateAreaCode

(#238)

* feat: adding enabled recurrence config validation to recurrences features

* Revert "feat: adding enabled recurrence config validation to recurrences features"

This reverts commit dc6e3a2.

* Fix Webapi\Exception __construct arguments

* feat: adding enabled recurrence config validation to recurrences features 

(#239)

* fix: adding pagarmeConfig property 

(#241)

* fix: error wih default brand or null (#244)

* fix: add conditional when wallet fields don't exist

(#243)

* PAOPN-576: add shipping and taxs in subs

(#242 )

* fix: brand validation call (#245)

* feat: changing cycles to discount in subscriptions and plans 

(#246)

* fix: recurrence price mask showing NaN for all values

(#248)

* fix: changing to use messageList from magento

(#249)

* fix: strlen on null value for php 8.2 

(#250)

* fix: release number version

(#251)

* Release/2.2.5 

(#252)

* feat: adding subscriptions to sales menu and re-adding enabled gateway dependency to show recurrence settings

(#253)

* fix: change to only update installments for valid brands 

(#255)

* fix: receive only magento webhooks (#254)

* fix: adding due_at, bank and instructions information to be send to createOrder for billet payment method

(#256)

* Revert "fix: adding due_at, bank and instructions information to be send to createOrder for billet payment method" (#257)

This reverts commit abf9308.

* build: changing module core version (#258)

---------

Co-authored-by: RafaMelazzo <rafael.melazzo@stone.com.br>
Co-authored-by: Fabiano Mallmann <25328512+fabiano-mallmann@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: robsoned <robsoneduardosantos@gmail.com>
  • Loading branch information
5 people authored Oct 4, 2023
1 parent 7ac3929 commit 3a6ef97
Show file tree
Hide file tree
Showing 148 changed files with 8,312 additions and 7,185 deletions.
113 changes: 59 additions & 54 deletions Block/Adminhtml/Order/Charge/Tab/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,64 @@

namespace Pagarme\Pagarme\Block\Adminhtml\Order\Charge\Tab;

use Exception;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Tab\TabInterface;
use Magento\Framework\Pricing\Helper\Data;
use Magento\Framework\Registry;
use Magento\Sales\Model\Order;
use Pagarme\Core\Kernel\Exceptions\InvalidParamException;
use Pagarme\Pagarme\Block\BaseTemplateWithCurrency;
use Pagarme\Pagarme\Concrete\Magento2CoreSetup;
use Pagarme\Pagarme\Service\Order\ChargeService;

use Pagarme\Core\Kernel\Repositories\ChargeRepository;
use Pagarme\Core\Kernel\Repositories\OrderRepository;
use Pagarme\Core\Kernel\ValueObjects\Id\OrderId;

class View extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\Tab\TabInterface
class View extends BaseTemplateWithCurrency implements TabInterface
{
// @codingStandardsIgnoreLine
protected $_template = 'tab/view/order_charge.phtml';

/**
* View constructor.
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @var Registry
*/
private $registry;

/**
* @var ChargeService
*/
private $chargeService;

/**
* @param Context $context
* @param Registry $registry
* @param Data $priceHelper
* @param ChargeService $chargeService
* @param array $data
* @throws Exception
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
array $data = []
Context $context,
Registry $registry,
Data $priceHelper,
ChargeService $chargeService,
array $data = []
) {
Magento2CoreSetup::bootstrap();

$this->_coreRegistry = $registry;
$this->registry = $registry;
$this->chargeService = $chargeService;

parent::__construct($context, $data);
parent::__construct($context, $priceHelper, $data);
}

/**
* Retrieve order model instance
*
* @return \Magento\Sales\Model\Order
* @return array
* @throws InvalidParamException
*/
public function getOrder()
{
return $this->_coreRegistry->registry('current_order');
}

public function getCharges()
{
//@todo Create service to return the charges
$platformOrderID = $this->getOrderIncrementId();
$pagarmeOrder = (new OrderRepository)->findByPlatformId($platformOrderID);

if ($pagarmeOrder === null) {
return [];
}

$charges = (new ChargeRepository)->findByOrderId(
new OrderId($pagarmeOrder->getPagarmeId()->getValue())
return $this->chargeService->findChargesByIncrementId(
$this->getOrderIncrementId()
);

return $charges;
}

/**
* Retrieve order model instance
*
* @return \Magento\Sales\Model\Order
*/
public function getOrderId()
{
return $this->getOrder()->getEntityId();
}

/**
* Retrieve order increment id
*
* @return string
*/
public function getOrderIncrementId()
{
return $this->getOrder()->getIncrementId();
}

/**
Expand All @@ -90,7 +75,7 @@ public function getTabLabel()
*/
public function getTabTitle()
{
return __('Charges');
return $this->getTabLabel();
}

/**
Expand Down Expand Up @@ -118,4 +103,24 @@ public function getChargeCaptureUrl()
{
return $this->_urlBuilder->getUrl('pagarme_pagarme/charges/capture');
}

/**
* Retrieve order model instance
*
* @return Order
*/
private function getOrder()
{
return $this->registry->registry('current_order');
}

/**
* Retrieve order increment id
*
* @return string
*/
private function getOrderIncrementId()
{
return $this->getOrder()->getIncrementId();
}
}
6 changes: 3 additions & 3 deletions Block/Adminhtml/Recurrence/Subscriptions/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Pagarme\Pagarme\Block\Adminhtml\Recurrence\Subscriptions;

use Exception;
use Magento\Catalog\Api\ProductRepositoryInterfaceFactory;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder;
Expand All @@ -19,8 +20,6 @@
use Pagarme\Core\Recurrence\ValueObjects\IntervalValueObject;
use Pagarme\Pagarme\Concrete\Magento2CoreSetup;
use Pagarme\Pagarme\Helper\RecurrenceProductHelper;
use Pagarme\Pagarme\Ui\Component\Column\Invoices\Actions;
use Pagarme\Pagarme\Ui\Component\Recurrence\Column\TotalCyclesByProduct;
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
use Magento\Catalog\Model\Product\Interceptor as ProductInterceptor;

Expand All @@ -47,7 +46,7 @@ class Subscription extends Template
* @param Context $context
* @param CollectionFactory $productCollectionFactory
* @param Registry $registry
* @param ProductHelper $productHelper
* @throws Exception
*/
public function __construct(
Context $context,
Expand Down Expand Up @@ -123,6 +122,7 @@ public function getCicleSelectOption()
return [
'interval_count' => range(1, 12),
'interval_type' => [
IntervalValueObject::INTERVAL_TYPE_DAY => __('day'),
IntervalValueObject::INTERVAL_TYPE_WEEK => __('week'),
IntervalValueObject::INTERVAL_TYPE_MONTH => __('month'),
IntervalValueObject::INTERVAL_TYPE_YEAR => __('year')
Expand Down
45 changes: 45 additions & 0 deletions Block/BaseTemplateWithCurrency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/**
* Class BaseTemplateWithCurrency
*
* @author Open Source Team
* @copyright 2023 Pagar.me (https://pagar.me)
* @license https://pagar.me Copyright
*
* @link https://pagar.me
*/

namespace Pagarme\Pagarme\Block;

use Magento\Framework\Pricing\Helper\Data;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;

class BaseTemplateWithCurrency extends Template
{
/**
* @var Data
*/
private $priceHelper;

/**
* @param Context $context
* @param Data $priceHelper
* @param array $data
*/
public function __construct(Context $context, Data $priceHelper, array $data = [])
{
parent::__construct($context, $data);
$this->priceHelper = $priceHelper;
}

/**
* @param mixed $number
* @return float|string
*/
public function formatToCurrency($number)
{
return $this->priceHelper->currency(($number) / 100);
}
}
42 changes: 32 additions & 10 deletions Block/Customer/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@

namespace Pagarme\Pagarme\Block\Customer;

use Magento\Framework\View\Element\Template;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Pricing\Helper\Data;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\Registry;
use Magento\Customer\Model\Session;
use Pagarme\Core\Kernel\ValueObjects\Id\SubscriptionId;
use Pagarme\Pagarme\Block\BaseTemplateWithCurrency;
use Pagarme\Pagarme\Concrete\Magento2CoreSetup;
use Pagarme\Core\Recurrence\Repositories\SubscriptionRepository;
use Pagarme\Core\Kernel\Exceptions\InvalidParamException;
use Pagarme\Core\Kernel\Abstractions\AbstractEntity;
use Pagarme\Core\Recurrence\Repositories\ChargeRepository;
use Pagarme\Core\Recurrence\Aggregates\Charge;

class Invoice extends Template
class Invoice extends BaseTemplateWithCurrency
{
/**
* @var Session
Expand All @@ -47,17 +49,18 @@ class Invoice extends Template
protected $coreRegistry;

/**
* Link constructor.
* @param Context $context
* @param CheckoutSession $checkoutSession
* @throws InvalidParamException
* @param Session $customerSession
* @param Registry $coreRegistry
* @param Data $priceHelper
*/
public function __construct(
Context $context,
Session $customerSession,
Registry $coreRegistry
Registry $coreRegistry,
Data $priceHelper
) {
parent::__construct($context, []);
parent::__construct($context, $priceHelper, []);
Magento2CoreSetup::bootstrap();

$this->coreRegistry = $coreRegistry;
Expand Down Expand Up @@ -95,9 +98,27 @@ public function getSubscriptionPaymentMethod()
return $subscription->getPaymentMethod();
}

/**
* @param int $id
* @return int
*/
public function getVisualChargeId($id)
{
return $id + 1;
}

/**
* @param Charge $item
* @return bool
*/
public function isBillet($item)
{
return !empty($item->getBoletoLink());
}

/**
* @param string $codeOrder
* @throws InvalidParamException
* @throws InvalidParamException|AuthorizationException
*/
private function validateUserInvoice($codeOrder)
{
Expand All @@ -112,8 +133,9 @@ private function validateUserInvoice($codeOrder)
}

if (!in_array($codeOrder, $listSubscriptionCode)) {
throw new \Exception(
'Esse pedido não pertence a esse usuário',
throw new AuthorizationException(
__('This order does not belong to this user'),
null,
403
);
}
Expand Down
78 changes: 78 additions & 0 deletions Block/Form/CreditCard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace Pagarme\Pagarme\Block\Form;

use Magento\Framework\View\Element\Template\Context;
use Magento\Payment\Block\Form;
use Magento\Quote\Model\Quote;
use Pagarme\Pagarme\Helper\Adminhtml\CheckoutHelper;

class CreditCard extends Form
{
/**
* @var CheckoutHelper
*/
protected $checkoutHelper;

public function __construct(
Context $context,
CheckoutHelper $checkoutHelper,
array $data = []
) {
parent::__construct($context, $data);
$this->checkoutHelper = $checkoutHelper;
}

public function getMethodCode()
{
return $this->escapeHtml(parent::getMethodCode());
}

/**
* @return string|null
*/
public function getPublicKey()
{
return $this->checkoutHelper->getPublicKey();
}

/**
* @param Quote $quote
* @return string
*/
public function getGrandTotal($quote)
{
return $this->checkoutHelper->formatGrandTotal($quote->getBaseGrandTotal());
}

/**
* @return string[]
*/
public function getMonths()
{
return $this->checkoutHelper->getMonths();
}

/**
* @return string[]
*/
public function getYears()
{
return $this->checkoutHelper->getYears();
}

/**
* @return array
*/
public function getAvailableBrands()
{
return $this->checkoutHelper->getBrandsAvailables(
$this->escapeHtml($this->getMethodCode())
);
}

public function getInstallmentsUrl()
{
return $this->checkoutHelper->getInstallmentsUrl($this->getBaseUrl());
}
}
Loading

0 comments on commit 3a6ef97

Please sign in to comment.