Skip to content

Commit

Permalink
Release 2.7.0
Browse files Browse the repository at this point in the history
Release 2.7.0
  • Loading branch information
fabiano-mallmann authored Nov 12, 2024
2 parents 83eff71 + bee6daa commit bccf832
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 137 deletions.
84 changes: 42 additions & 42 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
{
"name": "pagarme/ecommerce-module-core",
"description": "Core component for Pagar.me e-commerce platform modules.",
"license": "MIT",
"version": "2.6.0",
"authors": [
{
"name":"Open Source Team"
}
],
"type": "library",
"require": {
"php": ">=7.1",
"monolog/monolog": "<3",
"pagarme/pagarmecoreapi": "v5.6.5",
"ext-json": "*"
},
"require-dev": {
"mockery/mockery": "1.2.4",
"nesbot/carbon": "1.39.0",
"ext-pdo": "*",
"phpunit/phpunit": "^5 | ^6 | ^7 | ^8 | ^9"
},
"autoload": {
"psr-4": {
"Pagarme\\Core\\": "src",
"Pagarme\\Core\\Test\\": "tests",
"Pagarme\\Core\\Test\\Mock\\": "tests\\mock"
}
},
"scripts": {
"post-install-cmd": [
"cp 'hooks/pre-commit' '.git/hooks/pre-commit'"
],
"post-update-cmd": [
"cp 'hooks/pre-commit' '.git/hooks/pre-commit'"
"name": "pagarme/ecommerce-module-core",
"description": "Core component for Pagar.me e-commerce platform modules.",
"license": "MIT",
"version": "2.7.0",
"authors": [
{
"name":"Open Source Team"
}
],
"tests": "vendor/bin/phpunit --colors=always",
"tests-coverage": "vendor/bin/phpunit --colors=always --coverage-html ./tests/report"
},
"config": {
"allow-plugins": {
"kylekatarnls/update-helper": true
"type": "library",
"require": {
"php": ">=7.1",
"monolog/monolog": "<3",
"pagarme/pagarmecoreapi": "v5.6.6",
"ext-json": "*"
},
"require-dev": {
"mockery/mockery": "1.2.4",
"nesbot/carbon": "1.39.0",
"ext-pdo": "*",
"phpunit/phpunit": "^5 | ^6 | ^7 | ^8 | ^9"
},
"autoload": {
"psr-4": {
"Pagarme\\Core\\": "src",
"Pagarme\\Core\\Test\\": "tests",
"Pagarme\\Core\\Test\\Mock\\": "tests\\mock"
}
},
"scripts": {
"post-install-cmd": [
"cp 'hooks/pre-commit' '.git/hooks/pre-commit'"
],
"post-update-cmd": [
"cp 'hooks/pre-commit' '.git/hooks/pre-commit'"
],
"tests": "vendor/bin/phpunit --colors=always",
"tests-coverage": "vendor/bin/phpunit --colors=always --coverage-html ./tests/report"
},
"config": {
"allow-plugins": {
"kylekatarnls/update-helper": true
}
}
}
}
6 changes: 3 additions & 3 deletions src/Kernel/Repositories/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function create(AbstractEntity &$object)
$order = json_decode(json_encode($object));

$query = "
INSERT INTO $orderTable (`pagarme_id`, `code`, `status`)
INSERT INTO $orderTable (`pagarme_id`, `code`, `status`)
VALUES ('{$order->pagarmeId}', '{$order->code}', '{$order->status}');
";

Expand Down Expand Up @@ -119,7 +119,7 @@ public function findByPlatformId($platformID)
$orderTable = $this->db->getTable(AbstractDatabaseDecorator::TABLE_ORDER);
$platformID = filter_var($platformID, FILTER_SANITIZE_SPECIAL_CHARS);
$query = "SELECT * FROM `$orderTable` ";
$query .= "WHERE code = '{$platformID}';";
$query .= "WHERE code = '{$platformID}' ORDER BY id DESC;";

$result = $this->db->fetch($query);

Expand All @@ -136,4 +136,4 @@ public function listEntities($limit, $listDisabled)
{
// TODO: Implement listEntities() method.
}
}
}
19 changes: 14 additions & 5 deletions src/Kernel/Services/ChargeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,20 @@ public function findChargeWithOutOrder($code)
{
$chargeRepository = new ChargeRepository();

try {
return $chargeRepository->findChargeWithOutOrder($code);
} catch (Exception $exception) {
throw new Exception($exception, $exception->getCode());
}
return $chargeRepository->findChargeWithOutOrder($code);
}

