From d2137a5eb1a24c324b6190a3ced716244ec08aa1 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Tue, 8 Nov 2022 11:36:41 -0300 Subject: [PATCH 01/17] Allow guzzle versions from 6.4 up to 7.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8b3caa4..a1a3631 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "license": "MIT", "require": { "php": ">=5.6.0", - "guzzlehttp/guzzle": "^6.4" + "guzzlehttp/guzzle": ">=6.4" }, "require-dev": { "phpunit/phpunit": "^8", From bca0f5e848d2bfc508ddd95332530c0a3b162324 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Wed, 9 Nov 2022 11:34:12 -0300 Subject: [PATCH 02/17] Added additional Beans --- src/Beans/Customer.php | 385 +++++++++++++++++++++++++++++++++++++++ src/Beans/DeviceInfo.php | 301 ++++++++++++++++++++++++++++++ src/Beans/LineItem.php | 161 ++++++++++++++++ src/Beans/ShipTo.php | 275 ++++++++++++++++++++++++++++ 4 files changed, 1122 insertions(+) create mode 100644 src/Beans/Customer.php create mode 100644 src/Beans/DeviceInfo.php create mode 100644 src/Beans/LineItem.php create mode 100644 src/Beans/ShipTo.php diff --git a/src/Beans/Customer.php b/src/Beans/Customer.php new file mode 100644 index 0000000..443d021 --- /dev/null +++ b/src/Beans/Customer.php @@ -0,0 +1,385 @@ +documentType; + } + + /** + * Tipo do documento de identificação do comprador(CPF, CNPJ) + * + * @param string $value | cpf, cnpj + * @return void + */ + public function setDocumentType(string $value) + { + $this->documentType = $value; + return $this; + } + + /** + * Número do documento do comprador sem pontuação (sem máscara) + * + * @return void + */ + public function getDocumentNumber() + { + return $this->documentNumber; + } + + /** + * Número do documento do comprador sem pontuação (sem máscara) + * + * @param string $value + * @return void + */ + public function setDocumentNumber(string $value) + { + $this->documentNumber = $value; + return $this; + } + + /** + * Primeiro nome do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * Primeiro nome do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setFirstName(string $value) + { + $this->firstName = $value; + return $this; + } + + /** + * Último nome do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * Último nome do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setLastName(string $value) + { + $this->lastName = $value; + return $this; + } + + /** + * E-mail do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getEmail() + { + return $this->email; + } + + /** + * E-mail do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setEmail(string $value) + { + $this->email = $value; + return $this; + } + + /** + * Telefone do comprador (sem máscara) - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getPhoneNumber() + { + return $this->phoneNumber; + } + + /** + * Telefone do comprador (sem máscara) - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setPhoneNumber(string $value) + { + $this->phoneNumber = $value; + return $this; + } + + /** + * Telefone celular do comprador (sem máscara) - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getMobilePhoneNumber() + { + return $this->mobilePhoneNumber; + } + + /** + * Telefone celular do comprador (sem máscara) - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setMobilePhoneNumber(string $value) + { + $this->mobilePhoneNumber = $value; + return $this; + } + + /** + * Endereço do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getAddress() + { + return $this->address; + } + + /** + * Endereço do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setAddress(string $value) + { + $this->address = $value; + return $this; + } + + /** + * Complemento do endereço do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getComplement() + { + return $this->complement; + } + + /** + * Complemento do endereço do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setComplement(string $value) + { + $this->complement = $value; + return $this; + } + + /** + * Cidade do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getCity() + { + return $this->city; + } + + /** + * Cidade do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setCity(string $value) + { + $this->city = $value; + return $this; + } + + /** + * Estado do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getState() + { + return $this->state; + } + + /** + * Estado do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setState(string $value) + { + $this->state = $value; + return $this; + } + + /** + * CEP comprador (sem máscara) - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getZipCode() + { + return $this->zipCode; + } + + /** + * CEP comprador (sem máscara) - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setZipCode(string $value) + { + $this->zipCode = $value; + return $this; + } + + /** + * Endereço IP do dispositivo do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getIpAddress() + { + return $this->ipAddress; + } + + /** + * Endereço IP do dispositivo do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setIpAddress(string $value) + { + $this->ipAddress = $value; + return $this; + } + + /** + * Converts to data array + * + * @return void + */ + public function getCustomerData() + { + return [ + 'DocumentType' => $this->documentType, + 'DocumentNumber' => $this->documentNumber, + 'FirstName' => $this->firstName, + 'LastName' => $this->lastName, + 'Email' => $this->email, + 'PhoneNumber' => $this->phoneNumber, + 'MobilePhoneNumber' => $this->mobilePhoneNumber, + 'Address' => $this->address, + 'Complement' => $this->complement, + 'City' => $this->city, + 'State' => $this->state, + 'ZipCode' => $this->zipCode, + 'IpAddress' => $this->ipAddress, + ]; + } +} diff --git a/src/Beans/DeviceInfo.php b/src/Beans/DeviceInfo.php new file mode 100644 index 0000000..97ff798 --- /dev/null +++ b/src/Beans/DeviceInfo.php @@ -0,0 +1,301 @@ +httpAcceptBrowserValue; + } + + /** + * Valor do “Accept Header” do browser do cliente - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpAcceptBrowserValue(string $value) + { + $this->httpAcceptBrowserValue = $value; + return $this; + } + + /** + * Valor exato do HTTP Accept Header - Obrigatório para 3DS. + * + * @return void + */ + public function getHttpAcceptContent() + { + return $this->httpAcceptContent; + } + + /** + * Valor exato do HTTP Accept Header - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpAcceptContent(string $value) + { + $this->httpAcceptContent = $value; + return $this; + } + + /** + * Linguagem do browser do cliente conforme https://www.techonthenet.com/js/language_tags.php - Obrigatório para 3DS. + * + * @return void + */ + public function getHttpBrowserLanguage() + { + return $this->httpBrowserLanguage; + } + + /** + * Linguagem do browser do cliente conforme https://www.techonthenet.com/js/language_tags.php - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpBrowserLanguage(string $value) + { + $this->httpBrowserLanguage = $value; + return $this; + } + + /** + * Se JAVA habilitado enviar valor Y, caso contrário N - Obrigatório para 3DS. + * + * @return void + */ + public function getHttpBrowserJavaEnabled() + { + return $this->httpBrowserJavaEnabled; + } + + /** + * Se JAVA habilitado enviar valor Y, caso contrário N - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpBrowserJavaEnabled(string $value) + { + $this->httpBrowserJavaEnabled = $value; + return $this; + } + + /** + * Se JAVA SCRIPT habilitado enviar valor Y, caso contrário N - Obrigatório para 3DS. + * + * @return void + */ + public function getHttpBrowserJavaScriptEnabled() + { + return $this->httpBrowserJavaScriptEnabled; + } + + /** + * Se JAVA SCRIPT habilitado enviar valor Y, caso contrário N - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpBrowserJavaScriptEnabled(string $value) + { + $this->httpBrowserJavaScriptEnabled = $value; + return $this; + } + + /** + * Quantidade de bits utilizados para exibição de imagens - Obrigatório para 3DS. + * + * @return void + */ + public function getHttpBrowserColorDepth() + { + return $this->httpBrowserColorDepth; + } + + /** + * Quantidade de bits utilizados para exibição de imagens - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpBrowserColorDepth(string $value) + { + $this->httpBrowserColorDepth = $value; + return $this; + } + + /** + * Altura da resolução da tela do cliente - Obrigatório para 3DS. + * + * @return void + */ + public function getHttpBrowserScreenHeight() + { + return $this->httpBrowserScreenHeight; + } + + /** + * Altura da resolução da tela do cliente - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpBrowserScreenHeight(string $value) + { + $this->httpBrowserScreenHeight = $value; + return $this; + } + + /** + * Largura da resolução da tela do cliente - Obrigatório para 3DS. + * + * @return void + */ + public function getHttpBrowserScreenWidth() + { + return $this->httpBrowserScreenWidth; + } + + /** + * Largura da resolução da tela do cliente - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpBrowserScreenWidth(string $value) + { + $this->httpBrowserScreenWidth = $value; + return $this; + } + + /** + * Diferença em minutos entre o horário GMT e o do browser do cliente - Obrigatório para 3DS. + * + * @return void + */ + public function getHttpBrowserTimeDifference() + { + return $this->httpBrowserTimeDifference; + } + + /** + * Diferença em minutos entre o horário GMT e o do browser do cliente - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setHttpBrowserTimeDifference(string $value) + { + $this->httpBrowserTimeDifference = $value; + return $this; + } + + /** + * O valor exato do User Agent Header - Obrigatório para 3DS. + * + * @return void + */ + public function getUserAgentBrowserValue() + { + return $this->userAgentBrowserValue; + } + + /** + * O valor exato do User Agent Header - Obrigatório para 3DS. + * + * @param string $value + * @return void + */ + public function setUserAgentBrowserValue(string $value) + { + $this->userAgentBrowserValue = $value; + return $this; + } + + /** + * Converts to data array + * + * @return void + */ + public function getDeviceInfoData() + { + return [ + 'httpAcceptBrowserValue' => $this->httpAcceptBrowserValue, + 'httpAcceptContent' => $this->httpAcceptContent, + 'httpBrowserLanguage' => $this->httpBrowserLanguage, + 'httpBrowserJavaEnabled' => $this->httpBrowserJavaEnabled, + 'httpBrowserJavaScriptEnabled' => $this->httpBrowserJavaScriptEnabled, + 'httpBrowserColorDepth' => $this->httpBrowserColorDepth, + 'httpBrowserScreenHeight' => $this->httpBrowserScreenHeight, + 'httpBrowserScreenWidth' => $this->httpBrowserScreenWidth, + 'httpBrowserTimeDifference' => $this->httpBrowserTimeDifference, + 'userAgentBrowserValue' => $this->userAgentBrowserValue, + ]; + } +} diff --git a/src/Beans/LineItem.php b/src/Beans/LineItem.php new file mode 100644 index 0000000..169be9d --- /dev/null +++ b/src/Beans/LineItem.php @@ -0,0 +1,161 @@ +productCode; + } + + /** + * Tipo do produto - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setProductCode(string $value) + { + $this->productCode = $value; + return $this; + } + + /** + * Identificador do produto na loja - Obrigatório para antifraude. + * + * @return void + */ + public function getProductSKU() + { + return $this->productSku; + } + + /** + * Identificador do produto na loja - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setProductSKU(string $value) + { + $this->productSku = $value; + return $this; + } + + /** + * Nome do produto - Obrigatório para antifraude. + * + * @return void + */ + public function getProductName() + { + return $this->productName; + } + + /** + * Nome do produto - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setProductName(string $value) + { + $this->productName = $value; + return $this; + } + + /** + * Quantidade dos produtos sendo adquiridos - Obrigatório para antifraude. + * + * @return void + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Quantidade dos produtos sendo adquiridos - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setQuantity(string $value) + { + $this->quantity = $value; + return $this; + } + + /** + * Preço do produto (por item) - Obrigatório para antifraude. + * + * @return void + */ + public function getUnitPrice() + { + return $this->unitPrice; + } + + /** + * Preço do produto (por item) - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setUnitPrice(string $value) + { + $this->unitPrice = $value; + return $this; + } + + /** + * Converts to data array + * + * @return void + */ + public function getLineItemData() + { + return [ + 'ProductCode' => $this->productCode, + 'ProductSKU' => $this->productSku, + 'ProductName' => $this->productName, + 'Quantity' => $this->quantity, + 'UnitPrice' => $this->unitPrice, + ]; + } +} diff --git a/src/Beans/ShipTo.php b/src/Beans/ShipTo.php new file mode 100644 index 0000000..6f51975 --- /dev/null +++ b/src/Beans/ShipTo.php @@ -0,0 +1,275 @@ +firstName; + } + + /** + * Primeiro nome do comprador - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setFirstName(string $value) + { + $this->firstName = $value; + return $this; + } + + /** + * Último nome do comprador - Obrigatório para antifraude. + * + * @return void + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * Último nome do comprador - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setLastName(string $value) + { + $this->lastName = $value; + return $this; + } + + /** + * Telefone do comprador (sem máscara) - Obrigatório para antifraude. + * + * @return void + */ + public function getPhoneNumber() + { + return $this->phoneNumber; + } + + /** + * Telefone do comprador (sem máscara) - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setPhoneNumber(string $value) + { + $this->phoneNumber = $value; + return $this; + } + + /** + * Endereço do comprador - Obrigatório para antifraude. + * + * @return void + */ + public function getAddress() + { + return $this->address; + } + + /** + * Endereço do comprador - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setAddress(string $value) + { + $this->address = $value; + return $this; + } + + /** + * Complemento do endereço do comprador - Obrigatório para antifraude. + * + * @return void + */ + public function getComplement() + { + return $this->complement; + } + + /** + * Complemento do endereço do comprador - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setComplement(string $value) + { + $this->complement = $value; + return $this; + } + + /** + * Cidade do comprador - Obrigatório para antifraude. + * + * @return void + */ + public function getCity() + { + return $this->city; + } + + /** + * Cidade do comprador - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setCity(string $value) + { + $this->city = $value; + return $this; + } + + /** + * Estado do comprador - Obrigatório para antifraude. + * + * @return void + */ + public function getState() + { + return $this->state; + } + + /** + * Estado do comprador - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setState(string $value) + { + $this->state = $value; + return $this; + } + + /** + * CEP comprador (sem máscara) - Obrigatório para antifraude. + * + * @return void + */ + public function getZipCode() + { + return $this->zipCode; + } + + /** + * CEP comprador (sem máscara) - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setZipCode(string $value) + { + $this->zipCode = $value; + return $this; + } + + /** + * Pais do endereço do comprador - Obrigatório para antifraude. + * + * @return void + */ + public function getCountry() + { + return $this->country; + } + + /** + * Pais do endereço do comprador - Obrigatório para antifraude. + * + * @param string $value + * @return void + */ + public function setCountry(string $value) + { + $this->country = $value; + return $this; + } + + + /** + * Converts to data array + * + * @return void + */ + public function getLineItemData() + { + return [ + 'FirstName' => $this->firstName, + 'LastName' => $this->lastName, + 'PhoneNumber' => $this->phoneNumber, + 'Address' => $this->address, + 'Complement' => $this->complement, + 'City' => $this->city, + 'State' => $this->state, + 'ZipCode' => $this->zipCode, + 'Country' => $this->country, + ]; + } +} From 659a7509b7ab38952825459c979a9f7873009226 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Wed, 9 Nov 2022 11:34:37 -0300 Subject: [PATCH 03/17] Added support for resuming ongoing access tokens --- src/Client.php | 59 +++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/Client.php b/src/Client.php index 89a7f70..547419f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -37,12 +37,12 @@ class Client * @var \Adiq\Endpoints\Payment */ private $payment; - + /** * @var \Adiq\Endpoints\Card */ private $card; - + /** * @var \Adiq\Endpoints\Card */ @@ -52,27 +52,27 @@ class Client * @var \Adiq\Endpoints\Auth */ private $auth; - + /** * @var string */ private $accessToken; - + /** * @var string */ private $tokenType; - + /** * @var string */ private $expiresIn; - + /** * @var string */ private $scope; - + /** * @var bool */ @@ -85,7 +85,7 @@ class Client */ public function __construct(array $extras = null, bool $sandbox = false) { - if($sandbox) { + if ($sandbox) { $base_url = self::BASE_URI_SANDBOX; } else { $base_url = self::BASE_URI; @@ -116,6 +116,23 @@ public function __construct(array $extras = null, bool $sandbox = false) $this->auth = new Auth($this); } + /** + * Updates the current access token to be used. + * + * @param string $accessToken + * @param string $tokenType + * @param int $expiresIn + * @param string $scope + * @return void + */ + public function setAccessToken($accessToken, $tokenType, $expiresIn, $scope) + { + $this->accessToken = $accessToken; + $this->tokenType = $tokenType; + $this->expiresIn = $expiresIn; + $this->scope = $scope; + } + /** * @param string $method * @param string $uri @@ -133,13 +150,13 @@ public function request($method, $uri, $options = [], $header = []) $userAgent = isset($header['headers']['User-Agent']) ? $header['headers']['User-Agent'] : ''; - if(isset($header) && !empty($header)) { - if($this->sandbox) { + if (isset($header) && !empty($header)) { + if ($this->sandbox) { $base_url = self::BASE_URI_SANDBOX; } else { $base_url = self::BASE_URI; } - + $options = array_merge($options, ['base_uri' => $base_url]); $authorization = isset($header['Authorization']) ? @@ -150,7 +167,7 @@ public function request($method, $uri, $options = [], $header = []) $this->http = new HttpClient($options); } - + $response = $this->http->request( $method, $uri, @@ -158,11 +175,9 @@ public function request($method, $uri, $options = [], $header = []) ); $body = ResponseHandler::success((string)$response->getBody()); - if(isset($body->accessToken) && !empty($body->accessToken)) { - $this->accessToken = $body->accessToken; - $this->tokenType = $body->tokenType; - $this->expiresIn = $body->expiresIn; - $this->scope = $body->scope; + + if (isset($body->accessToken) && !empty($body->accessToken)) { + $this->setAccessToken($body->accessToken, $body->tokenType, $body->expiresIn, $body->scope); } return $body; @@ -232,7 +247,7 @@ public function marketplace() { return $this->marketplace; } - + /** * @return \Adiq\Endpoints\Auth */ @@ -240,7 +255,7 @@ public function auth() { return $this->auth; } - + /** * @return string */ @@ -248,7 +263,7 @@ public function getAccessToken() { return $this->accessToken; } - + /** * @return string */ @@ -256,7 +271,7 @@ public function getTokenType() { return $this->tokenType; } - + /** * @return string */ @@ -264,7 +279,7 @@ public function getExpiresIn() { return $this->expiresIn; } - + /** * @return string */ From 2d6ed237187c49768115ed3452dddc5283604dab Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Wed, 9 Nov 2022 12:35:36 -0300 Subject: [PATCH 04/17] Added Country attribute in Customer --- src/Beans/Customer.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Beans/Customer.php b/src/Beans/Customer.php index 443d021..bc875d6 100644 --- a/src/Beans/Customer.php +++ b/src/Beans/Customer.php @@ -5,7 +5,7 @@ class Customer { /** - * @var string | cpf, cnpj + * @var int | 1-cpf, 2-cnpj */ private $documentType; @@ -59,6 +59,11 @@ class Customer */ private $state; + /** + * @var string + */ + private $country; + /** * @var string */ @@ -89,7 +94,7 @@ public function getDocumentType() * @param string $value | cpf, cnpj * @return void */ - public function setDocumentType(string $value) + public function setDocumentType(int $value) { $this->documentType = $value; return $this; @@ -315,6 +320,28 @@ public function setState(string $value) return $this; } + /** + * País do comprador - Obrigatório para 3DS/antifraude. + * + * @return void + */ + public function getCountry() + { + return $this->country; + } + + /** + * País do comprador - Obrigatório para 3DS/antifraude. + * + * @param string $value + * @return void + */ + public function setCountry(string $value) + { + $this->country = $value; + return $this; + } + /** * CEP comprador (sem máscara) - Obrigatório para 3DS/antifraude. * From de055edb5ce3c68d761a98041d4ae3d86848b319 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Wed, 9 Nov 2022 12:57:44 -0300 Subject: [PATCH 05/17] Fix typo --- src/Beans/ShipTo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Beans/ShipTo.php b/src/Beans/ShipTo.php index 6f51975..d00ff50 100644 --- a/src/Beans/ShipTo.php +++ b/src/Beans/ShipTo.php @@ -258,7 +258,7 @@ public function setCountry(string $value) * * @return void */ - public function getLineItemData() + public function getShipToData() { return [ 'FirstName' => $this->firstName, From ea9d64b31e5cacdcb8bb33a27f80613f063e0875 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Wed, 9 Nov 2022 17:10:38 -0300 Subject: [PATCH 06/17] Bumping API version to /v2 --- src/Beans/ShipTo.php | 1 - src/Client.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Beans/ShipTo.php b/src/Beans/ShipTo.php index d00ff50..2836f5f 100644 --- a/src/Beans/ShipTo.php +++ b/src/Beans/ShipTo.php @@ -252,7 +252,6 @@ public function setCountry(string $value) return $this; } - /** * Converts to data array * diff --git a/src/Client.php b/src/Client.php index 547419f..12c3dd3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -19,7 +19,7 @@ class Client /** * @var string */ - const VERSION_API = "v1/"; + const VERSION_API = "v2/"; const BASE_URI = 'https://ecommerce.adiq.io/'; const BASE_URI_SANDBOX = 'https://ecommerce-hml.adiq.io/'; From 349ee1f939338f0ab60a4625eb27c7dc069d4c7b Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Wed, 9 Nov 2022 17:33:39 -0300 Subject: [PATCH 07/17] Conditional bump up to v2 --- src/Client.php | 3 ++- src/Routes.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Client.php b/src/Client.php index 12c3dd3..498543b 100644 --- a/src/Client.php +++ b/src/Client.php @@ -19,7 +19,8 @@ class Client /** * @var string */ - const VERSION_API = "v2/"; + const VERSION_API = "v1/"; + const LATEST_VERSION_API = "v2/"; const BASE_URI = 'https://ecommerce.adiq.io/'; const BASE_URI_SANDBOX = 'https://ecommerce-hml.adiq.io/'; diff --git a/src/Routes.php b/src/Routes.php index c445fb7..66647c0 100644 --- a/src/Routes.php +++ b/src/Routes.php @@ -14,7 +14,7 @@ public static function payment() $anonymous = new Anonymous(); $anonymous->create = static function () { - return Client::VERSION_API . 'payments'; + return Client::LATEST_VERSION_API . 'payments'; }; $anonymous->details = static function ($id) { @@ -31,7 +31,7 @@ public static function payment() return $anonymous; } - + /** * @return \Adiq\Anonymous */ @@ -49,7 +49,7 @@ public static function card() return $anonymous; } - + /** * @return \Adiq\Anonymous */ @@ -64,7 +64,7 @@ public static function marketplace() return $anonymous; } - /** + /** * @return \Adiq\Anonymous */ public static function auth() From efd015621743b520e6ca9e3d845674aaecea1f6f Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Thu, 10 Nov 2022 09:01:34 -0300 Subject: [PATCH 08/17] Added Country to getCustomerData --- src/Beans/Customer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Beans/Customer.php b/src/Beans/Customer.php index bc875d6..80ae6ac 100644 --- a/src/Beans/Customer.php +++ b/src/Beans/Customer.php @@ -405,6 +405,7 @@ public function getCustomerData() 'Complement' => $this->complement, 'City' => $this->city, 'State' => $this->state, + 'Country' => $this->country, 'ZipCode' => $this->zipCode, 'IpAddress' => $this->ipAddress, ]; From 1045d6b68243cfebbf3129ab250229c05ad811e7 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Thu, 10 Nov 2022 17:01:28 -0300 Subject: [PATCH 09/17] More technical messages when dealing with API errors --- src/Exceptions/AdiqException.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Exceptions/AdiqException.php b/src/Exceptions/AdiqException.php index 1123488..a98e9f1 100644 --- a/src/Exceptions/AdiqException.php +++ b/src/Exceptions/AdiqException.php @@ -8,7 +8,7 @@ final class AdiqException extends \Exception * @var int */ private $status; - + /** * @var string */ @@ -23,12 +23,12 @@ final class AdiqException extends \Exception * @var string */ private $type; - + /** * @var string */ private $title; - + /** * @var string */ @@ -39,13 +39,13 @@ final class AdiqException extends \Exception * @param int $description */ public function __construct( - $status, - $tag, - $description, + $status, + $tag, + $description, $type = "", $title = "", - $traceId = "") - { + $traceId = "" + ) { $this->status = $status; $this->tag = $tag; $this->description = $description; @@ -64,9 +64,10 @@ public function __construct( private function buildExceptionMessage() { return sprintf( + '[%s]:%s (code:%s,type:%s,title:%s,traceId:%s)', + $this->tag, $this->description, $this->code, - $this->tag, $this->type, $this->title, $this->traceId @@ -101,7 +102,7 @@ public function getStatus() * Get the value of type * * @return string - */ + */ public function getType() { return $this->type; @@ -111,7 +112,7 @@ public function getType() * Get the value of title * * @return string - */ + */ public function getTitle() { return $this->title; @@ -121,7 +122,7 @@ public function getTitle() * Get the value of traceId * * @return string - */ + */ public function getTraceId() { return $this->traceId; From e499177e5735398d0e788c5ef3c08cfbd6eda713 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Mon, 14 Nov 2022 17:01:09 -0300 Subject: [PATCH 10/17] Added 3DS data to SellerInfo --- src/Beans/SellerInfo.php | 245 ++++++++++++++++++++++++--------------- 1 file changed, 150 insertions(+), 95 deletions(-) diff --git a/src/Beans/SellerInfo.php b/src/Beans/SellerInfo.php index 938fcdb..a5ea166 100644 --- a/src/Beans/SellerInfo.php +++ b/src/Beans/SellerInfo.php @@ -5,199 +5,254 @@ class SellerInfo { /** - * @var string - */ + * @var string + */ private $orderNumber; /** - * @var string - */ + * @var string + */ private $softDescriptor; /** - * @var int - */ + * @var int + */ private $dynamicMcc; /** - * @var string - */ + * @var string + */ private $cavvUcaf; /** - * @var string - */ + * @var string + */ private $eci; /** - * @var string - */ + * @var string + */ private $xid; /** - * @var string - */ + * @var string + */ + private $code3DS; + + /** + * @var string + */ + private $urlSite3DS; + + + /** + * @var string + */ private $programProtocol; /** * Get the value of orderNumber * * @return string - */ + */ public function getOrderNumber() { return $this->orderNumber; } - /** - * Set the value of orderNumber - * - * @param string $orderNumber - * - */ - public function setOrderNumber(string $orderNumber) - { - $this->orderNumber = $orderNumber; + /** + * Set the value of orderNumber + * + * @param string $orderNumber + * + */ + public function setOrderNumber(string $orderNumber) + { + $this->orderNumber = $orderNumber; return $this; - } + } /** * Get the value of softDescriptor * * @return string - */ + */ public function getSoftDescriptor() { return $this->softDescriptor; } - /** - * Set the value of softDescriptor - * - * @param string $softDescriptor - * - */ - public function setSoftDescriptor(string $softDescriptor) - { - $this->softDescriptor = $softDescriptor; + /** + * Set the value of softDescriptor + * + * @param string $softDescriptor + * + */ + public function setSoftDescriptor(string $softDescriptor) + { + $this->softDescriptor = $softDescriptor; return $this; - } + } /** * Get the value of dynamicMcc * * @return int - */ + */ public function getDynamicMcc() { return $this->dynamicMcc; } - /** - * Set the value of dynamicMcc - * - * @param int $dynamicMcc - * - */ - public function setDynamicMcc(int $dynamicMcc) - { - $this->dynamicMcc = $dynamicMcc; + /** + * Set the value of dynamicMcc + * + * @param int $dynamicMcc + * + */ + public function setDynamicMcc(int $dynamicMcc) + { + $this->dynamicMcc = $dynamicMcc; return $this; - } + } /** * Get the value of cavvUcaf * * @return string - */ + */ public function getCavvUcaf() { return $this->cavvUcaf; } - /** - * Set the value of cavvUcaf - * - * @param string $cavvUcaf - * - */ - public function setCavvUcaf(string $cavvUcaf) - { - $this->cavvUcaf = $cavvUcaf; + /** + * Set the value of cavvUcaf + * + * @param string $cavvUcaf + * + */ + public function setCavvUcaf(string $cavvUcaf) + { + $this->cavvUcaf = $cavvUcaf; return $this; - } + } /** * Get the value of eci * * @return string - */ + */ public function getEci() { return $this->eci; } - /** - * Set the value of eci - * - * @param string $eci - * - */ - public function setEci(string $eci) - { - $this->eci = $eci; + /** + * Set the value of eci + * + * @param string $eci + * + */ + public function setEci(string $eci) + { + $this->eci = $eci; return $this; - } + } /** * Get the value of xid * * @return string - */ + */ public function getXid() { return $this->xid; } - /** - * Set the value of xid - * - * @param string $xid - * - */ - public function setXid(string $xid) - { - $this->xid = $xid; + /** + * Set the value of xid + * + * @param string $xid + * + */ + public function setXid(string $xid) + { + $this->xid = $xid; return $this; - } + } /** * Get the value of programProtocol * * @return string - */ + */ public function getProgramProtocol() { return $this->programProtocol; } - /** - * Set the value of programProtocol - * - * @param string $programProtocol - * - */ - public function setProgramProtocol(string $programProtocol) - { - $this->programProtocol = $programProtocol; + /** + * Set the value of programProtocol + * + * @param string $programProtocol + * + */ + public function setProgramProtocol(string $programProtocol) + { + $this->programProtocol = $programProtocol; + return $this; + } + + /** + * Get the value of code3DS + * + * @return string + */ + public function getCode3DS() + { + return $this->code3DS; + } + + /** + * Set the value of code3DS + * + * @param string $code3DS + * + */ + public function setCode3DS(string $code3DS) + { + $this->code3DS = $code3DS; + return $this; + } + + /** + * Get the value of urlSite3DS + * + * @return string + */ + public function getUrlSite3DS() + { + return $this->urlSite3DS; + } + + /** + * Set the value of urlSite3DS + * + * @param string $urlSite3DS + * + */ + public function setUrlSite3DS(string $urlSite3DS) + { + $this->urlSite3DS = $urlSite3DS; return $this; - } + } /** * Get the value of programProtocol * * @return string - */ + */ public function getSellerInfoData() { return [ @@ -207,9 +262,9 @@ public function getSellerInfoData() "cavvUcaf" => $this->cavvUcaf, "eci" => $this->eci, "xid" => $this->xid, - "programProtocol" => $this->programProtocol + "programProtocol" => $this->programProtocol, + "code3DS" => $this->code3DS, + "urlSite3DS" => $this->urlSite3DS, ]; } - } - From 3a226d75b25e62ca52cf61b7b5df0e89e9311d11 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Wed, 16 Nov 2022 15:47:17 -0300 Subject: [PATCH 11/17] Added support for /v1/payment/validate --- src/Endpoints/Payment.php | 22 ++++++++++++++++++++++ src/Routes.php | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/src/Endpoints/Payment.php b/src/Endpoints/Payment.php index b615cc3..5dc16fa 100644 --- a/src/Endpoints/Payment.php +++ b/src/Endpoints/Payment.php @@ -70,6 +70,7 @@ public function cancel(array $payload) ] ); } + /** * @param array $payload * @@ -90,5 +91,26 @@ public function capture(array $payload) ] ); } + + /** + * @param array $payload + * + * @return \ArrayObject + */ + public function validate(array $payload) + { + return $this->client->request( + self::POST, + Routes::payment()->validate(), + ['json' => $payload], + [ + 'Content-Type' => "application/json", + 'Authorization' => + $this->client->getTokenType() . + ' ' . + $this->client->getAccessToken() + ] + ); + } } diff --git a/src/Routes.php b/src/Routes.php index 66647c0..9cccfb3 100644 --- a/src/Routes.php +++ b/src/Routes.php @@ -29,6 +29,10 @@ public static function payment() return Client::VERSION_API . "payments/$id/capture"; }; + $anonymous->validate = static function () { + return Client::VERSION_API . "payments/"; + }; + return $anonymous; } From d052e5ce4bc2fe6debe49484e79df8dc9b7eb1c0 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Wed, 16 Nov 2022 15:47:54 -0300 Subject: [PATCH 12/17] Updated validate url --- src/Routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Routes.php b/src/Routes.php index 9cccfb3..715f475 100644 --- a/src/Routes.php +++ b/src/Routes.php @@ -30,7 +30,7 @@ public static function payment() }; $anonymous->validate = static function () { - return Client::VERSION_API . "payments/"; + return Client::VERSION_API . "payments/validate"; }; return $anonymous; From e890cbbe0122b342463c31ffa49808aae3a85746 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Tue, 22 Nov 2022 08:36:52 -0300 Subject: [PATCH 13/17] Added support for fetching payments with an {orderId}/{dateStr} syntax --- src/Routes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Routes.php b/src/Routes.php index 715f475..5e396e9 100644 --- a/src/Routes.php +++ b/src/Routes.php @@ -17,8 +17,8 @@ public static function payment() return Client::LATEST_VERSION_API . 'payments'; }; - $anonymous->details = static function ($id) { - return Client::VERSION_API . "payments/$id"; + $anonymous->details = static function ($id, $date) { + return Client::VERSION_API . "payments/$id" . ($date ? "/$date" : ''); }; $anonymous->cancel = static function ($id) { From fcc2193c812c6fa968881a3c6311b8ae7cbe2f54 Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Tue, 22 Nov 2022 08:45:56 -0300 Subject: [PATCH 14/17] Updated details on Payment endpoint --- src/Endpoints/Payment.php | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Endpoints/Payment.php b/src/Endpoints/Payment.php index 5dc16fa..a2d83ed 100644 --- a/src/Endpoints/Payment.php +++ b/src/Endpoints/Payment.php @@ -21,14 +21,14 @@ public function create(array $payload) ['json' => $payload], [ 'Content-Type' => 'application/json', - 'Authorization' => - $this->client->getTokenType() . - ' ' . + 'Authorization' => + $this->client->getTokenType() . + ' ' . $this->client->getAccessToken() ] ); } - + /** * @param array $payload * @@ -38,18 +38,18 @@ public function details(array $payload) { return $this->client->request( self::GET, - Routes::payment()->details($payload['id']), + Routes::payment()->details($payload['id'], $payload['date'] ?? null), ['json' => $payload], [ 'Content-Type' => "application/json", - 'Authorization' => - $this->client->getTokenType() . - ' ' . + 'Authorization' => + $this->client->getTokenType() . + ' ' . $this->client->getAccessToken() ] ); } - + /** * @param array $payload * @@ -63,9 +63,9 @@ public function cancel(array $payload) ['json' => $payload], [ 'Content-Type' => "application/json", - 'Authorization' => - $this->client->getTokenType() . - ' ' . + 'Authorization' => + $this->client->getTokenType() . + ' ' . $this->client->getAccessToken() ] ); @@ -84,9 +84,9 @@ public function capture(array $payload) ['json' => $payload], [ 'Content-Type' => "application/json", - 'Authorization' => - $this->client->getTokenType() . - ' ' . + 'Authorization' => + $this->client->getTokenType() . + ' ' . $this->client->getAccessToken() ] ); @@ -113,4 +113,3 @@ public function validate(array $payload) ); } } - From 436bf5d636f139bd5af3ebef42ecc8b0d659808b Mon Sep 17 00:00:00 2001 From: Vitor Kubinyete Date: Fri, 21 Jul 2023 16:00:41 -0300 Subject: [PATCH 15/17] Revert back from v2 to v1 for payment/create --- src/Routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Routes.php b/src/Routes.php index 5e396e9..ffe8b68 100644 --- a/src/Routes.php +++ b/src/Routes.php @@ -14,7 +14,7 @@ public static function payment() $anonymous = new Anonymous(); $anonymous->create = static function () { - return Client::LATEST_VERSION_API . 'payments'; + return Client::VERSION_API . 'payments'; }; $anonymous->details = static function ($id, $date) { From 614fe3c797723b50b5e30b8ffdaa0a406d36224f Mon Sep 17 00:00:00 2001 From: gabrielBrusarrosco Date: Mon, 26 Jan 2026 12:23:12 -0300 Subject: [PATCH 16/17] adicionando novo endpoint zeroAuth --- src/Beans/CustomerCard.php | 308 +++++++++++++++++++++---------------- src/Endpoints/Card.php | 34 +++- src/Routes.php | 4 + 3 files changed, 210 insertions(+), 136 deletions(-) diff --git a/src/Beans/CustomerCard.php b/src/Beans/CustomerCard.php index bae074a..737c5e2 100644 --- a/src/Beans/CustomerCard.php +++ b/src/Beans/CustomerCard.php @@ -4,213 +4,240 @@ class CustomerCard { - + /** - * @var string - */ + * @var string + */ private $vaultId; /** - * @var string - */ + * @var string + */ private $numberToken; - + /** - * @var string - */ + * @var string + */ private $cardNumber; /** - * @var string - */ + * @var string + */ private $cardholderName; - + /** - * @var bool - */ + * @var bool + */ private $verifyCard = false; /** - * @var string - */ + * @var string + */ private $securityCode; /** - * @var string | visa, mastercard, amex, elo - */ + * @var string | visa, mastercard, amex, elo + */ private $brand; /** - * @var string - */ + * @var string + */ private $expirationMonth; /** - * @var string - */ + * @var string + */ private $expirationYear; + /** + * @var string + */ + private $transactionType; + public function __construct() {} /** * Get the value of vaultId * * @return string - */ + */ public function getVaultId() { return $this->vaultId; } - /** - * Set the value of vaultId - * - * @param string $vaultId - * - */ - public function setVaultId(string $vaultId) - { - $this->vaultId = $vaultId; + /** + * Set the value of vaultId + * + * @param string $vaultId + * + */ + public function setVaultId(string $vaultId) + { + $this->vaultId = $vaultId; return $this; - } + } /** * Get the value of numberToken * * @return string - */ + */ public function getNumberToken() { return $this->numberToken; } - /** - * Set the value of numberToken - * - * @param string $numberToken - * - */ - public function setNumberToken(string $numberToken) - { - $this->numberToken = $numberToken; + /** + * Set the value of numberToken + * + * @param string $numberToken + * + */ + public function setNumberToken(string $numberToken) + { + $this->numberToken = $numberToken; return $this; - } + } /** * Get the value of cardholderName * * @return string - */ + */ public function getCardholderName() { return $this->cardholderName; } - /** - * Set the value of cardholderName - * - * @param string $cardholderName - * - */ - public function setCardholderName(string $cardholderName) - { - $this->cardholderName = $cardholderName; + /** + * Set the value of cardholderName + * + * @param string $cardholderName + * + */ + public function setCardholderName(string $cardholderName) + { + $this->cardholderName = $cardholderName; return $this; - } + } /** * Get the value of securityCode * * @return string - */ + */ public function getSecurityCode() { return $this->securityCode; } - /** - * Set the value of securityCode - * - * @param string $securityCode - * - */ - public function setSecurityCode(string $securityCode) - { - $this->securityCode = $securityCode; + /** + * Set the value of securityCode + * + * @param string $securityCode + * + */ + public function setSecurityCode(string $securityCode) + { + $this->securityCode = $securityCode; return $this; - } + } /** * Get the value of brand * * @return string - */ + */ public function getBrand() { return $this->brand; } - /** - * Set the value of brand - * - * @param string $brand - * - */ - public function setBrand(string $brand) - { - $this->brand = $brand; + /** + * Set the value of brand + * + * @param string $brand + * + */ + public function setBrand(string $brand) + { + $this->brand = $brand; return $this; - } + } /** * Get the value of expirationMonth * * @return string - */ + */ public function getExpirationMonth() { return $this->expirationMonth; } - /** - * Set the value of expirationMonth - * - * @param string $expirationMonth - * - */ - public function setExpirationMonth(string $expirationMonth) - { - $this->expirationMonth = $expirationMonth; + /** + * Set the value of expirationMonth + * + * @param string $expirationMonth + * + */ + public function setExpirationMonth(string $expirationMonth) + { + $this->expirationMonth = $expirationMonth; return $this; - } + } /** * Get the value of expirationYear * * @return string - */ + */ public function getExpirationYear() { return $this->expirationYear; } - /** - * Set the value of expirationYear - * - * @param string $expirationYear - * - */ - public function setExpirationYear(string $expirationYear) - { - $this->expirationYear = $expirationYear; + /** + * Set the value of expirationYear + * + * @param string $expirationYear + * + */ + public function setExpirationYear(string $expirationYear) + { + $this->expirationYear = $expirationYear; + return $this; + } + + /** + * Get the value of transactionType + * + * @return string + */ + public function getTransactionType() + { + return $this->transactionType; + } + + /** + * Set the value of transactionType + * + * @param string $transactionType + * + */ + public function setTransactionType(string $transactionType) + { + $this->transactionType = $transactionType; return $this; - } + } - /** + /** * Get the value of expirationYear * * @return array - */ + */ public function getCardData() { return [ @@ -229,48 +256,71 @@ public function getCardData() * Get the value of cardNumber * * @return array - */ + */ public function getCardNumberData() { return ["cardNumber" => $this->cardNumber]; } - /** - * Set the value of cardNumber - * - * @param string $cardNumber - * - * return $this - * - */ - public function setCardNumber(string $cardNumber) - { - $this->cardNumber = $cardNumber; - return $this; - } + /** + * Set the value of cardNumber + * + * @param string $cardNumber + * + * return $this + * + */ + public function setCardNumber(string $cardNumber) + { + $this->cardNumber = $cardNumber; + return $this; + } /** * Get the value of verifyCard * * @return bool - */ + */ public function getVerifyCard() { return $this->verifyCard; } - /** - * Set the value of verifyCard - * - * @param bool $verifyCard - * - * return $this - * - */ - public function setVerifyCard(bool $verifyCard) - { - $this->verifyCard = $verifyCard; - return $this; - } -} + /** + * Set the value of verifyCard + * + * @param bool $verifyCard + * + * return $this + * + */ + public function setVerifyCard(bool $verifyCard) + { + $this->verifyCard = $verifyCard; + return $this; + } + + /** + * Retorna o array formatado especificamente para o endpoint Zero Auth + * Lógica: Se tiver vaultId, usa o Caso 2. Se não, usa o Caso 1. + * + * @return array + */ + public function getZeroAuthData() + { + if (!empty($this->vaultId)) { + return [ + "vaultId" => $this->vaultId + ]; + } + return [ + "cardholderName" => $this->cardholderName, + "securityCode" => $this->securityCode, + "numberToken" => $this->numberToken, + "expirationMonth" => $this->expirationMonth, + "expirationYear" => $this->expirationYear, + "transactionType" => $this->transactionType + ]; + } +} diff --git a/src/Endpoints/Card.php b/src/Endpoints/Card.php index 0c4ee79..4a52bee 100644 --- a/src/Endpoints/Card.php +++ b/src/Endpoints/Card.php @@ -21,9 +21,9 @@ public function create(array $payload) ['json' => $payload], [ 'Content-Type' => "application/json", - 'Authorization' => - $this->client->getTokenType() . - ' ' . + 'Authorization' => + $this->client->getTokenType() . + ' ' . $this->client->getAccessToken() ] ); @@ -42,12 +42,32 @@ public function vaults(array $payload) ['json' => $payload], [ 'Content-Type' => "application/json", - 'Authorization' => - $this->client->getTokenType() . - ' ' . + 'Authorization' => + $this->client->getTokenType() . + ' ' . $this->client->getAccessToken() ] ); } -} + /** + * @param array $payload Pode conter os dados do cartão + transactionType OU apenas vaultId + * + * @return \ArrayObject + */ + public function zeroAuth(array $payload) + { + return $this->client->request( + self::POST, + Routes::card()->zeroAuth(), + ['json' => $payload], + [ + 'Content-Type' => "application/json", + 'Authorization' => + $this->client->getTokenType() . + ' ' . + $this->client->getAccessToken() + ] + ); + } +} diff --git a/src/Routes.php b/src/Routes.php index ffe8b68..bc2f9ca 100644 --- a/src/Routes.php +++ b/src/Routes.php @@ -51,6 +51,10 @@ public static function card() return Client::VERSION_API . "vaults/cards"; }; + $anonymous->zeroAuth = static function () { + return Client::VERSION_API . "zero-auth"; + }; + return $anonymous; } From 28882e8ab8cba980dddd08dea9c66cd4d5e16264 Mon Sep 17 00:00:00 2001 From: gabrielBrusarrosco Date: Mon, 26 Jan 2026 14:43:32 -0300 Subject: [PATCH 17/17] adicionando novo endpoint zeroAuth --- src/Beans/CustomerCard.php | 3 ++- tests/unit/ZeroAuthTest.php | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/unit/ZeroAuthTest.php diff --git a/src/Beans/CustomerCard.php b/src/Beans/CustomerCard.php index 737c5e2..8c0dd0b 100644 --- a/src/Beans/CustomerCard.php +++ b/src/Beans/CustomerCard.php @@ -320,7 +320,8 @@ public function getZeroAuthData() "numberToken" => $this->numberToken, "expirationMonth" => $this->expirationMonth, "expirationYear" => $this->expirationYear, - "transactionType" => $this->transactionType + "transactionType" => $this->transactionType, + "cardNumber" => $this->cardNumber ]; } } diff --git a/tests/unit/ZeroAuthTest.php b/tests/unit/ZeroAuthTest.php new file mode 100644 index 0000000..cfc0c20 --- /dev/null +++ b/tests/unit/ZeroAuthTest.php @@ -0,0 +1,48 @@ +setClientId("6bb5b48c-16d4-4245-9583-d72f3c238d04"); + $key->setClientSecret("8E95DD96-DA38-43C8-9FB7-A9F6B3A06634"); + + $sandbox = true; + + $client = new Client(['Authorization' => $key->getKeyBase64()], $sandbox); + + $client->auth()->token([ + "grantType" => "client_credentials", + ]); + + $cardInfo = new CustomerCard(); + $cardInfo->setCardNumber("5200000000001005"); // Cartão de teste Adiq + + $responseToken = $client->card()->create($cardInfo->getCardNumberData()); + $numberToken = $responseToken->numberToken; + + $cardInfo->setNumberToken($numberToken) + ->setBrand("visa") + ->setCardholderName("JOSE SILVA") + ->setExpirationMonth("07") + ->setExpirationYear("40") + ->setVerifyCard(true) + ->setSecurityCode("123") + ->setTransactionType("credit"); + + $responseZeroAuth = $client->card()->zeroAuth($cardInfo->getZeroAuthData()); + + $this->assertTrue(isset($responseZeroAuth->cardAuthSuccess)); + $this->assertEquals("credit", $responseZeroAuth->transactionType); + } +}