From 07a24bca57195750d10d1ee4a3b7520c271604e7 Mon Sep 17 00:00:00 2001 From: Gianluca Bine Date: Sun, 11 Jul 2021 15:21:37 -0300 Subject: [PATCH 01/10] =?UTF-8?q?fix:=20passagem=20de=20par=C3=A2metros=20?= =?UTF-8?q?ao=20confirmar=20cobran=C3=A7a=20com=20pagamento=20em=20dinheir?= =?UTF-8?q?o=20e=20nome=20de=20m=C3=A9todo=20para=20desconfirmar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cobranca.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Cobranca.php b/src/Cobranca.php index 2a02d27..86f5b00 100755 --- a/src/Cobranca.php +++ b/src/Cobranca.php @@ -74,11 +74,12 @@ public function estorno($id){ // Confirmação em dinheiro public function confirmacao($id, $dados){ - return $this->http->post("/payments/{$id}/receiveInCash", array()); + return $this->http->post("/payments/{$id}/receiveInCash", $dados); } - // Confirmação em dinheiro - public function dezconfirmacao($id, $dados){ - return $this->http->post("/payments/{$id}/undoReceivedInCash", array()); + + // Desconfirmação em dinheiro + public function desconfirmacao($id, $dados){ + return $this->http->post("/payments/{$id}/undoReceivedInCash", $dados); } // Deleta uma cobrança From 77d7a339c5f1d8e7184739326d52fed5ed36c999 Mon Sep 17 00:00:00 2001 From: CodePhix Date: Wed, 14 Jul 2021 01:37:47 -0300 Subject: [PATCH 02/10] 2.0.2 --- .DS_Store | Bin 6148 -> 6148 bytes README.md | 2 +- src/Asaas.php | 14 +++++++ src/Cobranca.php | 9 +++++ src/ConsultaSerasa.php | 0 src/InformacoesFiscais.php | 0 src/LinkPagamento.php | 0 src/MinhaConta.php | 0 src/NotaFiscal.php | 2 +- src/Parcelamento.php | 77 +++++++++++++++++++++++++++++++++++ src/Pix.php | 81 +++++++++++++++++++++++++++++++++++++ 11 files changed, 183 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/ConsultaSerasa.php mode change 100644 => 100755 src/InformacoesFiscais.php mode change 100644 => 100755 src/LinkPagamento.php mode change 100644 => 100755 src/MinhaConta.php mode change 100644 => 100755 src/NotaFiscal.php create mode 100755 src/Parcelamento.php create mode 100755 src/Pix.php diff --git a/.DS_Store b/.DS_Store index ed0c180e491ab03ca61d2ab625a88d6a70e21207..97ea93d6f0d5eb4ebc642730a48ef58eca216d76 100644 GIT binary patch delta 144 zcmZoMXfc=|#>CJ*u~2NHo+3XB0|Nsi1A_pAVQ_MOZo$MtT}GD4YnUW#7PJ9nm>G&0 ziWrh}^Icq$a`KaaA{;=>{>lBYBeHA?n(QQIDaHev6`7y0Y&Kw4W7^El!OsD-5-9SW Uc{0CB)qF;Q%yo}wrR0|Nsi1A_nqLotIc5T`I?=cI3DWL(Zz50c_!NCXNd zf=RfvVQ_MOZUImh2wGHu1Qu1f`7SO=Ir&LIS)e%$;!o!va>S)F1*=LWOsfkrkgR4* zV3^n=VbjL~G?p3Y$RdVhWJ~9y+F6yG9R^tnmql0vk)8NJig5zavu{{7vvcrs07C`H b`OZ9Cobranca()->estorno(id); $cobranca = $asaas->Cobranca()->confirmacao(id); // Desfazer confirmação de recebimento em dinheiro -$cobranca = $asaas->Cobranca()->confirmacao(id); +$cobranca = $asaas->Cobranca()->dezconfirmacao(id); // Deleta uma cobrança $asaas->Cobranca()->delete(123); diff --git a/src/Asaas.php b/src/Asaas.php index a4583f5..d4f0eea 100755 --- a/src/Asaas.php +++ b/src/Asaas.php @@ -27,6 +27,8 @@ class Asaas { public $MinhaConta; public $InformacoesFiscais; public $ConsultaSerasa; + public $Pix; + public $Parcelamento; private $connection; @@ -48,6 +50,8 @@ public function __construct($token, $status = false) { $this->InformacoesFiscais = new InformacoesFiscais($this->connection); $this->ConsultaSerasa = new ConsultaSerasa($this->connection); $this->webhook = new Webhook($this->connection); + $this->Pix = new Pix($this->connection); + $this->Parcelamento = new Parcelamento($this->connection); } public function Assinatura(){ @@ -55,6 +59,16 @@ public function Assinatura(){ return $this->assinatura; } + public function Pix(){ + $this->Pix = new Pix($this->connection); + return $this->Pix; + } + + public function Parcelamento(){ + $this->Parcelamento = new Parcelamento($this->connection); + return $this->Parcelamento; + } + public function Cidade(){ $this->cidade = new Cidades($this->connection); return $this->cidade; diff --git a/src/Cobranca.php b/src/Cobranca.php index 2a02d27..984eabb 100755 --- a/src/Cobranca.php +++ b/src/Cobranca.php @@ -86,6 +86,15 @@ public function delete($id){ return $this->http->get('/payments/'.$id,'','DELETE'); } + + + // Retorna a listagem de cobranças de acordo com o Id da Assinaturas + public function Carner($id){ + return $this->http->get('/installments/id'.$id); + } + + + /** * Cria um novo boleto no Asaas. * @param Array $cliente diff --git a/src/ConsultaSerasa.php b/src/ConsultaSerasa.php old mode 100644 new mode 100755 diff --git a/src/InformacoesFiscais.php b/src/InformacoesFiscais.php old mode 100644 new mode 100755 diff --git a/src/LinkPagamento.php b/src/LinkPagamento.php old mode 100644 new mode 100755 diff --git a/src/MinhaConta.php b/src/MinhaConta.php old mode 100644 new mode 100755 diff --git a/src/NotaFiscal.php b/src/NotaFiscal.php old mode 100644 new mode 100755 index 0a815aa..5f6fca1 --- a/src/NotaFiscal.php +++ b/src/NotaFiscal.php @@ -41,7 +41,7 @@ public function ListMunicipalServices($parametos){ } public function issueInvoice($id){ - return $this->http->post('/invoices/'$id.'/authorize', arrat()); + return $this->http->post('/invoices/'.$id.'/authorize', arrat()); } public function create($id){ diff --git a/src/Parcelamento.php b/src/Parcelamento.php new file mode 100755 index 0000000..8460fb1 --- /dev/null +++ b/src/Parcelamento.php @@ -0,0 +1,77 @@ +http = $connection; + } + + // Retorna a listagem de cobranças + public function getAll(array $filtros = array()){ + $filtro = ''; + if(is_array($filtros)){ + if($filtros){ + foreach($filtros as $key => $f){ + if(!empty($f)){ + if($filtro){ + $filtro .= '&'; + } + $filtro .= $key.'='.$f; + } + } + $filtro = '?'.$filtro; + } + } + return $this->http->get('/installments'.$filtro); + } + + // Retorna os dados da cobrança de acordo com o Id + public function getById($id){ + return $this->http->get('/installments/'.$id); + } + + // Retorna os dados da cobrança de acordo com o Id + public function getBeefPdf($id){ + $id = str_replace( + array( + 'ins_00000000000', + 'ins_0000000000', + 'ins_000000000', + 'ins_00000000', + 'ins_0000000', + 'ins_000000', + 'ins_00000', + 'ins_0000', + 'ins_000', + 'ins_00', + 'ins_0', + 'ins_' + ),'',$id); + + $link = $this->http->base_url.'.asaas.com/installment/paymentBook/'.$id; + return $link; + } + + // Retorna a listagem de cobranças de acordo com o Id do Cliente + public function getByCustomer($customer_id){ + return $this->http->get('/installments?customer='.$customer_id); + } + + // Estorna cobrança + public function estorno($id){ + return $this->http->post("/installment/{$id}/refund", []); + } + + // Deleta uma cobrança + public function delete($id){ + return $this->http->get('/installments/'.$id,'','DELETE'); + } + +} diff --git a/src/Pix.php b/src/Pix.php new file mode 100755 index 0000000..9ab0a27 --- /dev/null +++ b/src/Pix.php @@ -0,0 +1,81 @@ +http = $connection; + } + + //https://www.asaas.com/api/v3/payments/id/pixQrCode + + //Retorna informação via Pix, para conta com liberação. + public function create($id) + { + + $resturn = $this->http->get('/payments/'.$id.'/pixQrCode'); + + if(!empty($resturn->encodedImage)){ + $resturn->success = 1; + return $resturn; + }else{ + return json_encode(array('success' => false)); + } + + /* + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, 'https://www.asaas.com/pixQrCode/createAsaasPaymentQrCode/'.$id); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_HEADER, FALSE); + + if(!empty($custom)){ + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $custom); + } + + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + "Content-Type: application/json" + )); + + $response = curl_exec($ch); + curl_close($ch); + $response = json_decode($response); + + //$response = $this->http->request('GET', $this->base_url . $url); + + return $response;*/ + } + + //Retorna informação via Pix, para conta com liberação. + public function get($id) + { + + $id = str_replace('pay_','',$id); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, 'https://www.asaas.com/payment/isReceivedPayment/'.$id); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_HEADER, FALSE); + + if(!empty($custom)){ + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $custom); + } + + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + "Content-Type: application/json" + )); + + $response = curl_exec($ch); + curl_close($ch); + $response = json_decode($response); + + //$response = $this->http->request('GET', $this->base_url . $url); + + return $response; + } + +} From 0120f43ffc776fe419e8ad1d236ac26739d84282 Mon Sep 17 00:00:00 2001 From: CodePhix Date: Wed, 14 Jul 2021 01:46:28 -0300 Subject: [PATCH 03/10] 2.0.1 --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 67f623c..dd9aa36 100755 --- a/README.md +++ b/README.md @@ -112,6 +112,25 @@ $asaas->Cobranca()->delete(123); ``` +Pix +------------ + +Para criar o pix, precisa ser adicionar uma cobrança e com esse id da cobrança será gerado o qrCode do pix, lembrando o qrCode é gerado até as 23:59h do mesmo dia. +O QrCode vem em base64. + +```php + +$Pix = $asaas->Pix()->create($id_cobranca); +if($Pix->success){ + echo ''; +} + +//Consulta se foi efetivado o pagamento via Pix, (Obs: Recomendo um post a cada 30s, ou um botão para confirmação do pagamento, assim não sobrecarregado o seu sistema e nem o do asaas ;) ). +$retorno = $asaas->Pix()->get($id_cobranca); + +``` + + Link de Pagamemto ------------ From 4c76f0a1b54009f42ea6bbfe1e29ed1ec231b7a9 Mon Sep 17 00:00:00 2001 From: Gianluca Bine Date: Sun, 25 Jul 2021 20:59:53 -0300 Subject: [PATCH 04/10] =?UTF-8?q?fix:=20corrigido=20par=C3=A2metros=20de?= =?UTF-8?q?=20fun=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/NotaFiscal.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NotaFiscal.php b/src/NotaFiscal.php index 0a815aa..b786a8d 100644 --- a/src/NotaFiscal.php +++ b/src/NotaFiscal.php @@ -41,10 +41,10 @@ public function ListMunicipalServices($parametos){ } public function issueInvoice($id){ - return $this->http->post('/invoices/'$id.'/authorize', arrat()); + return $this->http->post('/invoices/'. $id.'/authorize', array()); } - public function create($id){ + public function create($dadosConta){ return $this->http->post('/invoices', $dadosConta); } From ee0b463963dd6210afa39ea61c5f4898871346e3 Mon Sep 17 00:00:00 2001 From: mcharchat <73533552+mcharchat@users.noreply.github.com> Date: Fri, 20 Aug 2021 09:35:13 -0300 Subject: [PATCH 05/10] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20NotaFiscal.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/NotaFiscal.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NotaFiscal.php b/src/NotaFiscal.php index 5f6fca1..fd078de 100755 --- a/src/NotaFiscal.php +++ b/src/NotaFiscal.php @@ -41,10 +41,10 @@ public function ListMunicipalServices($parametos){ } public function issueInvoice($id){ - return $this->http->post('/invoices/'.$id.'/authorize', arrat()); + return $this->http->post('/invoices/'.$id.'/authorize', array()); } - public function create($id){ + public function create($dadosConta){ return $this->http->post('/invoices', $dadosConta); } @@ -53,7 +53,7 @@ public function update($id, $dadosConta){ } public function cancel($id){ - return $this->http->post('/invoices/'.$id.'/cancel', []); + return $this->http->post('/invoices/'.$id.'/cancel', array()); } } From b0e121b57c0be87405235fc4fe0cf4be4fad9a58 Mon Sep 17 00:00:00 2001 From: CodePhix Date: Tue, 28 Dec 2021 18:44:43 -0300 Subject: [PATCH 06/10] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5964020..98c45bb 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "php": "^7.2" + "php": ">=7.2" }, "autoload": { "psr-4": { From 261e69c662db151570f052f2e7b76b11efe35a55 Mon Sep 17 00:00:00 2001 From: Tiago <11445757+tiagocaus@users.noreply.github.com> Date: Mon, 3 Jan 2022 11:00:56 -0300 Subject: [PATCH 07/10] Update Cliente.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Email não é obrigatório. --- src/Cliente.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cliente.php b/src/Cliente.php index abfbae1..ce00344 100755 --- a/src/Cliente.php +++ b/src/Cliente.php @@ -183,6 +183,6 @@ public function setCliente($cliente) */ public function cliente_valid($cliente) { - return ! ( (empty($cliente['name']) OR empty($cliente['cpfCnpj']) OR empty($cliente['email'])) ? 1 : '' ); + return ! ( (empty($cliente['name']) OR empty($cliente['cpfCnpj'])) ? 1 : '' ); } -} \ No newline at end of file +} From 5b02a9b14a23881e117b0a2c2c58b6b3872501b4 Mon Sep 17 00:00:00 2001 From: CodePhix Date: Tue, 11 Jan 2022 22:08:03 -0300 Subject: [PATCH 08/10] 2.0.3 --- .DS_Store | Bin 6148 -> 6148 bytes composer.json | 2 +- src/.DS_Store | Bin 0 -> 6148 bytes 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/.DS_Store diff --git a/.DS_Store b/.DS_Store index 97ea93d6f0d5eb4ebc642730a48ef58eca216d76..3467b8489b69ad463cb44535327adb8f5468e0c6 100644 GIT binary patch delta 85 zcmZoMXfc=|#>B`mF;Q%yo+2ab!~pBb0*nnnMo+OYGea>$5kqoWa8X`PeqK5Q0|Vn` jM#fUM&Fmcf96(J#&Ufa?{33=Nj6k^tAl~dDvWFP}ie?j+ delta 63 zcmZoMXfc=|#>CJ*F;Q%yo+2a5!~knXmdQMf#haHhCb3Q4z_@HPI|n}pP{rnjjNh3j T^NScVGEBDNk=`65vVs`^KH3q% diff --git a/composer.json b/composer.json index 98c45bb..d4c15cb 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "authors": [ { "name": "Max Alex", - "email": "contato@codephix.com.br", + "email": "contato@codephix.com", "homepage": "https://www.codephix.com" } ], diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3e72e0d21c5f12d1766cb696bc7f7afd9226b033 GIT binary patch literal 6148 zcmeHKOHRWu5S@WmRCLoNOJAWkaI18~HW#ScqJWep5&xy{#>IH!8Kg#}YF7xsjAXyD z=VRwZu`@)(%a`4pXhuX6G(i?+KxBH*bYae8AmvFqTe_rd%va?z0;QN z=wSbKH7~dAzSB)#y&d!0w?(n3+YRhO(rq>USRD7=o$cG*AFjVf%He&!mXA%{HWlo6 z2QJQlGvEw31J1xn2JF6=Oiy~cgEQa^{5J;Vd Date: Mon, 17 Jan 2022 15:25:45 -0300 Subject: [PATCH 09/10] v2.0.3 --- .DS_Store | Bin 6148 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index 3467b8489b69ad463cb44535327adb8f5468e0c6..c4431bd993f6ad85a1b7a46c2b4b55e420419995 100644 GIT binary patch delta 61 zcmZoMXfc@JFT%#az`)4BAi$8Ela!yI1LQFCfX6N|J4*=253rhe1 From 89c9eea081faf40dfcf5a6abb9f6664d660ab8d8 Mon Sep 17 00:00:00 2001 From: Gianluca Bine Date: Wed, 2 Mar 2022 21:17:04 -0300 Subject: [PATCH 10/10] feat: suporte para PHP 8.0 e superior --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d4c15cb..8e23af3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "php": ">=7.2" + "php": "^7.2|^8.0" }, "autoload": { "psr-4": {