Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dash validation #268

Merged
merged 25 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ce384ad
added AccountService and CoreAuth
RafaMelazzo Sep 25, 2023
9ae4afb
add temporary menu for tests
fabiano-mallmann Sep 26, 2023
a785661
create HubAccount Class
mauriciohaygert Sep 27, 2023
d6e2d96
add accountId in Concrete/Magento2CoreSetup
mauriciohaygert Sep 28, 2023
8c72b00
Merge branch 'stg' of https://github.com/pagarme/magento2 into feat/P…
mauriciohaygert Sep 29, 2023
0acc4d1
get accountId from Webhook
mauriciohaygert Sep 29, 2023
80be2f8
improving notifications
RafaMelazzo Oct 6, 2023
9925bd6
feat: adding dash account settings validation when access payment adm…
Oct 9, 2023
22a22e1
Merge branch 'stg' into feat/PAOPN-329/dash-validation
Oct 9, 2023
80845e2
Merge branch 'feat/PAOPN-329/dash-validation' of https://github.com/p…
RafaMelazzo Oct 9, 2023
85d2ef8
feat: adding debit dash validation
Oct 9, 2023
7efdaf5
feat: adding debit dash validation
Oct 9, 2023
22d9e58
feat: add Dash validation messages
RafaMelazzo Oct 9, 2023
975b707
Merge branch 'feat/PAOPN-329/dash-validation' of https://github.com/p…
RafaMelazzo Oct 9, 2023
0705f46
feat: dash settings validation translations
RafaMelazzo Oct 9, 2023
ee52543
feat: added button to clear Dash validation messages
RafaMelazzo Oct 19, 2023
7471a3a
refactor: moving account validation to ecommerce module core (#265)
mateus-picoloto Oct 26, 2023
003393f
feat: gateway/psp/simulator config validator
Oct 26, 2023
f5425b7
Merge branch 'stg' into feat/PAOPN-329/dash-validation
Oct 26, 2023
af8cc78
fix: code smells
Oct 26, 2023
d883de3
fix: code smells
Oct 26, 2023
b066541
fix: missing comment docs
Oct 26, 2023
4ac9eb7
fix: adding observer name
Oct 27, 2023
429c713
fix: integration button names
RafaMelazzo Oct 31, 2023
f157870
fix: adding back counter for softdescriptor
Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading