Skip to content

Commit

Permalink
Merge pull request #52 from mundipagg/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
LilianaLessa authored May 3, 2019
2 parents 9a0f8f2 + 7a1d05e commit fb07420
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mundipagg/ecommerce-module-core",
"license": "MIT",
"version": "1.7.0",
"version": "1.7.1",
"authors":[
{
"name":"MundiPagg Embeddables Team",
Expand Down
30 changes: 23 additions & 7 deletions src/Kernel/Abstractions/AbstractModuleCoreSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,15 @@ protected static function updateModuleConfiguration()

static::loadSavedConfiguration();

if (static::$moduleConfig !== null) {
return true;
}

$savedConfig = static::$moduleConfig;
static::$instance->loadModuleConfigurationFromPlatform();

static::$moduleConfig->setStoreId(static::getCurrentStoreId());

if (static::$moduleConfig->getId() !== null) {
return true;
if (
$savedConfig !== null &&
($savedConfigId = $savedConfig->getId()) !== null
) {
static::$moduleConfig->setid($savedConfigId);
}

if (self::getDefaultConfigSaved() === null) {
Expand Down Expand Up @@ -258,5 +257,22 @@ abstract public static function getCurrentStoreId();
* @since 1.6.1
*/
abstract public static function getDefaultStoreId();

/**
* @since 1.7.1
*
* @return \DateTimeZone
*/
public static function getStoreTimezone()
{
return self::$instance->getPlatformStoreTimezone();
}

/**
* @since 1.7.1
*
* @return \DateTimeZone
*/
abstract protected function getPlatformStoreTimezone();
}

5 changes: 4 additions & 1 deletion src/Kernel/I18N/ENUS.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ protected function getTable()
"An error occurred when trying to create the order. Please try again. Error Reference: %s." => null,
"Can't cancel current order. Please cancel it by Mundipagg panel" => null,
"Charge canceled with success" => null,
'Invalid address. Please fill the street lines and try again.' => null
'Invalid address. Please fill the street lines and try again.' => null,
"The informed card couldn't be deleted." => null,
"The card '%s' was deleted." => null,
"The card '%s' couldn't be deleted." => null
];
}
}
5 changes: 4 additions & 1 deletion src/Kernel/I18N/PTBR.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ protected function getTable()
"An error occurred when trying to create the order. Please try again. Error Reference: %s" => 'Ocorreu um erro ao tentar criar o pedido. Por favor, tente novamente. Referência do erro: %s',
"Can't cancel current order. Please cancel it by Mundipagg panel" => "Não foi possível cancelar o pedido. Por favor, realize o cancelamento no portal Mundipagg.",
"Charge canceled with success" => "Charge cancelada com sucesso",
'Invalid address. Please fill the street lines and try again.' => 'Endereço inválido. Preencha rua, número e bairro e tente novamente.'
'Invalid address. Please fill the street lines and try again.' => 'Endereço inválido. Preencha rua, número e bairro e tente novamente.',
"The informed card couldn't be deleted." => "O cartão informado não pode ser deletado.",
"The card '%s' was deleted." => "O cartão '%s' foi deletado.",
"The card '%s' couldn't be deleted." => "O cartão '%s' não pôde ser deletado."
];
}
}
5 changes: 5 additions & 0 deletions src/Kernel/ValueObjects/AbstractValidString.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public function jsonSerialize()
{
return $this->getValue();
}

public function __toString()
{
return $this->getValue();
}
}
2 changes: 1 addition & 1 deletion src/Maintenance/Assets/integrityData

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/Payment/Aggregates/SavedCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

final class SavedCard extends AbstractEntity
{
const DATE_FORMAT = 'Y-m-d H:i:s';

/** @var CustomerId */
private $ownerId;

Expand All @@ -24,6 +26,9 @@ final class SavedCard extends AbstractEntity
/** @var CardBrand */
private $brand;

/** @var \DateTime */
private $createdAt;

/**
* @return CustomerId
*/
Expand Down Expand Up @@ -104,6 +109,21 @@ public function setBrand(CardBrand $brand)
$this->brand = $brand;
}

/**
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}

/**
* @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
}

/**
* Specify data which should be serialized to JSON
Expand All @@ -123,6 +143,11 @@ public function jsonSerialize()
$obj->firstSixDigits = $this->getFirstSixDigits();
$obj->lastFourDigits = $this->getLastFourDigits();
$obj->brand = $this->getBrand();
$obj->createdAt = $this->getCreatedAt();

if ($obj->createdAt !== null) {
$obj->createdAt = $obj->createdAt->format(self::DATE_FORMAT);
}

return $obj;
}
Expand Down
15 changes: 15 additions & 0 deletions src/Payment/Factories/SavedCardFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Mundipagg\Core\Payment\Factories;

use Mundipagg\Core\Kernel\Abstractions\AbstractModuleCoreSetup as MPSetup;
use Mundipagg\Core\Kernel\Interfaces\FactoryInterface;
use Mundipagg\Core\Kernel\ValueObjects\CardBrand;
use Mundipagg\Core\Kernel\ValueObjects\Id\CustomerId;
Expand Down Expand Up @@ -38,6 +39,12 @@ public function createFromPostData($postData)
new NumericString($postData->last_four_digits)
);

if (isset($postData->created_at)) {
$createdAt = new \Datetime($postData->created_at);
$createdAt->setTimezone(MPSetup::getStoreTimezone());
$savedCard->setCreatedAt($createdAt);
}

return $savedCard;
}

Expand Down Expand Up @@ -70,6 +77,14 @@ public function createFromDbData($dbData)
new NumericString($dbData['last_four_digits'])
);

if (!empty($dbData['created_at'])) {
$createdAt = \Datetime::createFromFormat(
SavedCard::DATE_FORMAT,
$dbData['created_at']
);
$savedCard->setCreatedAt($createdAt);
}

return $savedCard;
}
}
6 changes: 4 additions & 2 deletions src/Payment/Repositories/SavedCardRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ protected function create(AbstractEntity &$object)
owner_name,
first_six_digits,
last_four_digits,
brand
brand,
created_at
)
VALUES
(
Expand All @@ -64,7 +65,8 @@ protected function create(AbstractEntity &$object)
'{$obj->ownerName}',
'{$obj->firstSixDigits}',
'{$obj->lastFourDigits}',
'{$obj->brand}'
'{$obj->brand}',
'{$obj->createdAt}'
)
";

Expand Down
2 changes: 0 additions & 2 deletions src/Payment/Services/ResponseHandlers/OrderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ private function handleOrderStatusPending(Order $order)
)
);

$this->saveCards($order);

$orderRepository = new OrderRepository();
$orderRepository->save($order);

Expand Down

0 comments on commit fb07420

Please sign in to comment.