Skip to content

Commit bccf832

Browse files
Release 2.7.0
Release 2.7.0
2 parents 83eff71 + bee6daa commit bccf832

File tree

10 files changed

+134
-137
lines changed

10 files changed

+134
-137
lines changed

composer.json

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
{
2-
"name": "pagarme/ecommerce-module-core",
3-
"description": "Core component for Pagar.me e-commerce platform modules.",
4-
"license": "MIT",
5-
"version": "2.6.0",
6-
"authors": [
7-
{
8-
"name":"Open Source Team"
9-
}
10-
],
11-
"type": "library",
12-
"require": {
13-
"php": ">=7.1",
14-
"monolog/monolog": "<3",
15-
"pagarme/pagarmecoreapi": "v5.6.5",
16-
"ext-json": "*"
17-
},
18-
"require-dev": {
19-
"mockery/mockery": "1.2.4",
20-
"nesbot/carbon": "1.39.0",
21-
"ext-pdo": "*",
22-
"phpunit/phpunit": "^5 | ^6 | ^7 | ^8 | ^9"
23-
},
24-
"autoload": {
25-
"psr-4": {
26-
"Pagarme\\Core\\": "src",
27-
"Pagarme\\Core\\Test\\": "tests",
28-
"Pagarme\\Core\\Test\\Mock\\": "tests\\mock"
29-
}
30-
},
31-
"scripts": {
32-
"post-install-cmd": [
33-
"cp 'hooks/pre-commit' '.git/hooks/pre-commit'"
34-
],
35-
"post-update-cmd": [
36-
"cp 'hooks/pre-commit' '.git/hooks/pre-commit'"
2+
"name": "pagarme/ecommerce-module-core",
3+
"description": "Core component for Pagar.me e-commerce platform modules.",
4+
"license": "MIT",
5+
"version": "2.7.0",
6+
"authors": [
7+
{
8+
"name":"Open Source Team"
9+
}
3710
],
38-
"tests": "vendor/bin/phpunit --colors=always",
39-
"tests-coverage": "vendor/bin/phpunit --colors=always --coverage-html ./tests/report"
40-
},
41-
"config": {
42-
"allow-plugins": {
43-
"kylekatarnls/update-helper": true
11+
"type": "library",
12+
"require": {
13+
"php": ">=7.1",
14+
"monolog/monolog": "<3",
15+
"pagarme/pagarmecoreapi": "v5.6.6",
16+
"ext-json": "*"
17+
},
18+
"require-dev": {
19+
"mockery/mockery": "1.2.4",
20+
"nesbot/carbon": "1.39.0",
21+
"ext-pdo": "*",
22+
"phpunit/phpunit": "^5 | ^6 | ^7 | ^8 | ^9"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"Pagarme\\Core\\": "src",
27+
"Pagarme\\Core\\Test\\": "tests",
28+
"Pagarme\\Core\\Test\\Mock\\": "tests\\mock"
29+
}
30+
},
31+
"scripts": {
32+
"post-install-cmd": [
33+
"cp 'hooks/pre-commit' '.git/hooks/pre-commit'"
34+
],
35+
"post-update-cmd": [
36+
"cp 'hooks/pre-commit' '.git/hooks/pre-commit'"
37+
],
38+
"tests": "vendor/bin/phpunit --colors=always",
39+
"tests-coverage": "vendor/bin/phpunit --colors=always --coverage-html ./tests/report"
40+
},
41+
"config": {
42+
"allow-plugins": {
43+
"kylekatarnls/update-helper": true
44+
}
4445
}
45-
}
4646
}

src/Kernel/Repositories/OrderRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function create(AbstractEntity &$object)
2323
$order = json_decode(json_encode($object));
2424

2525
$query = "
26-
INSERT INTO $orderTable (`pagarme_id`, `code`, `status`)
26+
INSERT INTO $orderTable (`pagarme_id`, `code`, `status`)
2727
VALUES ('{$order->pagarmeId}', '{$order->code}', '{$order->status}');
2828
";
2929

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

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

@@ -136,4 +136,4 @@ public function listEntities($limit, $listDisabled)
136136
{
137137
// TODO: Implement listEntities() method.
138138
}
139-
}
139+
}

