Skip to content

Commit

Permalink
2.2.1
Browse files Browse the repository at this point in the history
## 🚀 Improvements
- Added notifications for customer configs

## 🐛 Bug fixes
- Bug fix: Document value handler for customers #181 
- Bug fix: Removed values in config.xml
  • Loading branch information
fabiano-mallmann authored Apr 19, 2023
1 parent 58811e6 commit 7ff4068
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function _renderValue(AbstractElement $element): string
{
$html = '<td class="value">';
$html .= $this->_getElementHtml($element);
$html .= '<p>Pagar.me recipient id that represents your marketplace</p>';
$html .= __('<p>Pagar.me recipient id that represents your marketplace</p>');
$html .= '</td>';
$html .= '<td>';
$html .= sprintf(
Expand Down
12 changes: 5 additions & 7 deletions Concrete/Magento2PlatformOrderDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,17 +539,15 @@ private function getRegisteredCustomer($quote)

$customer->setName($fullName);
$customer->setEmail($quote->getCustomerEmail());

$customerDocument = $this->cleanCustomerDocument(
$quote->getCustomer()->getTaxVat()
);
$address->getVatId() ?? ""
);

if (!$customerDocument) {
$customerDocument = $this->cleanCustomerDocument(
$address->getVatId()
);
$quote->getCustomer()->getTaxVat() ?? ""
);
}

$customer->setDocument($customerDocument);
$customer->setType(CustomerType::individual());

Expand Down
21 changes: 21 additions & 0 deletions Gateway/Transaction/Base/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@

class Config extends AbstractConfig implements ConfigInterface
{
/**
* @return bool
*/
public function isEnabled()
{
return $this->getConfig(static::PATH_ENABLED);
}

/**
* @return string
*/
Expand Down Expand Up @@ -133,4 +141,17 @@ public function isSendEmail()

return false;
}

/**
* @return array
*/
public function getPagarmeCustomerConfigs()
{
$customerConfigs = [
'showVatNumber' => $this->getConfig(static::PATH_CUSTOMER_VAT_NUMBER) ?? '',
'streetLinesNumber' => $this->getConfig(static::PATH_CUSTOMER_ADDRESS_LINES) ?? '',
];

return $customerConfigs;
}
}
39 changes: 26 additions & 13 deletions Gateway/Transaction/Base/Config/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,27 @@

