Skip to content

Commit

Permalink
Adiciona configuração de parceiros
Browse files Browse the repository at this point in the history
  • Loading branch information
netojoaobatista committed Jun 14, 2019
1 parent 34ba9a5 commit 1600ecc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Gateway/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Config extends \Magento\Payment\Gateway\Config\Config

const MIN_TOTAL_INSTALLMENTS = 'min_total_installments';

const KEY_MODULE = 'module';
const KEY_GATEWAY = 'gateway';

const VALUE_3DSECURE_ALL = 0;
const CODE_3DSECURE = 'three_d_secure';
const FRAUD_PROTECTION = 'fraudprotection';
Expand Down Expand Up @@ -72,6 +75,22 @@ public function getMinTotalInstallments()
return (double)$this->getValue(self::MIN_TOTAL_INSTALLMENTS);
}

/**
* @return string
*/
public function getModule()
{
return $this->getValue(Config::KEY_MODULE);
}

/**
* @return string
*/
public function getGateway()
{
return $this->getValue(Config::KEY_GATEWAY);
}

/**
* Check if 3d secure verification enabled
* @return bool
Expand Down
6 changes: 6 additions & 0 deletions src/Model/Adapter/RedeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function authorize(array $attributes, $capture = false)
$token = $this->config->getToken();
$environment = \Rede\Environment::production();
$softDescriptor = $this->config->getSoftDescriptor();
$module = $this->config->getModule();
$gateway = $this->config->getGateway();

if ($this->config->getEnvironment() == 'test') {
$environment = \Rede\Environment::sandbox();
Expand Down Expand Up @@ -113,6 +115,10 @@ public function authorize(array $attributes, $capture = false)
$transaction->setSoftDescriptor($softDescriptor);
}

if (!empty($module) && !empty($gateway)) {
$transaction->additional($gateway, $module);
}

$logger = new \Monolog\Logger('rede');
$logger->pushHandler(new \Monolog\Handler\StreamHandler(BP . '/var/log/rede.log', \Monolog\Logger::DEBUG));
$logger->info('Log Rede');
Expand Down
10 changes: 10 additions & 0 deletions src/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@
<frontend_class>validate-number</frontend_class>
</field>

<field id="module" translate="label" type="text" sortOrder="8"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Module</label>
</field>

<field id="gateway" translate="label" type="text" sortOrder="8"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Gateway</label>
</field>

<!--
<field id="verify_3dsecure" translate="label" type="select" sortOrder="9" showInDefault="1"
Expand Down
3 changes: 3 additions & 0 deletions src/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<number_installments>12</number_installments>
<min_total_installments>0</min_total_installments>

<module></module>
<gateway></gateway>

<can_authorize>1</can_authorize>
<can_sale>1</can_sale>
<can_capture>1</can_capture>
Expand Down

0 comments on commit 1600ecc

Please sign in to comment.