src/Kernel/Services/ChargeService.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,20 @@ public function findChargeWithOutOrder($code)
311311
{
312312
$chargeRepository = new ChargeRepository();
313313

314-
try {
315-
return $chargeRepository->findChargeWithOutOrder($code);
316-
} catch (Exception $exception) {
317-
throw new Exception($exception, $exception->getCode());
318-
}
314+
return $chargeRepository->findChargeWithOutOrder($code);
315+
}
316+
317+
/**
318+
* @param $code
319+
*
320+
* @return Charge[]
321+
* @throws \Exception
322+
*/
323+
public function findChargesByCode($code)
324+
{
325+
$chargeRepository = new ChargeRepository();
326+
327+
return $chargeRepository->findChargesByCode($code);
319328
}
320329

321330
/**

src/Kernel/ValueObjects/CardBrand.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ final class CardBrand extends AbstractValueObject
2626
CONST SODEXO_PREMIUM = "SodexoPremium";
2727
CONST SODEXO_REFEICAO = "SodexoRefeicao";
2828
CONST SODEXO_COMBUSTIVEL = "SodexoCombustivel";
29+
CONST TICKET = "Ticket";
2930
CONST VR = "VR";
3031
CONST ALELO = "Alelo";
3132
CONST BANESE = "Banese";
@@ -134,6 +135,11 @@ static public function sodexocombustivel()
134135
return new self(self::SODEXO_COMBUSTIVEL);
135136
}
136137

138+
static public function ticket()
139+
{
140+
return new self(self::TICKET);
141+
}
142+
137143
static public function vr()
138144
{
139145
return new self(self::VR);
@@ -172,13 +178,13 @@ protected function isEqual($object)
172178
}
173179

174180
/**
175-
* Specify data which should be serialized to JSON
176-
*
177-
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
178-
* @return mixed data which can be serialized by <b>json_encode</b>,
179-
* which is a value of any type other than a resource.
180-
* @since 5.4.0
181-
*/
181+
* Specify data which should be serialized to JSON
182+
*
183+
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
184+
* @return mixed data which can be serialized by <b>json_encode</b>,
185+
* which is a value of any type other than a resource.
186+
* @since 5.4.0
187+
*/
182188
#[\ReturnTypeWillChange]
183189
public function jsonSerialize()
184190
{

src/Middle/Model/Account.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ class Account extends ModelWithErrors
1111
{
1212
const ACCOUNT_DISABLED = 'accountDisabled';
1313

14-
const DOMAIN_EMPTY = 'domainEmpty';
15-
16-
const DOMAIN_INCORRECT = 'domainIncorrect';
17-
1814
const WEBHOOK_INCORRECT = 'webhookIncorrect';
1915

2016
const MULTIPAYMENTS_DISABLED = 'multiPaymentsDisabled';
@@ -242,7 +238,6 @@ public function setDebitCardSettings($debitCardSettings)
242238
public function validate($storeSettings = null)
243239
{
244240
$this->validateAccountEnabled();
245-
$this->validateDomain($storeSettings);
246241
$this->validateWebhooks($storeSettings);
247242
$this->validateMultiBuyer();
248243
$this->validateMultiPayments();
@@ -265,34 +260,6 @@ private function validateAccountEnabled()
265260
}
266261
}
267262

268-
/**
269-
* @param StoreSettings|null $storeSettings
270-
* @return void
271-
*/
272-
private function validateDomain($storeSettings = null)
273-
{
274-
$domains = $this->getDomains();
275-
if (empty($domains) && (empty($storeSettings) || !$storeSettings->isSandbox())) {
276-
$this->addError(self::DOMAIN_EMPTY);
277-
return;
278-
}
279-
280-
if ($this->canNotValidateUrlSetting($storeSettings)) {
281-
return;
282-
}
283-
284-
$siteUrls = $storeSettings->getStoreUrls();
285-
foreach ($domains as $domain) {
286-
foreach ($siteUrls as $siteUrl) {
287-
if (strpos($siteUrl, $domain) !== false) {
288-
return;
289-
}
290-
}
291-
}
292-
293-
$this->addError(self::DOMAIN_INCORRECT);
294-
}
295-
296263
/**
297264
* @param StoreSettings|null $storeSettings
298265
* @return void

src/Middle/Model/Customer/Address.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,24 @@ public function getNumber()
9393
{
9494
return $this->number ?? "";
9595
}
96-
96+
9797
public function getComplement()
9898
{
9999
return $this->complement ?? "";
100100
}
101-
101+
102102
public function getLine1()
103103
{
104-
$address = [$this->getNumber(), $this->getStreet(), $this->getNeighborhood()];
104+
if (!empty($this->getNumber())) {
105+
$address[] = $this->getNumber();
106+
}
107+
108+
$address[] = $this->getStreet();
109+
110+
if (!empty($this->getNeighborhood())) {
111+
$address[] = $this->getNeighborhood();
112+
}
113+
105114
return implode(self::ADDRESS_SEPARATOR, $address);
106115
}
107116

src/Payment/Aggregates/Address.php

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ public function setNumber($number)
7878

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

81-
if (empty($this->number) && ($this->number === null || !is_numeric(trim($this->number)))) {
82-
81+
if (empty(trim($this->number))) {
8382
$inputName = $this->i18n->getDashboard('number');
8483
$message = $this->i18n->getDashboard(
8584
"The %s should not be empty!",
@@ -107,14 +106,8 @@ public function getStreet()
107106
*/
108107
public function setStreet($street)
109108
{
110-
$streetWithoutComma = str_replace(
111-
self::ADDRESS_LINE_SEPARATOR,
112-
'',
113-
$street ?? ''
114-
);
115-
116109
$streetWithoutLineBreaks = StringFunctionsHelper::removeLineBreaks(
117-
$streetWithoutComma
110+
$street
118111
);
119112

120113
$this->street = substr($streetWithoutLineBreaks, 0, 64);
@@ -137,7 +130,7 @@ public function setStreet($street)
137130
*/
138131
public function getNeighborhood()
139132
{
140-
return $this->neighborhood;
133+
return $this->neighborhood ?? '';
141134
}
142135

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

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

162-
if (empty($this->neighborhood)) {
163-
164-
$inputName = $this->i18n->getDashboard('neighborhood');
165-
$message = $this->i18n->getDashboard(
166-
"The %s should not be empty!",
167-
$inputName
168-
);
169-
170-
throw new \Exception($message, 400);
171-
}
172-
173155
return $this;
174156
}
175157

@@ -289,12 +271,17 @@ public function setCountry($country)
289271

290272
public function getLine1()
291273
{
292-
$line = [];
293-
$line[] = $this->getNumber();
274+
if ($this->getNumber()) {
275+
$line[] = $this->getNumber();
276+
}
277+
294278
$line[] = $this->getStreet();
295-
$line[] = $this->getNeighborhood();
296279

297-
return implode (self::ADDRESS_LINE_SEPARATOR, $line);
280+
if ($this->getNeighborhood()) {
281+
$line[] = $this->getNeighborhood();
282+
}
283+
284+
return implode(self::ADDRESS_LINE_SEPARATOR, $line);
298285
}
299286

300287
public function getLine2()
@@ -334,21 +321,21 @@ public function setState($state)
334321
}
335322