interface ConfigInterface
{
const PATH_PUBLIC_KEY_TEST = 'pagarme_pagarme/global/public_key_test';
const PATH_SECRET_KEY_TEST = 'pagarme_pagarme/global/secret_key_test';
const PATH_PUBLIC_KEY = 'pagarme_pagarme/global/public_key';
const PATH_SECRET_KEY = 'pagarme_pagarme/global/secret_key';
const PATH_HUB_INSTALL_ID = 'pagarme_pagarme/hub/install_id';
const PATH_HUB_ENVIRONMENT = 'pagarme_pagarme/hub/environment';
const PATH_TEST_MODE = 'pagarme_pagarme/global/test_mode';
const PATH_SEND_EMAIL = 'pagarme_pagarme/global/sendmail';
const PATH_CUSTOMER_STREET = 'payment/pagarme_customer_address/street_attribute';
const PATH_CUSTOMER_NUMBER = 'payment/pagarme_customer_address/number_attribute';
const PATH_CUSTOMER_COMPLEMENT = 'payment/pagarme_customer_address/complement_attribute';
const PATH_CUSTOMER_DISTRICT = 'payment/pagarme_customer_address/district_attribute';
const HUB_SANDBOX_ENVIRONMENT = 'Sandbox';
const PATH_ENABLED = 'pagarme_pagarme/global/active';
const PATH_PUBLIC_KEY_TEST = 'pagarme_pagarme/global/public_key_test';
const PATH_SECRET_KEY_TEST = 'pagarme_pagarme/global/secret_key_test';
const PATH_PUBLIC_KEY = 'pagarme_pagarme/global/public_key';
const PATH_SECRET_KEY = 'pagarme_pagarme/global/secret_key';
const PATH_HUB_INSTALL_ID = 'pagarme_pagarme/hub/install_id';
const PATH_HUB_ENVIRONMENT = 'pagarme_pagarme/hub/environment';
const PATH_TEST_MODE = 'pagarme_pagarme/global/test_mode';
const PATH_SEND_EMAIL = 'pagarme_pagarme/global/sendmail';
const PATH_CUSTOMER_STREET = 'payment/pagarme_customer_address/street_attribute';
const PATH_CUSTOMER_NUMBER = 'payment/pagarme_customer_address/number_attribute';
const PATH_CUSTOMER_COMPLEMENT = 'payment/pagarme_customer_address/complement_attribute';
const PATH_CUSTOMER_DISTRICT = 'payment/pagarme_customer_address/district_attribute';
const PATH_CUSTOMER_VAT_NUMBER = 'customer/create_account/vat_frontend_visibility';
const PATH_CUSTOMER_ADDRESS_LINES = 'customer/address/street_lines';
const HUB_SANDBOX_ENVIRONMENT = 'Sandbox';

/**
* @return bool
*/
public function isEnabled();

/**
* @return string
Expand Down Expand Up @@ -79,6 +87,11 @@ public function getCustomerAddressComplement();
*/
public function getCustomerAddressDistrict();

/**
* @return array
*/
public function getPagarmeCustomerConfigs();

/**
* @return bool
*/
Expand Down
19 changes: 17 additions & 2 deletions Model/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,22 @@ public function __construct(
array $data = []
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
if (!$config->isEnabled()) {
return;
}

if ($config->isSandboxMode()) {
$this->warnings[] = '<b> Pagar.me </b><br>' . __('<span style=\'background-color:red; color:white; padding:2px 5px\'>Important!</span> This store is linked to the Pagar.me test environment. This environment is intended for integration validation and does not generate real financial transactions.');
$this->warnings[] = __('This store is linked to the Pagar.me test environment. This environment is intended for integration validation and does not generate real financial transactions.');
}

$customerConfigs = $config->getPagarmeCustomerConfigs();

if ($customerConfigs['showVatNumber'] != 1) {
$this->warnings[] = __("<b>Show VAT Number on Storefront</b> must be defined as <b>'Yes'</b> on <b>Stores</b> > <b>Configuration</b> > <b>Customer</b> > <b>Customer Configuration</b> > <b>Create New Account Options</b> for Pagar.me module to work on your store.");
}

if ($customerConfigs['streetLinesNumber'] != 4) {
$this->warnings[] = __("<b>Number of Lines in a Street Address</b> must be defined as <b>'4'</b> on <b>Stores</b> > <b>Configuration</b> > <b>Customer</b> > <b>Customer Configuration</b> > <b>Name and Address Options</b> for Pagar.me module to work on your store.");
}
}

Expand All @@ -63,8 +77,9 @@ public function getText(): ?string
{
$html = null;
$count = count($this->warnings);

for ($i = 0; $i < $count; $i++) {
$html .= "<div style='padding-bottom:5px;" . (($i != 0) ? "margin-top:5px;" : "") . (($i < $count - 1) ? "border-bottom:1px solid gray;" : "") . "'>" . $this->warnings[$i] . "</div>";
$html .= '<div style="padding-bottom: 10px;' . (($i !== 0) ? 'margin-top: 10px;' : '') . (($i < $count - 1) ? 'border-bottom: 1px dashed #d1d1d1' : '') . '">' . (($i === 0) ? "<b style='display:block; margin-bottom:8px'> Pagar.me </b>" : '') . __("<span style='background-color:red; color:white; padding:2px 5px'>Important!</span> ") . $this->warnings[$i] . '</div>';
}
return $html;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ composer require pagarme/pagarme-magento2-module

## Requirements
* PHP >= 7.1
* Magento2 >= 2.3 & < 2.4.6
* Magento2 >= 2.3 & <= 2.4.5

## Configuration

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "pagarme/pagarme-magento2-module",
"license": "MIT",
"version": "2.2.0",
"version": "2.2.1",
"type": "magento2-module",
"description": "Magento 2 Module Pagar.me",
"minimum-stability": "dev",
"require": {
"php": ">=7.1",
"pagarme/ecommerce-module-core": "~2.2"
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<type name="Magento\Framework\Notification\MessageList">
<arguments>
<argument name="messages" xsi:type="array">
<item name="indexer" xsi:type="string">Pagarme\Pagarme\Model\Notifications</item>
<item name="pagarme_notifications" xsi:type="string">Pagarme\Pagarme\Model\Notifications</item>
</argument>
</arguments>
</type>
Expand Down
12 changes: 4 additions & 8 deletions etc/adminhtml/system/customer-address.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="pagarme_customer_address" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="20">
<label>Customer Address</label>
<field id="street_attribute" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label" type="text">
<field id="street_attribute" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label comment" type="text">
<label>Street parameter</label>
<comment><![CDATA[<b> for example: </b> street_1]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/pagarme_customer_address/street_attribute</config_path>
<validate>required-entry no-whitespace</validate>
</field>
<field id="number_attribute" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label" type="text">
<field id="number_attribute" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label comment" type="text">
<label>Number parameter</label>
<comment><![CDATA[<b> for example: </b> street_2]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/pagarme_customer_address/number_attribute</config_path>
<validate>required-entry no-whitespace</validate>
</field>
<field id="complement_attribute" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="30" translate="label" type="text">
<field id="complement_attribute" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="30" translate="label comment" type="text">
<label>Complement parameter</label>
<comment><![CDATA[<b> for example: </b> street_3]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/pagarme_customer_address/complement_attribute</config_path>
<validate>required-entry no-whitespace</validate>
</field>
<field id="district_attribute" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="40" translate="label" type="text">
<field id="district_attribute" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="40" translate="label comment" type="text">
<label>Neighborhood parameter</label>
<comment><![CDATA[<b> for example: </b> street_4]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/pagarme_customer_address/district_attribute</config_path>
<validate>required-entry no-whitespace</validate>
</field>
Expand Down
9 changes: 1 addition & 8 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
</pagarme>
</pagarme>
<payment>
<pagarme_customer_address>
<street_attribute>street_1</street_attribute>
<number_attribute>street_2</number_attribute>
<complement_attribute>street_3</complement_attribute>
<district_attribute>street_4</district_attribute>
</pagarme_customer_address>

<pagarme_billet>
<active>1</active>
<model>PagarmeBilletRemoteMethodAdapter</model>
Expand Down Expand Up @@ -202,7 +195,7 @@
<can_initialize>1</can_initialize>
<allow_multiple_address>0</allow_multiple_address>
</pagarme_voucher>

<pagarme_debit>
<active>1</active>
<model>PagarmeDebitRemoteMethodAdapter</model>
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.2.0">
<module name="Pagarme_Pagarme" setup_version="2.2.1">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down
5 changes: 4 additions & 1 deletion i18n/pt_BR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@
"<p><strong style='color:red'>Warning!</strong> Don't forget to add your store's domain on Pagar.me dashboard</p>", "<p><strong style='color:red'>Aviso!</strong> Não se esqueça de adicionar o domínio da sua loja no painel do Pagar.me</p>"
"View Integration", "Ver Integração"
"Integrate With Pagar.me", "Integrar com Pagar.me"
"<span style='background-color:red; color:white; padding:2px 5px'>Important!</span> This store is linked to the Pagar.me test environment. This environment is intended for integration validation and does not generate real financial transactions.","<span style='background-color:red; color:white; padding:2px 5px'>Importante!</span> Esta loja está vinculada ao ambiente de testes da Pagar.me. Este ambiente é destinado a validação de integração e não gera operações financeiras reais."
"<span style='background-color:red; color:white; padding:2px 5px'>Important!</span> ","<span style='background-color:red; color:white; padding:2px 5px'>Importante!</span> "
"This store is linked to the Pagar.me test environment. This environment is intended for integration validation and does not generate real financial transactions.","Esta loja está vinculada ao ambiente de testes da Pagar.me. Este ambiente é destinado a validação de integração e não gera operações financeiras reais."
"<b>Show VAT Number on Storefront</b> must be defined as <b>'Yes'</b> on <b>Stores</b> > <b>Configuration</b> > <b>Customer</b> > <b>Customer Configuration</b> > <b>Create New Account Options</b> for Pagar.me module to work on your store.","<b>Mostrar Número VAT na Vitrine</b> deve ser definido como <b>'Sim'</b> em <b>Lojas</b> > <b>Configuração</b> > <b>Cliente</b> > <b>Configurações de cliente</b> > <b>Criar Novas Opções de Conta</b> para que o módulo da Pagar.me funcione na sua loja."
"<b>Number of Lines in a Street Address</b> must be defined as <b>'4'</b> on <b>Stores</b> > <b>Configuration</b> > <b>Customer</b> > <b>Customer Configuration</b> > <b>Name and Address Options</b> for Pagar.me module to work on your store.","<b>Numero de Linhas em Endereço</b> deve ser definido como <b>'4'</b> em <b>Lojas</b> > <b>Configuração</b> > <b>Cliente</b> > <b>Configurações de cliente</b> > <b>Opções de Nome e Endereço</b> para que o módulo da Pagar.me funcione na sua loja."
"Important! This store is in the testing phase. Orders placed in this environment will not be carried out.","Importante! Esta loja está em fase de testes. Os pedidos realizados neste ambiente não serão efetivados."
"A installment times should be set between 1 and 24!", "Um prazo de parcelamento deve ser definido entre 1 e 24!"
"Please enter a valid number in this field.", "Insira um número válido neste campo."
Expand Down

0 comments on commit 7ff4068

Please sign in to comment.