From 080cb9db6902e7f71213707417caa19fdb0a6d35 Mon Sep 17 00:00:00 2001 From: Matheus Marques Date: Thu, 13 Jul 2023 10:43:11 -0300 Subject: [PATCH 1/6] Ajustes --- src/Rede/Brand.php | 23 +++++++++++++++ src/Rede/Exception/RedeException.php | 29 +++++++++++++++++++ .../Service/AbstractTransactionsService.php | 4 ++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/Rede/Brand.php b/src/Rede/Brand.php index 97caeb5..f2cbaf4 100644 --- a/src/Rede/Brand.php +++ b/src/Rede/Brand.php @@ -21,6 +21,11 @@ class Brand */ private $returnMessage; + /** + * @var string + */ + private $authorizationCode; + /** * @return string */ @@ -78,5 +83,23 @@ public function setReturnMessage(string $returnMessage): Brand return $this; } + /** + * @param string $authorizationCode + * + * @return Brand + */ + public function setAuthorizationCode(string $authorizationCode): Brand + { + $this->authorizationCode = $authorizationCode; + return $this; + } + + /** + * @return string + */ + public function getAuthorizationCode(): string + { + return $this->authorizationCode; + } } \ No newline at end of file diff --git a/src/Rede/Exception/RedeException.php b/src/Rede/Exception/RedeException.php index 41d6f3e..77e388c 100644 --- a/src/Rede/Exception/RedeException.php +++ b/src/Rede/Exception/RedeException.php @@ -2,8 +2,37 @@ namespace Rede\Exception; +use Rede\Transaction; use RuntimeException; +use Throwable; class RedeException extends RuntimeException { + private ?string $response = null; + + private ?Transaction $transaction = null; + + public function __construct($message = "", $code = 0, ?Throwable $previous = null, string $response = null, ?Transaction $transaction = null) + { + parent::__construct($message, $code, $previous); + + $this->response = $response; + $this->transaction = $transaction; + } + + /** + * @return string|null + */ + public function getResponse(): ?string + { + return $this->response; + } + + /** + * @return Transaction|null + */ + public function getTransaction(): ?Transaction + { + return $this->transaction; + } } diff --git a/src/Rede/Service/AbstractTransactionsService.php b/src/Rede/Service/AbstractTransactionsService.php index 24297a3..a1bcacc 100644 --- a/src/Rede/Service/AbstractTransactionsService.php +++ b/src/Rede/Service/AbstractTransactionsService.php @@ -100,7 +100,9 @@ protected function parseResponse($response, $statusCode) throw new RedeException( $this->transaction->getReturnMessage(), $this->transaction->getReturnCode(), - $previous + $previous, + $response, + $this->transaction ); } From 2c143d2fdeeb5b894ec175bda04969f9a1c92ef6 Mon Sep 17 00:00:00 2001 From: Matheus Marques Date: Thu, 13 Jul 2023 11:26:19 -0300 Subject: [PATCH 2/6] Ajsutes --- src/Rede/Authorization.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Rede/Authorization.php b/src/Rede/Authorization.php index b254d9c..3732393 100644 --- a/src/Rede/Authorization.php +++ b/src/Rede/Authorization.php @@ -94,6 +94,11 @@ class Authorization */ private $tid; + /** + * @var array + */ + private $brand; + /** * @return string */ @@ -417,4 +422,20 @@ public function setTid($tid) $this->tid = $tid; return $this; } + + /** + * @return array + */ + public function getBrand(): ?array + { + return $this->brand; + } + + /** + * @param array $brand + */ + public function setBrand(array $brand): void + { + $this->brand = $brand; + } } \ No newline at end of file From 7834cf243fa74dd0a90b1a62d1e4598f8c527b89 Mon Sep 17 00:00:00 2001 From: Matheus Marques Date: Thu, 13 Jul 2023 11:36:17 -0300 Subject: [PATCH 3/6] Mais ajustes --- src/Rede/Authorization.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Rede/Authorization.php b/src/Rede/Authorization.php index 3732393..389732b 100644 --- a/src/Rede/Authorization.php +++ b/src/Rede/Authorization.php @@ -95,7 +95,7 @@ class Authorization private $tid; /** - * @var array + * @var object */ private $brand; @@ -424,17 +424,17 @@ public function setTid($tid) } /** - * @return array + * @return object */ - public function getBrand(): ?array + public function getBrand() { return $this->brand; } /** - * @param array $brand + * @param object $brand */ - public function setBrand(array $brand): void + public function setBrand($brand): void { $this->brand = $brand; } From dea7703c781cda8b8451aeb5f8c5b63cd4f458e6 Mon Sep 17 00:00:00 2001 From: Matheus Marques Date: Wed, 10 Jun 2026 15:11:58 -0300 Subject: [PATCH 4/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 863cc46..711c984 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "php": ">=7.2", "ext-curl": "*", "ext-json": "*", - "psr/log": "^1.1", + "psr/log": "^1.1 ||^2.0 || ^3.0", "monolog/monolog": "*" }, "require-dev": { From 89fdf84d8c93b0a6b59c1574b55b026854a99111 Mon Sep 17 00:00:00 2001 From: Matheus Marques Date: Tue, 16 Jun 2026 13:45:44 -0300 Subject: [PATCH 5/6] bump php --- Dockerfile | 2 +- composer.json | 2 +- src/Rede/Environment.php | 2 +- src/Rede/Exception/RedeException.php | 2 +- src/Rede/SerializeTrait.php | 2 +- src/Rede/Service/AbstractService.php | 2 +- src/Rede/Service/AbstractTransactionsService.php | 2 +- src/Rede/Store.php | 2 +- src/Rede/Transaction.php | 6 ++++-- src/Rede/eRede.php | 2 +- 10 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9a2ecfe..72463e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.2-cli +FROM php:8.2-cli LABEL maintainer="neto.joaobatista@gmail.com" RUN apt -y update && apt -y install zlib1g-dev zip diff --git a/composer.json b/composer.json index 711c984..b671b88 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "license": "MIT", "type": "library", "require": { - "php": ">=7.2", + "php": ">=8.2", "ext-curl": "*", "ext-json": "*", "psr/log": "^1.1 ||^2.0 || ^3.0", diff --git a/src/Rede/Environment.php b/src/Rede/Environment.php index 2daf62d..5dfccde 100644 --- a/src/Rede/Environment.php +++ b/src/Rede/Environment.php @@ -104,7 +104,7 @@ public function setSessionId($sessionId) /** * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { $consumer = new stdClass(); $consumer->ip = $this->ip; diff --git a/src/Rede/Exception/RedeException.php b/src/Rede/Exception/RedeException.php index 77e388c..c687b5a 100644 --- a/src/Rede/Exception/RedeException.php +++ b/src/Rede/Exception/RedeException.php @@ -12,7 +12,7 @@ class RedeException extends RuntimeException private ?Transaction $transaction = null; - public function __construct($message = "", $code = 0, ?Throwable $previous = null, string $response = null, ?Transaction $transaction = null) + public function __construct($message = "", $code = 0, ?Throwable $previous = null, ?string $response = null, ?Transaction $transaction = null) { parent::__construct($message, $code, $previous); diff --git a/src/Rede/SerializeTrait.php b/src/Rede/SerializeTrait.php index 6ec13af..b7ffafb 100644 --- a/src/Rede/SerializeTrait.php +++ b/src/Rede/SerializeTrait.php @@ -7,7 +7,7 @@ trait SerializeTrait /** * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { return array_filter(get_object_vars($this), function ($v) { return $v !== null; diff --git a/src/Rede/Service/AbstractService.php b/src/Rede/Service/AbstractService.php index 1d48e14..af4c93d 100644 --- a/src/Rede/Service/AbstractService.php +++ b/src/Rede/Service/AbstractService.php @@ -47,7 +47,7 @@ abstract class AbstractService * @param Store $store * @param LoggerInterface|null $logger */ - public function __construct(Store $store, LoggerInterface $logger = null) + public function __construct(Store $store, ?LoggerInterface $logger = null) { $this->store = $store; $this->logger = $logger; diff --git a/src/Rede/Service/AbstractTransactionsService.php b/src/Rede/Service/AbstractTransactionsService.php index a1bcacc..b9f8d20 100644 --- a/src/Rede/Service/AbstractTransactionsService.php +++ b/src/Rede/Service/AbstractTransactionsService.php @@ -29,7 +29,7 @@ abstract class AbstractTransactionsService extends AbstractService * @param Transaction|null $transaction * @param LoggerInterface|null $logger */ - public function __construct(Store $store, Transaction $transaction = null, LoggerInterface $logger = null) + public function __construct(Store $store, ?Transaction $transaction = null, ?LoggerInterface $logger = null) { parent::__construct($store, $logger); diff --git a/src/Rede/Store.php b/src/Rede/Store.php index b0bbbaf..9dd9d70 100644 --- a/src/Rede/Store.php +++ b/src/Rede/Store.php @@ -29,7 +29,7 @@ class Store * @param string $token * @param Environment|null $environment if none provided, production will be used. */ - public function __construct($filiation, $token, Environment $environment = null) + public function __construct($filiation, $token, ?Environment $environment = null) { $environment = $environment != null ? $environment : Environment::production(); diff --git a/src/Rede/Transaction.php b/src/Rede/Transaction.php index 55e24e3..f77ae56 100644 --- a/src/Rede/Transaction.php +++ b/src/Rede/Transaction.php @@ -337,7 +337,7 @@ public function capture($capture = true) * @return array * @see \JsonSerializable::jsonSerialize() */ - public function jsonSerialize() + public function jsonSerialize(): array { $capture = null; @@ -446,7 +446,9 @@ public function jsonUnserialize($serialized) continue; } - $this->$property = $value; + if (property_exists($this, $property)) { + $this->$property = $value; + } } return $this; diff --git a/src/Rede/eRede.php b/src/Rede/eRede.php index 7790c11..899fe67 100644 --- a/src/Rede/eRede.php +++ b/src/Rede/eRede.php @@ -39,7 +39,7 @@ class eRede * @param Store $store * @param LoggerInterface|null $logger */ - public function __construct(Store $store, LoggerInterface $logger = null) + public function __construct(Store $store, ?LoggerInterface $logger = null) { $this->store = $store; $this->logger = $logger; From c43dc6b87140b51ee608bec81d41dd9a1560173f Mon Sep 17 00:00:00 2001 From: Matheus Marques Date: Mon, 22 Jun 2026 16:30:43 -0300 Subject: [PATCH 6/6] Remove uso de curl_close --- src/Rede/Service/AbstractService.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Rede/Service/AbstractService.php b/src/Rede/Service/AbstractService.php index af4c93d..5f40c5b 100644 --- a/src/Rede/Service/AbstractService.php +++ b/src/Rede/Service/AbstractService.php @@ -93,10 +93,6 @@ protected function sendRequest($body = '', $method = 'GET') $userAgent .= sprintf(' %s/%s', $this->platform, $this->platformVersion); } - if (is_resource($this->curl)) { - curl_close($this->curl); - } - $curlVersion = curl_version(); if (is_array($curlVersion)) { @@ -194,8 +190,6 @@ protected function sendRequest($body = '', $method = 'GET') throw new RuntimeException(sprintf('Curl error[%s]: %s', curl_errno($this->curl), curl_error($this->curl))); } - curl_close($this->curl); - $this->curl = null; return $this->parseResponse($response, $httpInfo['http_code']);