/**
* @param $code
*
* @return Charge[]
* @throws \Exception
*/
public function findChargesByCode($code)
{
$chargeRepository = new ChargeRepository();

return $chargeRepository->findChargesByCode($code);
}

/**
Expand Down
20 changes: 13 additions & 7 deletions src/Kernel/ValueObjects/CardBrand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ final class CardBrand extends AbstractValueObject
CONST SODEXO_PREMIUM = "SodexoPremium";
CONST SODEXO_REFEICAO = "SodexoRefeicao";
CONST SODEXO_COMBUSTIVEL = "SodexoCombustivel";
CONST TICKET = "Ticket";
CONST VR = "VR";
CONST ALELO = "Alelo";
CONST BANESE = "Banese";
Expand Down Expand Up @@ -134,6 +135,11 @@ static public function sodexocombustivel()
return new self(self::SODEXO_COMBUSTIVEL);
}

static public function ticket()
{
return new self(self::TICKET);
}

static public function vr()
{
return new self(self::VR);
Expand Down Expand Up @@ -172,13 +178,13 @@ protected function isEqual($object)
}

/**
* Specify data which should be serialized to JSON
*
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
* Specify data which should be serialized to JSON
*
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
Expand Down
33 changes: 0 additions & 33 deletions src/Middle/Model/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ class Account extends ModelWithErrors
{
const ACCOUNT_DISABLED = 'accountDisabled';

const DOMAIN_EMPTY = 'domainEmpty';

const DOMAIN_INCORRECT = 'domainIncorrect';

const WEBHOOK_INCORRECT = 'webhookIncorrect';

const MULTIPAYMENTS_DISABLED = 'multiPaymentsDisabled';
Expand Down Expand Up @@ -242,7 +238,6 @@ public function setDebitCardSettings($debitCardSettings)
public function validate($storeSettings = null)
{
$this->validateAccountEnabled();
$this->validateDomain($storeSettings);
$this->validateWebhooks($storeSettings);
$this->validateMultiBuyer();
$this->validateMultiPayments();
Expand All @@ -265,34 +260,6 @@ private function validateAccountEnabled()
}
}

/**
* @param StoreSettings|null $storeSettings
* @return void
*/
private function validateDomain($storeSettings = null)
{
$domains = $this->getDomains();
if (empty($domains) && (empty($storeSettings) || !$storeSettings->isSandbox())) {
$this->addError(self::DOMAIN_EMPTY);
return;
}

if ($this->canNotValidateUrlSetting($storeSettings)) {
return;
}

$siteUrls = $storeSettings->getStoreUrls();
foreach ($domains as $domain) {
foreach ($siteUrls as $siteUrl) {
if (strpos($siteUrl, $domain) !== false) {
return;
}
}
}

$this->addError(self::DOMAIN_INCORRECT);
}

