From 68c6f251b3a3439e48114a90bc9c6121935bcaf7 Mon Sep 17 00:00:00 2001 From: skaisser Date: Mon, 28 Mar 2016 14:49:58 -0300 Subject: [PATCH 01/28] Fix HandleError() error message --- src/Adapter/GuzzleHttpAdapter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adapter/GuzzleHttpAdapter.php b/src/Adapter/GuzzleHttpAdapter.php index 3498a7f..8f76195 100644 --- a/src/Adapter/GuzzleHttpAdapter.php +++ b/src/Adapter/GuzzleHttpAdapter.php @@ -159,9 +159,9 @@ protected function handleError() { $body = (string) $this->response->getBody(); $code = (int) $this->response->getStatusCode(); - $content = json_decode($body); + $error = $content->errors[0]; - throw new HttpException(isset($content->message) ? $content->message : 'Request not processed.', $code); + throw new HttpException(isset($error) ? $error->description : 'Request not processed.', $code); } } \ No newline at end of file From fc2f3927835611d779f86c5c13a517328063c06a Mon Sep 17 00:00:00 2001 From: Shirleyson Kaisser Date: Fri, 22 Jul 2016 11:26:28 -0300 Subject: [PATCH 02/28] Added the Installment Atribute --- src/Entity/Payment.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 72082c4..126335a 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -88,6 +88,10 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $boletoUrl; + /** + * @var int + */ + public $installment; /** * @var int */ From f2000f791a765f0e9dccbc4eaf8af1ed57e6a2e1 Mon Sep 17 00:00:00 2001 From: Shirleyson Kaisser Date: Fri, 22 Jul 2016 11:38:24 -0300 Subject: [PATCH 03/28] add get payment by installment id --- src/Api/Payment.php | 16 ++++++++++++++++ src/Entity/Installment.php | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/Entity/Installment.php diff --git a/src/Api/Payment.php b/src/Api/Payment.php index f060751..ca53ef7 100644 --- a/src/Api/Payment.php +++ b/src/Api/Payment.php @@ -3,6 +3,7 @@ // Entities use Softr\Asaas\Entity\Payment as PaymentEntity; +use Softr\Asaas\Entity\Installment as InstallmentEntity; /** * Payment API Endpoint @@ -67,6 +68,21 @@ public function getByCustomer($customerId, array $filters = []) }, $payments->data); } + /** + * Get Payment By Installment Id + * + * @param int $installmentId Installment Id + * @return PaymentEntity + */ + public function getByInstallmentId($installmentId) + { + $installment = $this->adapter->get(sprintf('%s/payments?installment=%s', $this->endpoint, $installmentId)); + + $installment = json_decode($installment); + + return new InstallmentEntity($installment); + } + /** * Get Payments By Subscription Id * diff --git a/src/Entity/Installment.php b/src/Entity/Installment.php new file mode 100644 index 0000000..8dedb2e --- /dev/null +++ b/src/Entity/Installment.php @@ -0,0 +1,17 @@ + + */ +final class Installment extends \Softr\Asaas\Entity\AbstractEntity +{ + /** + * @var array + */ + public $data; + + +} \ No newline at end of file From 40efb48829b5829d8c2e8639b05e41097cb95612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A1s=20Garcia?= Date: Fri, 8 Dec 2017 10:12:50 -0200 Subject: [PATCH 04/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7daa960..979a87a 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ $action123 = $asaas->city()->getById(123); Documentação Oficial -------------------- -Obs.: Esta é uma API não oficial. Foi feita com base na documentação disponibilizada [neste link](https://docs.google.com/document/d/1XUJRHY_0nd45CzFK5EmjDK92qgaQJGMxT0rjZriTk-g). +Obs.: Esta é uma API não oficial baseada na API ASAAS v2. A documentação oficial da última versão da API ASAAS está disponibilizada [neste link](https://asaasv3.docs.apiary.io). Creditos From 0c0e9e79c18a828efae2891b8a00d95592e2ea8d Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Wed, 27 Feb 2019 18:09:11 -0300 Subject: [PATCH 05/28] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20de=20Endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atualizado a versão dos endpoints homologação e produção para a v3 --- src/Api/AbstractApi.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 4cd5626..885162c 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -16,14 +16,14 @@ abstract class AbstractApi * * @var string */ - const ENDPOINT_PRODUCAO = 'https://www.asaas.com/api/v2'; + const ENDPOINT_PRODUCAO = 'https://www.asaas.com/api/v3'; /** * Endpoint Homologação * * @var string */ - const ENDPOINT_HOMOLOGACAO = 'http://homolog.asaas.com/api/v2'; + const ENDPOINT_HOMOLOGACAO = 'http://homolog.asaas.com/api/v3'; /** * Http Adapter Instance @@ -79,4 +79,4 @@ public function getMeta() { return $this->meta; } -} \ No newline at end of file +} From 4b00f89862a4306e9dfe2e755a89d587c694d617 Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Wed, 27 Feb 2019 18:17:03 -0300 Subject: [PATCH 06/28] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20das=20propriedade?= =?UTF-8?q?s=20para=20v3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Incluído: $municipalInscription, $stateInscription, $groupName, $additionalEmails, $externalReference Sinalizado como Depreciado: $foreignCustomer --- src/Entity/Customer.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 2b1d6c2..773e3d2 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -57,9 +57,15 @@ final class Customer extends \Softr\Asaas\Entity\AbstractEntity * @var string */ public $province; - + + /** + * @var string Identificador do cliente no seu sistema + */ + public externalReference; + /** * @var bool + * @deprecated Property not found on v3 API */ public $foreignCustomer; @@ -98,6 +104,26 @@ final class Customer extends \Softr\Asaas\Entity\AbstractEntity */ public $personType; + /** + * @var string + */ + public $additionalEmails; + + /** + * @var string + */ + public $municipalInscription; + + /** + * @var string + */ + public $stateInscription; + + /** + * @var string + */ + public $groupName; + /** * @var array */ @@ -112,4 +138,4 @@ final class Customer extends \Softr\Asaas\Entity\AbstractEntity * @var array */ public $notifications = []; -} \ No newline at end of file +} From 7aac4a995adf6abdccdd08ceda285084da68a012 Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Wed, 27 Feb 2019 18:19:29 -0300 Subject: [PATCH 07/28] =?UTF-8?q?Atualizado=20vers=C3=A3o=20de=20refer?= =?UTF-8?q?=C3=AAncia=20da=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atualizado o comentário sobre a versão da API para a v3 Ajustado referência sobre última versão ser diferente da v3 que está sendo atualizada --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 979a87a..205124d 100644 --- a/README.md +++ b/README.md @@ -183,10 +183,10 @@ $action123 = $asaas->city()->getById(123); Documentação Oficial -------------------- -Obs.: Esta é uma API não oficial baseada na API ASAAS v2. A documentação oficial da última versão da API ASAAS está disponibilizada [neste link](https://asaasv3.docs.apiary.io). +Obs.: Esta é uma API não oficial baseada na API ASAAS v3. A documentação oficial da API ASAAS está disponibilizada [neste link](https://asaasv3.docs.apiary.io). -Creditos +Créditos -------- * [Agência Softr Ltda - www.softr.com.br](http://www.softr.com.br) From 0e54976da130f7fda5872f67e859ddd65bedfe78 Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Wed, 27 Feb 2019 18:22:44 -0300 Subject: [PATCH 08/28] Fix propertyName $externalReference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrigido o nome da propriedade $externalReference - faltava o $ da variável --- src/Entity/Customer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 773e3d2..4565dd9 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -61,7 +61,7 @@ final class Customer extends \Softr\Asaas\Entity\AbstractEntity /** * @var string Identificador do cliente no seu sistema */ - public externalReference; + public $externalReference; /** * @var bool From 7914915fd1a4189d4b2a4f9b96ca6281c0f2cd56 Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Thu, 28 Feb 2019 10:49:45 -0300 Subject: [PATCH 09/28] =?UTF-8?q?Inclus=C3=A3o=20de=20m=C3=A9todos=20getBy?= =?UTF-8?q?CpfCnpj=20e=20getByName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inclusão: getByCpfCnpj getByName Ajuste getByEmail --- src/Api/Customer.php | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/Api/Customer.php b/src/Api/Customer.php index 9d25793..133bc9a 100644 --- a/src/Api/Customer.php +++ b/src/Api/Customer.php @@ -27,7 +27,7 @@ public function getAll(array $filters = []) return array_map(function($customer) { - return new CustomerEntity($customer->customer); + return new CustomerEntity($customer); }, $customers->data); } @@ -46,6 +46,28 @@ public function getById($id) return new CustomerEntity($customer); } + /** + * Get Customer By Name + * + * @param string $name Customer Name + * @return CustomerEntity + */ + public function getByName($name) + { + return $this->getAll(['name' => $name]); + } + + /** + * Get Customer By CPF/CNPJ + * + * @param string $cpfCnpj Customer CPF / CNPJ + * @return CustomerEntity + */ + public function getByCpfCnpj($cpfCnpj) + { + return $this->getAll(['cpfCnpj' => $cpfCnpj]); + } + /** * Get Customer By Email * @@ -54,15 +76,7 @@ public function getById($id) */ public function getByEmail($email) { - foreach($this->getAll(['name' => $email]) as $customer) - { - if($customer->email == $email) - { - return $customer; - } - } - - return; + return $this->getAll(['email' => $email]); } /** @@ -105,4 +119,4 @@ public function delete($id) { $this->adapter->delete(sprintf('%s/customers/%s', $this->endpoint, $id)); } -} \ No newline at end of file +} From 89068e4bdfa024361a6fd213897d06cd914014bf Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Thu, 28 Feb 2019 10:50:52 -0300 Subject: [PATCH 10/28] Fix PHPDoc getByEmail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajustado o PHPDoc do método getByEmail estava passando orientação errada na descrição do parâmetro --- src/Api/Customer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Customer.php b/src/Api/Customer.php index 133bc9a..aa6e5cf 100644 --- a/src/Api/Customer.php +++ b/src/Api/Customer.php @@ -71,7 +71,7 @@ public function getByCpfCnpj($cpfCnpj) /** * Get Customer By Email * - * @param string $email Customer Id + * @param string $email Customer e-mail * @return CustomerEntity */ public function getByEmail($email) From cf7ba16bcb93d85f4c54d549b4338d9bfed56106 Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Thu, 28 Feb 2019 10:51:46 -0300 Subject: [PATCH 11/28] =?UTF-8?q?Atualizado=20endere=C3=A7o=20Homologa?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atualizado o endereço da homologação para sandbox.asaas.com/api/v3 --- src/Api/AbstractApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 885162c..9b674b9 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -23,7 +23,7 @@ abstract class AbstractApi * * @var string */ - const ENDPOINT_HOMOLOGACAO = 'http://homolog.asaas.com/api/v3'; + const ENDPOINT_HOMOLOGACAO = 'http://sandbox.asaas.com/api/v3'; /** * Http Adapter Instance From 7e231fccdd090e05442c10905635e3acf04e3735 Mon Sep 17 00:00:00 2001 From: Gildonei M A Junior Date: Wed, 20 Mar 2019 08:58:56 -0300 Subject: [PATCH 12/28] =?UTF-8?q?Atualiza=C3=A7=C3=B5es=20para=20a=20V3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Payment.php - adicionados novas propriedades da V3 - Entity\Customer.php - adicionados novas propriedades da V3 - Api\Customer.php - add novos métodos como getByCpfCnpj - GuzzleHttpAdapter.php - modificado o método de retorno de erros para sintaxe correta --- src/Adapter/GuzzleHttpAdapter.php | 1 - src/Api/AbstractApi.php | 22 +++++++++++++++++++--- src/Api/Customer.php | 2 +- src/Api/Payment.php | 16 ---------------- src/Entity/Customer.php | 10 +++++----- src/Entity/Payment.php | 9 +++++---- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Adapter/GuzzleHttpAdapter.php b/src/Adapter/GuzzleHttpAdapter.php index 8f76195..be9e820 100644 --- a/src/Adapter/GuzzleHttpAdapter.php +++ b/src/Adapter/GuzzleHttpAdapter.php @@ -162,6 +162,5 @@ protected function handleError() $content = json_decode($body); $error = $content->errors[0]; - throw new HttpException(isset($error) ? $error->description : 'Request not processed.', $code); } } \ No newline at end of file diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 9b674b9..ac9de97 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -23,7 +23,14 @@ abstract class AbstractApi * * @var string */ - const ENDPOINT_HOMOLOGACAO = 'http://sandbox.asaas.com/api/v3'; + const ENDPOINT_HOMOLOGACAO = 'https://sandbox.asaas.com/api/v3'; + + /** + * Endpoint Sandbox + * + * @var string + */ + const ENDPOINT_SANDBOX = 'https://sandbox.asaas.com/api/v3'; /** * Http Adapter Instance @@ -54,7 +61,16 @@ public function __construct(AdapterInterface $adapter, $ambiente = 'producao') { $this->adapter = $adapter; - $this->endpoint = $ambiente == 'homologacao' ? static::ENDPOINT_HOMOLOGACAO : static::ENDPOINT_PRODUCAO; + switch ($ambiente) { + case 'sandbox': + $this->endpoint = static::ENDPOINT_SANDBOX; + break; + case 'homologacao': + $this->endpoint = static::ENDPOINT_HOMOLOGACAO; + break; + default: + $this->endpoint = static::ENDPOINT_PRODUCAO; + } } /** @@ -79,4 +95,4 @@ public function getMeta() { return $this->meta; } -} +} \ No newline at end of file diff --git a/src/Api/Customer.php b/src/Api/Customer.php index aa6e5cf..1d2533b 100644 --- a/src/Api/Customer.php +++ b/src/Api/Customer.php @@ -119,4 +119,4 @@ public function delete($id) { $this->adapter->delete(sprintf('%s/customers/%s', $this->endpoint, $id)); } -} +} \ No newline at end of file diff --git a/src/Api/Payment.php b/src/Api/Payment.php index ca53ef7..f060751 100644 --- a/src/Api/Payment.php +++ b/src/Api/Payment.php @@ -3,7 +3,6 @@ // Entities use Softr\Asaas\Entity\Payment as PaymentEntity; -use Softr\Asaas\Entity\Installment as InstallmentEntity; /** * Payment API Endpoint @@ -68,21 +67,6 @@ public function getByCustomer($customerId, array $filters = []) }, $payments->data); } - /** - * Get Payment By Installment Id - * - * @param int $installmentId Installment Id - * @return PaymentEntity - */ - public function getByInstallmentId($installmentId) - { - $installment = $this->adapter->get(sprintf('%s/payments?installment=%s', $this->endpoint, $installmentId)); - - $installment = json_decode($installment); - - return new InstallmentEntity($installment); - } - /** * Get Payments By Subscription Id * diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 4565dd9..5e31ff1 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -57,12 +57,12 @@ final class Customer extends \Softr\Asaas\Entity\AbstractEntity * @var string */ public $province; - + /** * @var string Identificador do cliente no seu sistema */ public $externalReference; - + /** * @var bool * @deprecated Property not found on v3 API @@ -108,12 +108,12 @@ final class Customer extends \Softr\Asaas\Entity\AbstractEntity * @var string */ public $additionalEmails; - + /** * @var string */ public $municipalInscription; - + /** * @var string */ @@ -138,4 +138,4 @@ final class Customer extends \Softr\Asaas\Entity\AbstractEntity * @var array */ public $notifications = []; -} +} \ No newline at end of file diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 126335a..7b6f2f1 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -88,10 +88,6 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $boletoUrl; - /** - * @var int - */ - public $installment; /** * @var int */ @@ -197,6 +193,11 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $creditCardHolderMobilePhoneDDD; + /** + * @var string Identificador do título no sistema origem + */ + public $externalReference; + /** * @param string $dueDate */ From 916e10dddf443368a62a016f304bbb0a448bf24e Mon Sep 17 00:00:00 2001 From: Luiz Eduardo <79588243+Luizea-dev@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:08:02 -0300 Subject: [PATCH 13/28] Update subscription fields --- src/Entity/Subscription.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Entity/Subscription.php b/src/Entity/Subscription.php index 67bcd10..fa9ff2d 100644 --- a/src/Entity/Subscription.php +++ b/src/Entity/Subscription.php @@ -1,4 +1,5 @@ endDate = static::convertDateTime($endDate); } -} \ No newline at end of file +} From c36d9613cf0230c7cccdbaf90005685d1e26f04b Mon Sep 17 00:00:00 2001 From: Luiz Eduardo <79588243+Luizea-dev@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:09:24 -0300 Subject: [PATCH 14/28] Update post request content-type --- src/Adapter/GuzzleHttpAdapter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adapter/GuzzleHttpAdapter.php b/src/Adapter/GuzzleHttpAdapter.php index be9e820..bac534e 100644 --- a/src/Adapter/GuzzleHttpAdapter.php +++ b/src/Adapter/GuzzleHttpAdapter.php @@ -119,7 +119,7 @@ public function put($url, $content = '') public function post($url, $content = '') { $options = []; - $options['form_params'] = $content; + $options['json'] = $content; try { @@ -163,4 +163,4 @@ protected function handleError() $error = $content->errors[0]; } -} \ No newline at end of file +} From 34bb2a8387d162ee5cf23bde73589f2ce89ba81f Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Wed, 28 Dec 2022 15:37:24 -0300 Subject: [PATCH 15/28] Update GuzzleHttpAdapter.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modificado o método handleError para manipular o retorno de erros em formato de array --- src/Adapter/GuzzleHttpAdapter.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Adapter/GuzzleHttpAdapter.php b/src/Adapter/GuzzleHttpAdapter.php index bac534e..dc6a4b4 100644 --- a/src/Adapter/GuzzleHttpAdapter.php +++ b/src/Adapter/GuzzleHttpAdapter.php @@ -159,8 +159,20 @@ protected function handleError() { $body = (string) $this->response->getBody(); $code = (int) $this->response->getStatusCode(); - $content = json_decode($body); - $error = $content->errors[0]; + $content = json_decode($body); + + $errors = []; + if (isset($content->errors)) { + foreach ((array)$content->errors as $error) { + $errors[] = $error->code . ': ' . $error->description; + } + } + + if (!empty($errors)) { + throw new HttpException(implode('
', $errors), $code); + } + + throw new HttpException(isset($content->message) ? $content->message : 'Request not processed.', $code); } } From 6ceae91c109682bf5e34ccab97595d2da6ac7125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Mon, 16 Jan 2023 09:55:13 -0300 Subject: [PATCH 16/28] Update composer.json Atualizado o nome do pacote para poder enviar ao Packagist --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a0f9fbf..022922b 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name" : "softr/asaas-php-sdk", + "name" : "lupainformatica/asaas-php-sdk", "type" : "library", "description": "Asaas.com PHP API Wrapper", "keywords" : ["Asaas", "API", "Payment SaaS", "Credit Card", "Boleto"], @@ -31,4 +31,4 @@ } }, "minimum-stability": "dev" -} \ No newline at end of file +} From a547c611c285dfd7bef4fa6d66d68f4db656426d Mon Sep 17 00:00:00 2001 From: Luizea-dev Date: Wed, 15 Feb 2023 14:48:57 -0300 Subject: [PATCH 17/28] Ajustado erro em ::getAll() e add ::getList() --- src/Api/Subscription.php | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Api/Subscription.php b/src/Api/Subscription.php index a76cfe0..a1613d3 100644 --- a/src/Api/Subscription.php +++ b/src/Api/Subscription.php @@ -1,4 +1,5 @@ adapter->get(sprintf('%s/subscriptions?%s', $this->endpoint, http_build_query($filters))); + + $subscriptions = json_decode($subscriptions); + + $this->extractMeta($subscriptions); + + return $subscriptions; + } + /** * Get all subscriptions * @@ -25,9 +43,8 @@ public function getAll(array $filters = []) $this->extractMeta($subscriptions); - return array_map(function($subscription) - { - return new SubscriptionEntity($subscription->subscription); + return array_map(function ($subscription) { + return new SubscriptionEntity($subscription); }, $subscriptions->data); } @@ -61,9 +78,8 @@ public function getByCustomer($customerId) $this->extractMeta($subscriptions); - return array_map(function($subscription) - { - return new SubscriptionEntity($subscription->subscription); + return array_map(function ($subscription) { + return new SubscriptionEntity($subscription); }, $subscriptions->data); } @@ -107,4 +123,4 @@ public function delete($id) { $this->adapter->delete(sprintf('%s/subscriptions/%s', $this->endpoint, $id)); } -} \ No newline at end of file +} From 74c1d730c646b30aaa0ee366bbb581a80cd4a189 Mon Sep 17 00:00:00 2001 From: Luizea-dev Date: Wed, 15 Feb 2023 17:25:23 -0300 Subject: [PATCH 18/28] Paginate method --- src/Api/Payment.php | 29 ++++++++++++++++++++++------- src/Api/Subscription.php | 4 ++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Api/Payment.php b/src/Api/Payment.php index f060751..783000c 100644 --- a/src/Api/Payment.php +++ b/src/Api/Payment.php @@ -1,4 +1,5 @@ adapter->get(sprintf('%s/payments?%s', $this->endpoint, http_build_query($filters))); + + $payments = json_decode($payments); + + $this->extractMeta($payments); + + return $payments; + } + /** * Get all payments * @@ -25,8 +43,7 @@ public function getAll(array $filters = []) $this->extractMeta($payments); - return array_map(function($payment) - { + return array_map(function ($payment) { return new PaymentEntity($payment); }, $payments->data); } @@ -61,8 +78,7 @@ public function getByCustomer($customerId, array $filters = []) $this->extractMeta($payments); - return array_map(function($payment) - { + return array_map(function ($payment) { return new PaymentEntity($payment); }, $payments->data); } @@ -82,8 +98,7 @@ public function getBySubscription($subscriptionId) $this->extractMeta($payments); - return array_map(function($payment) - { + return array_map(function ($payment) { return new PaymentEntity($payment); }, $payments->data); } @@ -128,4 +143,4 @@ public function delete($id) { $this->adapter->delete(sprintf('%s/payments/%s', $this->endpoint, $id)); } -} \ No newline at end of file +} diff --git a/src/Api/Subscription.php b/src/Api/Subscription.php index a1613d3..0046559 100644 --- a/src/Api/Subscription.php +++ b/src/Api/Subscription.php @@ -13,12 +13,12 @@ class Subscription extends \Softr\Asaas\Api\AbstractApi { /** - * Get all subscriptions + * Get paginate subscriptions * * @param array $filters (optional) Filters Array * @return array Subscriptions Array */ - public function getList(array $filters = []) + public function getPaginate(array $filters = []) { $subscriptions = $this->adapter->get(sprintf('%s/subscriptions?%s', $this->endpoint, http_build_query($filters))); From 53670f3f3e67274431306413f0531cbdf856cd84 Mon Sep 17 00:00:00 2001 From: Gildonei M A Junior Date: Wed, 22 Nov 2023 19:59:02 -0300 Subject: [PATCH 19/28] Paymet.php * Adicionados os novos campos para a Entity Signed-off-by: Gildonei M A Junior --- src/Entity/Payment.php | 115 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 7b6f2f1..81210a3 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -8,6 +8,11 @@ */ final class Payment extends \Softr\Asaas\Entity\AbstractEntity { + /** + * @var string + */ + public $object; + /** * @var int */ @@ -18,6 +23,16 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $customer; + /** + * @var string + */ + public $installment; + + /** + * @var string + */ + public $paymentLink; + /** * @var string */ @@ -28,6 +43,36 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $billingType; + /** + * @var bool + */ + public $canBePaidAfterDueDate; + + /** + * @var bool + */ + public $deleted; + + /** + * @var bool + */ + public $anticipated; + + /** + * @var bool + */ + public $anticipable; + + /** + * @var bool + */ + public $postalService; + + /** + * @var string + */ + public $pixTransaction; + /** * @var float */ @@ -83,11 +128,21 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $invoiceUrl; + /** + * @var string + */ + public $transactionReceiptUrl; + /** * @var string */ public $boletoUrl; + /** + * @var string + */ + public $bankSlipUrl; + /** * @var int */ @@ -198,6 +253,26 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $externalReference; + /** + * @var int + */ + public $installmentNumber; + + /** + * @var array|string + */ + public $discount; + + /** + * @var array|string + */ + public $fine; + + /** + * @var array|string + */ + public $interest; + /** * @param string $dueDate */ @@ -205,4 +280,44 @@ public function setDueDate($dueDate) { $this->dueDate = static::convertDateTime($dueDate); } + + /** + * @param string $originalDueDate + */ + public function setOriginalDueDate($originalDueDate) + { + $this->originalDueDate = static::convertDateTime($originalDueDate); + } + + /** + * @param string $paymentDate + */ + public function setPaymentDate($paymentDate) + { + $this->paymentDate = static::convertDateTime($paymentDate); + } + + /** + * @param string $clientPaymentDate + */ + public function setClientPaymentDate($clientPaymentDate) + { + $this->clientPaymentDate = static::convertDateTime($clientPaymentDate); + } + + /** + * @param string $creditDate + */ + public function setCreditDate($creditDate) + { + $this->creditDate = static::convertDateTime($creditDate); + } + + /** + * @param string $estimatedCreditDate + */ + public function setEstimatedCreditDate($estimatedCreditDate) + { + $this->estimatedCreditDate = static::convertDateTime($estimatedCreditDate); + } } \ No newline at end of file From cc2b0e591c32aa8b935900049306d013ea41394c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Fri, 24 Nov 2023 13:58:32 -0300 Subject: [PATCH 20/28] Update GuzzleHttpAdapter.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Atualizado constante de controle de versão da Cliente version --- src/Adapter/GuzzleHttpAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapter/GuzzleHttpAdapter.php b/src/Adapter/GuzzleHttpAdapter.php index dc6a4b4..b2f36cf 100644 --- a/src/Adapter/GuzzleHttpAdapter.php +++ b/src/Adapter/GuzzleHttpAdapter.php @@ -41,7 +41,7 @@ class GuzzleHttpAdapter implements AdapterInterface */ public function __construct($token, ClientInterface $client = null) { - if(version_compare(ClientInterface::VERSION, '6') === 1) + if(version_compare(ClientInterface::MAJOR_VERSION, '6') === 1) { $this->client = $client ?: new Client(['headers' => ['access_token' => $token]]); } From 59487f7d1d52d44c91390df8dd47e76b09b14788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Fri, 24 Nov 2023 14:59:29 -0300 Subject: [PATCH 21/28] Update Payment.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adicionado método deleteInstallment --- src/Api/Payment.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Api/Payment.php b/src/Api/Payment.php index 783000c..b548d77 100644 --- a/src/Api/Payment.php +++ b/src/Api/Payment.php @@ -143,4 +143,14 @@ public function delete($id) { $this->adapter->delete(sprintf('%s/payments/%s', $this->endpoint, $id)); } + + /** + * Delete Payment By Id + * + * @param string|int $id Payment Id + */ + public function deleteInstallment($id) + { + $this->adapter->delete(sprintf('%s/installments/%s', $this->endpoint, $id)); + } } From 9e057c58c97b9603c29ee4fced35379058fbd2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:27:21 -0300 Subject: [PATCH 22/28] Update AbstractEntity.php --- src/Entity/AbstractEntity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entity/AbstractEntity.php b/src/Entity/AbstractEntity.php index 5d3f780..f07ecb3 100644 --- a/src/Entity/AbstractEntity.php +++ b/src/Entity/AbstractEntity.php @@ -66,7 +66,7 @@ protected static function convertDateTime($date) return; } - $date = \DateTime::createFromFormat('d/m/Y', $date); + $date = new \DateTime($date); if(!$date) { @@ -91,4 +91,4 @@ protected static function convertToCamelCase($str) return lcfirst(preg_replace_callback('/(^|_)([a-z])/', $callback, $str)); } -} \ No newline at end of file +} From 5e89e8b82c6f645ad4e071e7d10f70f0814ba99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:20:51 -0300 Subject: [PATCH 23/28] Add files via upload --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fcaf8f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# VSCode +########################## +.history/ +.svn/ + +!.vendor/ +.vendor/* +!.vendor/.gitkeep \ No newline at end of file From f4f27f3854cf7bd42b4bae304865a39d80117ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:21:52 -0300 Subject: [PATCH 24/28] Update Payment.php Added refund method --- src/Api/Payment.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Api/Payment.php b/src/Api/Payment.php index b548d77..3123df0 100644 --- a/src/Api/Payment.php +++ b/src/Api/Payment.php @@ -134,6 +134,22 @@ public function update($id, array $data) return new PaymentEntity($payment); } + /** + * Refund a Payment By Id + * + * @param string $id Payment Id + * @param array $data Payment Data + * @return PaymentEntity + */ + public function refund($id, array $data) + { + $payment = $this->adapter->post(sprintf('%s/payments/%s/refund', $this->endpoint, $id), $data); + + $payment = json_decode($payment); + + return new PaymentEntity($payment); + } + /** * Delete Payment By Id * From 0b8c633f81aa0c58fe9a35cf612841fe01ba18f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:39:50 -0300 Subject: [PATCH 25/28] Update Payment.php --- src/Entity/Payment.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 81210a3..9161460 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -273,6 +273,16 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $interest; + /** + * @var string + */ + public $confirmedDate + + /** + * @var string + */ + public $confirmedDate + /** * @param string $dueDate */ @@ -280,7 +290,7 @@ public function setDueDate($dueDate) { $this->dueDate = static::convertDateTime($dueDate); } - + /** * @param string $originalDueDate */ @@ -320,4 +330,12 @@ public function setEstimatedCreditDate($estimatedCreditDate) { $this->estimatedCreditDate = static::convertDateTime($estimatedCreditDate); } -} \ No newline at end of file + + /** + * @param string $confirmedDate + */ + public function setConfirmedDate($confirmedDate) + { + $this->confirmedDate = static::convertDateTime(confirmedDate); + } +} From 4877322e2e621b8950c15e8d06615d752b3a5a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:43:29 -0300 Subject: [PATCH 26/28] Update Payment.php --- src/Entity/Payment.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 9161460..cf31156 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -272,16 +272,11 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity * @var array|string */ public $interest; - - /** - * @var string - */ - public $confirmedDate /** * @var string */ - public $confirmedDate + public $confirmedDate; /** * @param string $dueDate From e435eeec2f7c7ba2b997f0ba14c7e4dffd5032f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lupa=20Inform=C3=A1tica?= <67587830+lupainformatica@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:45:24 -0300 Subject: [PATCH 27/28] Update Payment.php --- src/Entity/Payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index cf31156..9e42d7c 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -331,6 +331,6 @@ public function setEstimatedCreditDate($estimatedCreditDate) */ public function setConfirmedDate($confirmedDate) { - $this->confirmedDate = static::convertDateTime(confirmedDate); + $this->confirmedDate = static::convertDateTime($confirmedDate); } } From a1e685e0a9da1bcc91c1061c44c7f725b86d88e5 Mon Sep 17 00:00:00 2001 From: Gildonei Mendes Anacleto Junior Date: Wed, 18 Sep 2024 18:52:05 -0300 Subject: [PATCH 28/28] chore: update asaas production endpoint --- src/Api/AbstractApi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index ac9de97..be5ef16 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -16,7 +16,7 @@ abstract class AbstractApi * * @var string */ - const ENDPOINT_PRODUCAO = 'https://www.asaas.com/api/v3'; + const ENDPOINT_PRODUCAO = 'https://api.asaas.com/v3'; /** * Endpoint Homologação @@ -95,4 +95,4 @@ public function getMeta() { return $this->meta; } -} \ No newline at end of file +}