Skip to content

Commit 8f59e30

Browse files
Merge pull request #11 from pagarme/develop
Develop
2 parents 1b0d028 + 397902e commit 8f59e30

File tree

33 files changed

+729
-137
lines changed

33 files changed

+729
-137
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This is the repository of Pagar.me's payment module core for all supported e-com
1313
- [Pagar.me Magento payment module for Magento 2.3+](https://github.com/pagarme/magento2).
1414

1515
## Dependencies
16-
* ``PHP`` Version 5.6+
16+
* ``PHP`` Version 7.1+
1717

1818
## Install
1919
Require by composer

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ stages:
2828
sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpCurrentVersion)
2929
sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpCurrentVersion)
3030
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpCurrentVersion)
31-
sudo apt-get install php-xdebug
31+
sudo apt-get install php7.2-xdebug
3232
php -version
3333
displayName: Build PHP Version $(phpCurrentVersion)
3434
3535
- script: |
36-
sudo apt-get install php-xdebug
36+
sudo apt-get install php7.2-xdebug
3737
php -version
3838
displayName: Install PHP extensions
3939

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"name": "pagarme/ecommerce-module-core",
33
"description": "Core component for Pagar.me e-commerce platform modules.",
44
"license": "MIT",
5-
"version": "1.0.0",
5+
"version": "1.1.0",
66
"authors": [
77
{
88
"name":"Open Source Team"
99
}
1010
],
1111
"type": "library",
1212
"require": {
13-
"php": ">=5.6",
13+
"php": ">=7.1",
1414
"monolog/monolog": "~1.6",
1515
"mundipagg/mundiapi": "^3.0",
1616
"ext-json": "*"

src/Hub/Commands/InstallCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public function execute()
1818

1919
$moduleConfig->setHubInstallId($this->getInstallId());
2020

21+
$moduleConfig->setHubEnvironment($this->getType());
22+
2123
$moduleConfig->setPublicKey(
2224
$this->getAccountPublicKey()
2325
);

src/Hub/Factories/HubCommandFactory.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function createFromStdClass($object)
3131

3232
/**
3333
*
34-
* @var AbstractCommand $command
35-
*/
34+
* @var AbstractCommand $command
35+
*/
3636
$command = new $commandClass();
3737

3838
$command->setAccessToken(
@@ -48,7 +48,10 @@ public function createFromStdClass($object)
4848
);
4949

5050
$publicKeyClass = PublicKey::class;
51-
if ($command->getType()->equals(CommandType::Sandbox())) {
51+
if (
52+
$command->getType()->equals(CommandType::Sandbox())
53+
|| $command->getType()->equals(CommandType::Development())
54+
) {
5255
$publicKeyClass = TestPublicKey::class;
5356
}
5457

src/Hub/Services/HubIntegrationService.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ public function endHubIntegration(
4949

5050
$installToken = $tokenRepo->findByPagarmeId(new HubInstallToken($installToken));
5151

52-
if (is_a($installToken, InstallToken::class)
53-
&& !$installToken->isExpired()
52+
if (
53+
is_a($installToken, InstallToken::class)
54+
&& !$installToken->isExpired()
5455
&& !$installToken->isUsed()
5556
) {
5657
$body = [
@@ -100,4 +101,4 @@ public function executeCommandFromPost($body)
100101
$command = $commandFactory->createFromStdClass($body);
101102
$command->execute();
102103
}
103-
}
104+
}

src/Kernel/Abstractions/AbstractModuleCoreSetup.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Pagarme\Core\Kernel\Aggregates\Configuration;
66
use Pagarme\Core\Kernel\Repositories\ConfigurationRepository;
7+
use MundiAPILib\Configuration as MundiAPIConfiguration;
78
use ReflectionClass;
89

910
abstract class AbstractModuleCoreSetup
@@ -72,6 +73,15 @@ public static function bootstrap($platformRoot = null)
7273
static::$platformRoot = $platformRoot;
7374

7475
static::updateModuleConfiguration();
76+
77+
static::$instance->setApiBaseUrl();
78+
}
79+
}
80+
81+
protected static function setApiBaseUrl()
82+
{
83+
if (static::$moduleConfig->isHubEnabled()) {
84+
MundiAPIConfiguration::$BASEURI = 'https://hubapi.mundipagg.com/core/v1';
7585
}
7686
}
7787

@@ -98,7 +108,7 @@ protected static function updateModuleConfiguration()
98108
static::$moduleConfig->setStoreId(static::getCurrentStoreId());
99109
}
100110

101-
if(
111+
if (
102112
static::$moduleConfig->getStoreId() != static::getDefaultStoreId() &&
103113
$savedConfig === null
104114
) {
@@ -241,7 +251,7 @@ public static function getModuleConcreteDir()
241251

242252
public static function setModuleConcreteDir($concreteModuleDir)
243253
{
244-
if(!isset(self::$moduleConcreteDir)) {
254+
if (!isset(self::$moduleConcreteDir)) {
245255
self::$moduleConcreteDir = $concreteModuleDir;
246256
}
247257
}
@@ -288,4 +298,3 @@ public static function getStoreTimezone()
288298
*/
289299
abstract protected function getPlatformStoreTimezone();
290300
}
291-

src/Kernel/Aggregates/Configuration.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ final class Configuration extends AbstractEntity
6262
*/
6363
private $hubInstallId;
6464

65+
/**
66+
*
67+
* @var string
68+
*/
69+
private $hubEnvironment;
70+
6571
/** @var string */
6672
private $cardOperation;
6773

@@ -315,6 +321,16 @@ public function getHubInstallId()
315321
return $this->hubInstallId;
316322
}
317323

324+
public function setHubEnvironment($hubEnvironment)
325+
{
326+
$this->hubEnvironment = $hubEnvironment;
327+
}
328+
329+
public function getHubEnvironment()
330+
{
331+
return $this->hubEnvironment;
332+
}
333+
318334
/**
319335
*
320336
* @param bool $boletoEnabled
@@ -711,6 +727,7 @@ public function jsonSerialize()
711727
"boletoCreditCardEnabled" => $this->boletoCreditCardEnabled,
712728
"testMode" => $this->testMode,
713729
"hubInstallId" => $this->isHubEnabled() ? $this->hubInstallId->getValue() : null,
730+
"hubEnvironment" => $this->hubEnvironment,
714731
"addressAttributes" => $this->getAddressAttributes(),
715732
"keys" => $this->keys,
716733
"cardOperation" => $this->cardOperation,

src/Kernel/Factories/ConfigurationFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ public function createFromJsonData($json)
124124
);
125125
}
126126

127+
if (!empty($data->hubEnvironment)) {
128+
$config->setHubEnvironment($data->hubEnvironment);
129+
}
130+
127131
if (!empty($data->keys) ) {
128132
if (!isset($data->publicKey)) {
129133
$index = Configuration::KEY_PUBLIC;

src/Kernel/Factories/Configurations/PixConfigFactory.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ public function createFromDbData($data)
2727
$pixConfig->setExpirationQrCode($data->expirationQrCode);
2828
}
2929

30+
if (!empty($data->additionalInformation)) {
31+
$additionalInformationArray = json_decode(
32+
json_encode($data->additionalInformation),
33+
true
34+
);
35+
36+
$pixConfig->setAdditionalInformation(
37+
$additionalInformationArray
38+
);
39+
}
40+
3041
if (!empty($data->bankType)) {
3142
$pixConfig->setBankType(
3243
$data->bankType

0 commit comments

Comments
 (0)