336323
/**
337-
* Specify data which should be serialized to JSON
338-
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
339-
* @return string data which can be serialized by <b>json_encode</b>,
340-
* which is a value of any type other than a resource.
341-
* @since 5.4.0
342-
*/
324+
* Specify data which should be serialized to JSON
325+
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
326+
* @return \stdClass data which can be serialized by <b>json_encode</b>,
327+
* which is a value of any type other than a resource.
328+
* @since 5.4.0
329+
*/
343330
#[\ReturnTypeWillChange]
344331
public function jsonSerialize()
345332
{
346333
$obj = new \stdClass();
347334

348-
$obj->number = $this->number;
349335
$obj->street = $this->street;
350-
$obj->neighborhood = $this->neighborhood;
336+
$obj->number = $this->number;
351337
$obj->complement = $this->complement;
338+
$obj->neighborhood = $this->neighborhood;
352339
$obj->zipCode = $this->zipCode;
353340
$obj->city = $this->city;
354341
$obj->state = $this->state;
@@ -366,16 +353,16 @@ public function convertToSDKRequest()
366353
{
367354
$addressRequest = new CreateAddressRequest();
368355

369-
$addressRequest->city = $this->getCity();
356+
$addressRequest->street = $this->getStreet();
357+
$addressRequest->number = $this->getNumber();
370358
$addressRequest->complement = $this->getComplement();
371-
$addressRequest->country = $this->getCountry();
372-
$addressRequest->line1 = $this->getLine1();
373-
$addressRequest->line2 = $this->getLine2();
374359
$addressRequest->neighborhood = $this->getNeighborhood();
375-
$addressRequest->number = $this->getNumber();
360+
$addressRequest->city = $this->getCity();
376361
$addressRequest->state = $this->getState();
377-
$addressRequest->street = $this->getStreet();
362+
$addressRequest->country = $this->getCountry();
378363
$addressRequest->zipCode = $this->getZipCode();
364+
$addressRequest->line1 = $this->getLine1();
365+
$addressRequest->line2 = $this->getLine2();
379366

380367
return $addressRequest;
381368
}

0 commit comments

Comments
 (0)