Skip to content

Commit

Permalink
Release 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mateus-picoloto authored Nov 8, 2023
2 parents 3a6ef97 + 54864de commit 0786be8
Show file tree
Hide file tree
Showing 66 changed files with 1,843 additions and 677 deletions.
3 changes: 2 additions & 1 deletion Api/WebhookManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ interface WebhookManagementInterface
/**
* @api
* @param mixed $id
* @param mixed $account
* @param mixed $type
* @param mixed $data
* @return boolean
*/
public function save($id, $type, $data);
public function save($id, $type, $data, $account);
}
47 changes: 47 additions & 0 deletions Block/Adminhtml/Form/Field/CreditCardPspField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;
use Pagarme\Pagarme\Model\PagarmeConfigProvider;

class CreditCardPspField extends Field
{
/**
* @var Account
*/
protected $account;

/**
* @param Context $context
* @param Account $account
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Account $account,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
) {
parent::__construct($context, $data, $secureRenderer);
$this->account = $account;
}

/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
if ($this->account->isGateway(PagarmeConfigProvider::CREDIT_CARD_PAYMENT_CONFIG)) {
return '';
}

return parent::render($element);
}
}
26 changes: 26 additions & 0 deletions Block/Adminhtml/Form/Field/EnableAdvanceSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Field;

use Exception;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Pagarme\Pagarme\Concrete\Magento2CoreSetup;

class EnableAdvanceSettings extends Field
{
/**
* @param AbstractElement $element
* @return string
* @throws Exception
*/
public function render(AbstractElement $element)
{
Magento2CoreSetup::bootstrap();
$config = Magento2CoreSetup::getModuleConfiguration();
if (!empty($config->getAccountId())) {
return '';
}
return parent::render($element);
}
}
55 changes: 55 additions & 0 deletions Block/Adminhtml/Form/Field/GatewayField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;

class GatewayField extends Field
{
/**
* @var string
*/
protected $paymentMethodName;

/**
* @var Account
*/
protected $account;

/**
* @param Context $context
* @param Account $account
* @param string $paymentMethodName
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Account $account,
string $paymentMethodName = '',
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
) {
parent::__construct($context, $data, $secureRenderer);
$this->account = $account;
$this->paymentMethodName = $paymentMethodName;
}

/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
if (empty($this->paymentMethodName) || !$this->account->isGateway($this->paymentMethodName)) {
return '';
}

return parent::render($element);
}

}
58 changes: 58 additions & 0 deletions Block/Adminhtml/Form/Field/InstallmentsNumber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;
use Pagarme\Pagarme\Model\PagarmeConfigProvider;

class InstallmentsNumber extends Field
{
/**
* @var Account
*/
protected $account;

/**
* @param Context $context
* @param CollectionFactory $configCollectionFactory
* @param Account $account
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
CollectionFactory $configCollectionFactory,
Account $account,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
) {
parent::__construct($context, $data, $secureRenderer);
$this->configCollectionFactory = $configCollectionFactory;
$this->account = $account;
}

/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$isGateway = $this->account->isGateway(PagarmeConfigProvider::CREDIT_CARD_PAYMENT_CONFIG);
if ($isGateway) {
$classes = $element->getClass();
$classes = str_replace('number-range-1-12', '', $classes);
$classes .= ' number-range-1-24';
$element->setClass($classes);

$comment = $element->getComment();
$comment = str_replace('12', '24', $comment);
$element->setComment($comment);
}
return parent::render($element);
}
}
64 changes: 64 additions & 0 deletions Block/Adminhtml/Form/Field/SoftDescriptor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Field;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;

class SoftDescriptor extends Field
{
/**
* @var Account
*/
protected $account;

/**
* @var string
*/
protected $paymentMethodName;

/**
* @param Context $context
* @param Account $account
* @param string $paymentMethodName
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Account $account,
string $paymentMethodName = '',
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
) {
parent::__construct($context, $data, $secureRenderer);
$this->account = $account;
$this->paymentMethodName = $paymentMethodName;
}

/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
if (empty($this->paymentMethodName)) {
return '';
}
$isGateway = $this->account->isGateway($this->paymentMethodName);
if ($isGateway) {
$classes = $element->getClass();
$classes = str_replace('maximum-length-13', '', $classes);
$classes .= ' maximum-length-22';
$element->setClass($classes);

$comment = $element->getComment();
$comment = str_replace('13', '22', $comment);
$element->setComment($comment);
}
return parent::render($element);
}
}
53 changes: 53 additions & 0 deletions Block/Adminhtml/Form/Fieldset/CreditCardGatewayFieldset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Fieldset;

use Magento\Backend\Block\Context;
use Magento\Backend\Model\Auth\Session;
use Magento\Config\Block\System\Config\Form\Fieldset;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\Js;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;
use Pagarme\Pagarme\Model\PagarmeConfigProvider;

class CreditCardGatewayFieldset extends Fieldset
{
/**
* @var Account
*/
protected $account;

/**
* @param Context $context
* @param Session $authSession
* @param Js $jsHelper
* @param Account $account
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Session $authSession,
Js $jsHelper,
Account $account,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
) {
parent::__construct($context, $authSession, $jsHelper, $data, $secureRenderer);
$this->account = $account;
}

/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
if (!$this->account->isGateway(PagarmeConfigProvider::CREDIT_CARD_PAYMENT_CONFIG)) {
return '';
}

return parent::render($element);
}
}
60 changes: 60 additions & 0 deletions Block/Adminhtml/Form/Fieldset/CustomPaymentFieldset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Pagarme\Pagarme\Block\Adminhtml\Form\Fieldset;

use Magento\Backend\Block\Context;
use Magento\Backend\Model\Auth\Session;
use Magento\Config\Block\System\Config\Form\Fieldset;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\Js;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
use Pagarme\Pagarme\Model\Account;

class CustomPaymentFieldset extends Fieldset
{
/**
* @var Account
*/
protected $account;

/**
* @var string
*/
protected $paymentMethodName;

/**
* @param Context $context
* @param Session $authSession
* @param Js $jsHelper
* @param Account $account
* @param string $paymentMethodName
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
Session $authSession,
Js $jsHelper,
Account $account,
string $paymentMethodName = '',
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
) {
parent::__construct($context, $authSession, $jsHelper, $data, $secureRenderer);
$this->account = $account;
$this->paymentMethodName = $paymentMethodName;
}

/**
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
if (empty($this->paymentMethodName) || $this->account->isPSP($this->paymentMethodName)) {
return '';
}

return parent::render($element);
}
}
Loading

0 comments on commit 0786be8

Please sign in to comment.