diff --git a/.env.sample b/.env.sample
index 1fd7956..912eb70 100644
--- a/.env.sample
+++ b/.env.sample
@@ -1,7 +1,4 @@
-COMPOSE_PROJECT_NAME=asaas-pix-dev
+COMPOSE_PROJECT_NAME=asaas-sdk-dev
-# ---------
-# Banco Brasil
-# ---------
ASAAS_API_KEY=
ASAAS_SANDBOX=1
diff --git a/README.md b/README.md
index bebdce8..cf68b44 100644
--- a/README.md
+++ b/README.md
@@ -9,24 +9,83 @@ A forma mais recomendada de instalar este pacote é através do [composer](http:
Para instalar, basta executar o comando abaixo
```bash
-$ @todo
+$ php composer.phar require astrotechlabs/asaas-sdk
```
ou adicionar esse linha
```
-@todo
+"astrotechlabs/asaas-sdk": "^1.0"
```
na seção `require` do seu arquivo `composer.json`.
## Como Usar?
+### Minimo para utilização
+#
+#### 1. Identificador único de cliente
+```php
+$sut = new CustomerIdentifierCreator($_ENV['ASAAS_API_KEY'], true);
-@todo
+$customerAsaasId = $sut->generateCustomerIdentifier(new CustomerData(
+ name: 'Joãozinho Barbosa',
+ phone: '999999999',
+ cpfCnpj: '01234567890'
+));
+
+print_r($customerAsaasId);
+```
+
+#### Saída
+```
+[
+ 'identifier' => 'cus_xxxxxxxx'
+]
+```
+#
+#### 2. Criar cobrança
+```php
+use AstrotechLabs\AsaasSdk\AssasGateway;
+use AstrotechLabs\AsaasSdk\Enum\BillingTypes;
+use AstrotechLabs\AsaasSdk\AssasGatewayParams;
+use AstrotechLabs\AsaasSdk\CreatePixCharge\Dto\PixData;
+
+$asaasGateway = new AssasGateway(new AssasGatewayParams(
+ apiKey: 'xxxxxxxxxx',
+ // isSandBox: true (opcional)
+));
+
+$pixChargeResponse = $asaasGateway->createCharge(new PixData(
+ customer: 'cus_xxxxxxxx', // Identificador único de cliente
+ billingType: BillingTypes::PIX,
+ value: 100.00,
+ dueDate: "2023-12-20"
+));
+
+print_r($pixChargeResponse);
+```
+
+### Saída
+```
+[
+ 'gatewayId': 'pay_kp6gqaovguxqr1od',
+ 'paymentUrl': 'https://sandbox.asaas.com/i/kp6gqaovguxqr1od',
+ 'copyPasteUrl': '00020101021226820014br.gov.bcb.pix2560qrpix-h.bradesco.com.br/xxxxxxxxx-xxxx......',
+ 'details' => [
+ 'object' => 'payment'
+ 'id' => 'pay_kp6gqaovguxqr1od'
+ 'dateCreated' => '2023-12-16'
+ 'customer' => 'cus_000005797885'
+ 'paymentLink' => 'https://sandbox.asaas.com/i/xxxxxxxxxxx',
+ ..............
+ ],
+ 'qrCode' => 'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAYsAAA......'
+]
+```
## Contributing
-Pull Request são bem-vindao. Para mudanças importantes, abra primeiro uma issue para discutir o que você gostaria de mudar.
+Pull Request são bem-vindas. Para mudanças importantes, abra primeiro uma issue para discutir o que você gostaria de mudar.
Certifique-se de atualizar os testes conforme apropriado.
diff --git a/composer.json b/composer.json
index 4bf9e7e..fc1a76b 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
- "name": "vaironaegos/asaas-pix",
- "description": "",
+ "name": "astrotechlabs/asaas-sdk",
+ "description": "Pacote facilitador para integrações com Asaas Pagamento",
"type": "project",
"license": "BSD-3-Clause",
"minimum-stability": "stable",
@@ -37,7 +37,7 @@
},
"autoload": {
"psr-4": {
- "Astrotech\\AsaasGateway\\": "src\\"
+ "AstrotechLabs\\AsaasSdk\\": "src\\"
}
},
"autoload-dev": {
diff --git a/composer.lock b/composer.lock
index c98720c..e6f26c1 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "05069be05f9b20ff93d8958736428ee1",
+ "content-hash": "85f413d3780bc849b6b2a6bd8b338aff",
"packages": [
{
"name": "brick/math",
@@ -125,16 +125,16 @@
},
{
"name": "guzzlehttp/guzzle",
- "version": "7.8.0",
+ "version": "7.8.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
- "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9"
+ "reference": "41042bc7ab002487b876a0683fc8dce04ddce104"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1110f66a6530a40fe7aea0378fe608ee2b2248f9",
- "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104",
+ "reference": "41042bc7ab002487b876a0683fc8dce04ddce104",
"shasum": ""
},
"require": {
@@ -149,11 +149,11 @@
"psr/http-client-implementation": "1.0"
},
"require-dev": {
- "bamarni/composer-bin-plugin": "^1.8.1",
+ "bamarni/composer-bin-plugin": "^1.8.2",
"ext-curl": "*",
"php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999",
"php-http/message-factory": "^1.1",
- "phpunit/phpunit": "^8.5.29 || ^9.5.23",
+ "phpunit/phpunit": "^8.5.36 || ^9.6.15",
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
@@ -231,7 +231,7 @@
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
- "source": "https://github.com/guzzle/guzzle/tree/7.8.0"
+ "source": "https://github.com/guzzle/guzzle/tree/7.8.1"
},
"funding": [
{
@@ -247,28 +247,28 @@
"type": "tidelift"
}
],
- "time": "2023-08-27T10:20:53+00:00"
+ "time": "2023-12-03T20:35:24+00:00"
},
{
"name": "guzzlehttp/promises",
- "version": "2.0.1",
+ "version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
- "reference": "111166291a0f8130081195ac4556a5587d7f1b5d"
+ "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/promises/zipball/111166291a0f8130081195ac4556a5587d7f1b5d",
- "reference": "111166291a0f8130081195ac4556a5587d7f1b5d",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223",
+ "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0"
},
"require-dev": {
- "bamarni/composer-bin-plugin": "^1.8.1",
- "phpunit/phpunit": "^8.5.29 || ^9.5.23"
+ "bamarni/composer-bin-plugin": "^1.8.2",
+ "phpunit/phpunit": "^8.5.36 || ^9.6.15"
},
"type": "library",
"extra": {
@@ -314,7 +314,7 @@
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
- "source": "https://github.com/guzzle/promises/tree/2.0.1"
+ "source": "https://github.com/guzzle/promises/tree/2.0.2"
},
"funding": [
{
@@ -330,20 +330,20 @@
"type": "tidelift"
}
],
- "time": "2023-08-03T15:11:55+00:00"
+ "time": "2023-12-03T20:19:20+00:00"
},
{
"name": "guzzlehttp/psr7",
- "version": "2.6.1",
+ "version": "2.6.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
- "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727"
+ "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/be45764272e8873c72dbe3d2edcfdfcc3bc9f727",
- "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221",
+ "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221",
"shasum": ""
},
"require": {
@@ -357,9 +357,9 @@
"psr/http-message-implementation": "1.0"
},
"require-dev": {
- "bamarni/composer-bin-plugin": "^1.8.1",
+ "bamarni/composer-bin-plugin": "^1.8.2",
"http-interop/http-factory-tests": "^0.9",
- "phpunit/phpunit": "^8.5.29 || ^9.5.23"
+ "phpunit/phpunit": "^8.5.36 || ^9.6.15"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
@@ -430,7 +430,7 @@
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
- "source": "https://github.com/guzzle/psr7/tree/2.6.1"
+ "source": "https://github.com/guzzle/psr7/tree/2.6.2"
},
"funding": [
{
@@ -446,7 +446,7 @@
"type": "tidelift"
}
],
- "time": "2023-08-27T10:13:57+00:00"
+ "time": "2023-12-03T20:05:35+00:00"
},
{
"name": "laravel/serializable-closure",
@@ -1961,16 +1961,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
- "version": "v3.40.0",
+ "version": "v3.41.1",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
- "reference": "27d2b3265b5d550ec411b4319967ae7cfddfb2e0"
+ "reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/27d2b3265b5d550ec411b4319967ae7cfddfb2e0",
- "reference": "27d2b3265b5d550ec411b4319967ae7cfddfb2e0",
+ "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8b6ae8dcbaf23f09680643ab832a4a3a260265f6",
+ "reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6",
"shasum": ""
},
"require": {
@@ -2000,8 +2000,6 @@
"php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4",
- "phpspec/prophecy": "^1.17",
- "phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.6",
"symfony/phpunit-bridge": "^6.3.8 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
@@ -2042,7 +2040,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
- "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.40.0"
+ "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.41.1"
},
"funding": [
{
@@ -2050,7 +2048,7 @@
"type": "github"
}
],
- "time": "2023-11-26T09:25:53+00:00"
+ "time": "2023-12-10T19:59:27+00:00"
},
{
"name": "myclabs/deep-copy",
@@ -2113,16 +2111,16 @@
},
{
"name": "nikic/php-parser",
- "version": "v4.17.1",
+ "version": "v4.18.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d"
+ "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d",
- "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999",
+ "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999",
"shasum": ""
},
"require": {
@@ -2163,9 +2161,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0"
},
- "time": "2023-08-13T19:53:39+00:00"
+ "time": "2023-12-10T21:03:43+00:00"
},
{
"name": "phar-io/manifest",
@@ -2599,16 +2597,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "9.6.13",
+ "version": "9.6.15",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be"
+ "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be",
- "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/05017b80304e0eb3f31d90194a563fd53a6021f1",
+ "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1",
"shasum": ""
},
"require": {
@@ -2682,7 +2680,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.15"
},
"funding": [
{
@@ -2698,7 +2696,7 @@
"type": "tidelift"
}
],
- "time": "2023-09-19T05:39:22+00:00"
+ "time": "2023-12-01T16:55:19+00:00"
},
{
"name": "psr/event-dispatcher",
@@ -3766,16 +3764,16 @@
},
{
"name": "squizlabs/php_codesniffer",
- "version": "3.7.2",
+ "version": "3.8.0",
"source": {
"type": "git",
- "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
- "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879"
+ "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
+ "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879",
- "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5805f7a4e4958dbb5e944ef1e6edae0a303765e7",
+ "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7",
"shasum": ""
},
"require": {
@@ -3785,7 +3783,7 @@
"php": ">=5.4.0"
},
"require-dev": {
- "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
},
"bin": [
"bin/phpcs",
@@ -3804,35 +3802,58 @@
"authors": [
{
"name": "Greg Sherwood",
- "role": "lead"
+ "role": "Former lead"
+ },
+ {
+ "name": "Juliette Reinders Folmer",
+ "role": "Current lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors"
}
],
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
- "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
"keywords": [
"phpcs",
"standards",
"static analysis"
],
"support": {
- "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
- "source": "https://github.com/squizlabs/PHP_CodeSniffer",
- "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
+ "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues",
+ "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy",
+ "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
},
- "time": "2023-02-22T23:07:41+00:00"
+ "funding": [
+ {
+ "url": "https://github.com/PHPCSStandards",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/jrfnl",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/php_codesniffer",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2023-12-08T12:32:31+00:00"
},
{
"name": "symfony/console",
- "version": "v7.0.0",
+ "version": "v7.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "64e06788686633deb8d9a7c75ab31bcf4b233a26"
+ "reference": "cdce5c684b2f920bb1343deecdfba356ffad83d5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/64e06788686633deb8d9a7c75ab31bcf4b233a26",
- "reference": "64e06788686633deb8d9a7c75ab31bcf4b233a26",
+ "url": "https://api.github.com/repos/symfony/console/zipball/cdce5c684b2f920bb1343deecdfba356ffad83d5",
+ "reference": "cdce5c684b2f920bb1343deecdfba356ffad83d5",
"shasum": ""
},
"require": {
@@ -3896,7 +3917,7 @@
"terminal"
],
"support": {
- "source": "https://github.com/symfony/console/tree/v7.0.0"
+ "source": "https://github.com/symfony/console/tree/v7.0.1"
},
"funding": [
{
@@ -3912,7 +3933,7 @@
"type": "tidelift"
}
],
- "time": "2023-11-20T16:43:42+00:00"
+ "time": "2023-12-01T15:10:06+00:00"
},
{
"name": "symfony/event-dispatcher",
diff --git a/index.php b/index.php
deleted file mode 100644
index 147185c..0000000
--- a/index.php
+++ /dev/null
@@ -1,26 +0,0 @@
-load();
-
-$asaasGateway = new \Astrotech\AsaasGateway\AssasGateway(new AssasGatewayParams(
- apiKey: $_ENV['ASAAS_API_KEY'],
- isSandBox: boolval($_ENV['ASAAS_SANDBOX'])
-));
-
-$data = $asaasGateway->createCharge(new PixData(
- customer: 'cus_000005797885',
- billingType: BillingTypes::PIX,
- value: 650.90,
- dueDate: "2023-12-20"
-));
-
-$a = 0;
diff --git a/phpcs.xml b/phpcs.xml
index 136db48..ff1de4e 100755
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -8,7 +8,7 @@
./src
- ./config
+
*/vendor/*
*/runtime/*
diff --git a/src/AsaasCustomerIdentifierCreator/Dto/AsaasCustomerIdentifierOutput.php b/src/AsaasCustomerIdentifierCreator/Dto/AsaasCustomerIdentifierOutput.php
deleted file mode 100644
index 9f511c4..0000000
--- a/src/AsaasCustomerIdentifierCreator/Dto/AsaasCustomerIdentifierOutput.php
+++ /dev/null
@@ -1,11 +0,0 @@
-params->apiKey,
isSandBox: $this->params->isSandBox
);
diff --git a/src/AssasGatewayParams.php b/src/AssasGatewayParams.php
index 84fadc7..06e1d0e 100644
--- a/src/AssasGatewayParams.php
+++ b/src/AssasGatewayParams.php
@@ -1,6 +1,8 @@
"application/json",
@@ -44,7 +44,7 @@ public function createCharge(PixData $pixData): CreateAsaasPixChargeOutput
]);
} catch (ClientException $e) {
$responsePayload = json_decode($e->getResponse()->getBody()->getContents(), true);
- throw new CreateAsaasPixChargeException(
+ throw new CreatePixChargeException(
1001,
$responsePayload['errors'][0]['description'],
$responsePayload['errors'][0]['code'],
@@ -57,11 +57,12 @@ public function createCharge(PixData $pixData): CreateAsaasPixChargeOutput
$qrCode = $this->getPaymentQrCode($responsePayload['id']);
- return new CreateAsaasPixChargeOutput(
+ return new CreatePixChargeOutput(
gatewayId: $responsePayload['id'],
paymentUrl: $responsePayload['invoiceUrl'],
+ copyPasteUrl: $qrCode->copyAndPaste,
details: $responsePayload,
- qrCode: $qrCode->encodedImage
+ qrCode: 'data:image/png;base64, ' . $qrCode->encodedImage
);
}
@@ -75,7 +76,7 @@ public function getPaymentQrCode(string $paymentId): QrCodeOutput
try {
$response = $this->httpClient->get("payments/{$paymentId}/pixQrCode", ['headers' => $headers]);
} catch (ClientException $e) {
- throw new CreateAsaasPixChargeException(
+ throw new CreatePixChargeException(
$e->getCode(),
$e->getMessage(),
$this->isSandBox ? $e->getTraceAsString() : '',
diff --git a/src/CreateAsaasPixChargeGateway/Dto/CreateAsaasPixChargeOutput.php b/src/CreatePixCharge/Dto/CreatePixChargeOutput.php
similarity index 73%
rename from src/CreateAsaasPixChargeGateway/Dto/CreateAsaasPixChargeOutput.php
rename to src/CreatePixCharge/Dto/CreatePixChargeOutput.php
index 4d636eb..dae796c 100644
--- a/src/CreateAsaasPixChargeGateway/Dto/CreateAsaasPixChargeOutput.php
+++ b/src/CreatePixCharge/Dto/CreatePixChargeOutput.php
@@ -2,15 +2,16 @@
declare(strict_types=1);
-namespace Astrotech\AsaasGateway\CreateAsaasPixChargeGateway\Dto;
+namespace AstrotechLabs\AsaasSdk\CreatePixCharge\Dto;
use JsonSerializable;
-final class CreateAsaasPixChargeOutput implements JsonSerializable
+final class CreatePixChargeOutput implements JsonSerializable
{
public function __construct(
public readonly string $gatewayId,
public readonly string $paymentUrl,
+ public readonly string $copyPasteUrl,
public readonly array $details,
public readonly string $qrCode
) {
diff --git a/src/CreateAsaasPixChargeGateway/Dto/PixData.php b/src/CreatePixCharge/Dto/PixData.php
similarity index 86%
rename from src/CreateAsaasPixChargeGateway/Dto/PixData.php
rename to src/CreatePixCharge/Dto/PixData.php
index 76591b3..2d961d7 100644
--- a/src/CreateAsaasPixChargeGateway/Dto/PixData.php
+++ b/src/CreatePixCharge/Dto/PixData.php
@@ -1,8 +1,10 @@
"application/json",
@@ -43,7 +43,7 @@ public function generateCustomerIdentifier(AsaasCustomerData $customerData): Asa
]);
} catch (ClientException $e) {
$responsePayload = json_decode($e->getResponse()->getBody()->getContents(), true);
- throw new CreateAsaasCustomerIdentifierException(
+ throw new CreateCustomerIdentifierException(
1001,
$responsePayload['errors'][0]['description'],
$responsePayload['errors'][0]['code'],
@@ -54,6 +54,6 @@ public function generateCustomerIdentifier(AsaasCustomerData $customerData): Asa
$responsePayload = json_decode($response->getBody()->getContents(), true);
- return new AsaasCustomerIdentifierOutput(identifier: $responsePayload['id']);
+ return new CustomerIdentifierOutput(identifier: $responsePayload['id']);
}
}
diff --git a/src/AsaasCustomerIdentifierCreator/Dto/AsaasCustomerData.php b/src/CustomerIdentifierCreator/Dto/CustomerData.php
similarity index 84%
rename from src/AsaasCustomerIdentifierCreator/Dto/AsaasCustomerData.php
rename to src/CustomerIdentifierCreator/Dto/CustomerData.php
index 47233c1..f82673f 100644
--- a/src/AsaasCustomerIdentifierCreator/Dto/AsaasCustomerData.php
+++ b/src/CustomerIdentifierCreator/Dto/CustomerData.php
@@ -1,8 +1,10 @@
assertIsString($sut->getBaseUrl());
$this->assertNotEmpty($sut->getBaseUrl());
@@ -24,7 +24,7 @@ public function testItShouldDefineCorrectUrlWhenNotInSandbox()
public function testItShouldDefineCorrectUrlWhenasInSandbox()
{
- $sut = new CreateAsaasPixChargeGateway($_ENV['ASAAS_API_KEY'], true);
+ $sut = new CreatePixChargeGateway($_ENV['ASAAS_API_KEY'], true);
$this->assertIsString($sut->getBaseUrl());
$this->assertNotEmpty($sut->getBaseUrl());
@@ -33,11 +33,11 @@ public function testItShouldDefineCorrectUrlWhenasInSandbox()
public function testItShouldThrowAnExceptionWhenProvideInvalidCustomerIdentifier()
{
- $this->expectException(CreateAsaasPixChargeException::class);
+ $this->expectException(CreatePixChargeException::class);
$this->expectExceptionCode(1001);
$this->expectExceptionMessage('Customer inválido ou não informado.');
- $sut = new CreateAsaasPixChargeGateway($_ENV['ASAAS_API_KEY'], true);
+ $sut = new CreatePixChargeGateway($_ENV['ASAAS_API_KEY'], true);
$customerIdentifier = self::$faker->uuid;
$response = $sut->createCharge(new PixData(
@@ -50,11 +50,11 @@ public function testItShouldThrowAnExceptionWhenProvideInvalidCustomerIdentifier
public function testItShouldThrowAnExceptionWhenProvideInvalidDueDate()
{
- $this->expectException(CreateAsaasPixChargeException::class);
+ $this->expectException(CreatePixChargeException::class);
$this->expectExceptionCode(1001);
$this->expectExceptionMessage('Não é permitido data de vencimento inferior a hoje.');
- $sut = new CreateAsaasPixChargeGateway($_ENV['ASAAS_API_KEY'], true);
+ $sut = new CreatePixChargeGateway($_ENV['ASAAS_API_KEY'], true);
$customerIdentifier = 'cus_000005797885';
$response = $sut->createCharge(new PixData(
@@ -67,7 +67,7 @@ public function testItShouldThrowAnExceptionWhenProvideInvalidDueDate()
public function testItShouldCreatePaymentCharge()
{
- $sut = new CreateAsaasPixChargeGateway($_ENV['ASAAS_API_KEY'], true);
+ $sut = new CreatePixChargeGateway($_ENV['ASAAS_API_KEY'], true);
$customerIdentifier = 'cus_000005797885';
@@ -94,19 +94,19 @@ public function testItShouldCreatePaymentCharge()
$this->assertSame($customerIdentifier, $response->details['customer']);
}
- public function testItShouldThrowAnExceptionWhenTryGetQrCodeForInvalidOrNonexistentPayment()
+ public function testItShouldThrowAnExceptionWhenTryGetQrCodeForInvalidOrNonExistentPayment()
{
- $this->expectException(CreateAsaasPixChargeException::class);
+ $this->expectException(CreatePixChargeException::class);
$this->expectExceptionCode(404);
- $sut = new CreateAsaasPixChargeGateway($_ENV['ASAAS_API_KEY'], true);
+ $sut = new CreatePixChargeGateway($_ENV['ASAAS_API_KEY'], true);
$response = $sut->getPaymentQrCode(self::$faker->name);
}
public function testItShouldTReturnValidQrCodeWhenValidPaymentIdProvide()
{
- $sut = new CreateAsaasPixChargeGateway($_ENV['ASAAS_API_KEY'], true);
+ $sut = new CreatePixChargeGateway($_ENV['ASAAS_API_KEY'], true);
$response = $sut->getPaymentQrCode('pay_5xs951pgtcuiqe41');
diff --git a/tests/Integration/AsaasCustomerIdentifierCreator/AsaasCustomerIdentifierCreatorTest.php b/tests/Integration/CustomerIdentifierCreator/CustomerIdentifierCreatorTest.php
similarity index 75%
rename from tests/Integration/AsaasCustomerIdentifierCreator/AsaasCustomerIdentifierCreatorTest.php
rename to tests/Integration/CustomerIdentifierCreator/CustomerIdentifierCreatorTest.php
index fb56a0a..24a30a9 100644
--- a/tests/Integration/AsaasCustomerIdentifierCreator/AsaasCustomerIdentifierCreatorTest.php
+++ b/tests/Integration/CustomerIdentifierCreator/CustomerIdentifierCreatorTest.php
@@ -2,21 +2,21 @@
declare(strict_types=1);
-namespace Tests\Integration\AsaasCustomerIdentifierCreator;
+namespace Tests\Integration\CustomerIdentifierCreator;
-use Astrotech\AsaasGateway\AsaasCustomerIdentifierCreator\AsaasCustomerIdentifierCreator;
-use Astrotech\AsaasGateway\AsaasCustomerIdentifierCreator\Dto\AsaasCustomerData;
use Tests\TestCase;
+use AstrotechLabs\AsaasSdk\CustomerIdentifierCreator\Dto\CustomerData;
+use AstrotechLabs\AsaasSdk\CustomerIdentifierCreator\CustomerIdentifierCreator;
-final class AsaasCustomerIdentifierCreatorTest extends TestCase
+final class CustomerIdentifierCreatorTest extends TestCase
{
public function testItShouldCreateCustomerUniqueIdentifier()
{
$customerId = self::$faker->uuid;
- $sut = new AsaasCustomerIdentifierCreator($_ENV['ASAAS_API_KEY'], true);
+ $sut = new CustomerIdentifierCreator($_ENV['ASAAS_API_KEY'], true);
- $customerAsaasId = $sut->generateCustomerIdentifier(new AsaasCustomerData(
+ $customerAsaasId = $sut->generateCustomerIdentifier(new CustomerData(
name: self::$faker->name,
phone: self::$faker->phoneNumber,
cpfCnpj: self::$faker->numerify('67981499011'),
@@ -40,14 +40,16 @@ public function testItShouldCreateCustomerUniqueIdentifier()
public function testItShouldCreateCustomerUniqueIdentifierWhenProvideOnlyRequiredParameters()
{
- $sut = new AsaasCustomerIdentifierCreator($_ENV['ASAAS_API_KEY'], true);
+ $sut = new CustomerIdentifierCreator($_ENV['ASAAS_API_KEY'], true);
- $customerAsaasId = $sut->generateCustomerIdentifier(new AsaasCustomerData(
+ $customerAsaasId = $sut->generateCustomerIdentifier(new CustomerData(
name: self::$faker->name,
phone: self::$faker->phoneNumber,
cpfCnpj: self::$faker->numerify('67981499011')
));
+ print_r($customerAsaasId);
+
$this->assertNotEmpty($customerAsaasId->identifier);
$this->assertStringContainsString('cus_', $customerAsaasId->identifier);
}