/**
* @param StoreSettings|null $storeSettings
* @return void
Expand Down
15 changes: 12 additions & 3 deletions src/Middle/Model/Customer/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,24 @@ public function getNumber()
{
return $this->number ?? "";
}

public function getComplement()
{
return $this->complement ?? "";
}

public function getLine1()
{
$address = [$this->getNumber(), $this->getStreet(), $this->getNeighborhood()];
if (!empty($this->getNumber())) {
$address[] = $this->getNumber();
}

$address[] = $this->getStreet();

if (!empty($this->getNeighborhood())) {
$address[] = $this->getNeighborhood();
}

return implode(self::ADDRESS_SEPARATOR, $address);
}

Expand Down
65 changes: 26 additions & 39 deletions src/Payment/Aggregates/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public function setNumber($number)

$this->number = substr($numberWithoutLineBreaks, 0, 15);

if (empty($this->number) && ($this->number === null || !is_numeric(trim($this->number)))) {

if (empty(trim($this->number))) {
$inputName = $this->i18n->getDashboard('number');
$message = $this->i18n->getDashboard(
"The %s should not be empty!",
Expand Down Expand Up @@ -107,14 +106,8 @@ public function getStreet()
*/
public function setStreet($street)
{
$streetWithoutComma = str_replace(
self::ADDRESS_LINE_SEPARATOR,
'',
$street ?? ''
);

$streetWithoutLineBreaks = StringFunctionsHelper::removeLineBreaks(
$streetWithoutComma
$street
);

$this->street = substr($streetWithoutLineBreaks, 0, 64);
Expand All @@ -137,7 +130,7 @@ public function setStreet($street)
*/
public function getNeighborhood()
{
return $this->neighborhood;
return $this->neighborhood ?? '';
}

/**
Expand All @@ -159,17 +152,6 @@ public function setNeighborhood($neighborhood)

$this->neighborhood = substr($neighborhoodWithoutLineBreaks, 0, 64);

if (empty($this->neighborhood)) {

$inputName = $this->i18n->getDashboard('neighborhood');
$message = $this->i18n->getDashboard(
"The %s should not be empty!",
$inputName
);

throw new \Exception($message, 400);
}

return $this;
}

Expand Down Expand Up @@ -289,12 +271,17 @@ public function setCountry($country)

public function getLine1()
{
$line = [];
$line[] = $this->getNumber();
if ($this->getNumber()) {
$line[] = $this->getNumber();
}

$line[] = $this->getStreet();
$line[] = $this->getNeighborhood();

return implode (self::ADDRESS_LINE_SEPARATOR, $line);
if ($this->getNeighborhood()) {
$line[] = $this->getNeighborhood();
}

return implode(self::ADDRESS_LINE_SEPARATOR, $line);
}

public function getLine2()
Expand Down Expand Up @@ -334,21 +321,21 @@ public function setState($state)
}

/**
* Specify data which should be serialized to JSON
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
* @return string data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
* Specify data which should be serialized to JSON
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
* @return \stdClass data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$obj = new \stdClass();

$obj->number = $this->number;
$obj->street = $this->street;
$obj->neighborhood = $this->neighborhood;
$obj->number = $this->number;
$obj->complement = $this->complement;
$obj->neighborhood = $this->neighborhood;
$obj->zipCode = $this->zipCode;
$obj->city = $this->city;
$obj->state = $this->state;
Expand All @@ -366,16 +353,16 @@ public function convertToSDKRequest()
{
$addressRequest = new CreateAddressRequest();

$addressRequest->city = $this->getCity();
$addressRequest->street = $this->getStreet();
$addressRequest->number = $this->getNumber();
$addressRequest->complement = $this->getComplement();
$addressRequest->country = $this->getCountry();
$addressRequest->line1 = $this->getLine1();
$addressRequest->line2 = $this->getLine2();
$addressRequest->neighborhood = $this->getNeighborhood();
$addressRequest->number = $this->getNumber();
$addressRequest->city = $this->getCity();
$addressRequest->state = $this->getState();
$addressRequest->street = $this->getStreet();
$addressRequest->country = $this->getCountry();
$addressRequest->zipCode = $this->getZipCode();
$addressRequest->line1 = $this->getLine1();
$addressRequest->line2 = $this->getLine2();

return $addressRequest;
}
Expand Down
Loading

0 comments on commit bccf832

Please sign in to comment.