From 90d1a14a3635cca3f7b81414154f02d941143228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Lucas?= Date: Tue, 24 Dec 2024 11:23:22 -0300 Subject: [PATCH] PHPAY-31: fix: replace setFilters to setParams --- examples/asaas/charges.php | 18 ++++++++--------- .../Asaas/Resources/Charge/Charge.php | 20 ++++++++++++------- .../Charge/Interface/ChargeInterface.php | 6 +++--- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/examples/asaas/charges.php b/examples/asaas/charges.php index 6898a61..ca5e595 100644 --- a/examples/asaas/charges.php +++ b/examples/asaas/charges.php @@ -59,7 +59,7 @@ */ $phpay ->charge() - ->setFilters(['limit' => 5]) + ->setQueryParams(['limit' => 5]) ->getAll(); /** @@ -69,7 +69,7 @@ */ $phpay ->charge() - ->update($chargeCreated['id'], [ + ->update($chargeId, [ 'description' => 'Teste de fatura atualizado', ]); @@ -80,7 +80,7 @@ */ $phpay ->charge() - ->destroy($chargeCreated['id']); + ->destroy($chargeId); /** * restore charge @@ -89,7 +89,7 @@ */ $phpay ->charge() - ->restore($chargeCreated['id']); + ->restore($chargeId); /** * get charge status @@ -98,7 +98,7 @@ */ $phpay ->charge() - ->getStatus($chargeCreated['id']); + ->getStatus($chargeId); /** * get digitable line charge @@ -107,7 +107,7 @@ */ $phpay ->charge() - ->getDigitableLine($chargeCreated['id']); + ->getDigitableLine($chargeId); /** * get qrcode charge @@ -116,7 +116,7 @@ */ $qrcode = $phpay ->charge() - ->getQrCodePix($chargeCreated['id']); + ->getQrCodePix($chargeId); /** * confirm receipt charge @@ -125,7 +125,7 @@ */ $confirmed = $phpay ->charge() - ->confirmReceipt($chargeCreated['id'], [ + ->confirmReceipt($chargeId, [ 'paymentDate' => date('Y-m-d'), 'value' => 100.00, 'notifyCustomer' => true, @@ -138,4 +138,4 @@ */ $phpay ->charge() - ->undoConfirmReceipt($chargeCreated['id']); + ->undoConfirmReceipt($chargeId); diff --git a/src/Gateways/Asaas/Resources/Charge/Charge.php b/src/Gateways/Asaas/Resources/Charge/Charge.php index c46e297..b7b522f 100644 --- a/src/Gateways/Asaas/Resources/Charge/Charge.php +++ b/src/Gateways/Asaas/Resources/Charge/Charge.php @@ -23,7 +23,7 @@ class Charge implements ChargeInterface /** * @var array */ - private array $filter = []; + private array $queryParams = []; /** * construct @@ -43,14 +43,14 @@ public function __construct( } /** - * set filters + * set query params * - * @param array $filters + * @param array $queryParams * @return ChargeInterface */ - public function setFilters(array $filters): ChargeInterface + public function setQueryParams(array $queryParams): ChargeInterface { - $this->filter = $filters; + $this->queryParams = $queryParams; return $this; } @@ -91,7 +91,7 @@ public function find(string $id): array */ public function getAll(): array { - return $this->get('payments', $this->filter); + return $this->get('payments', $this->queryParams); } /** @@ -161,7 +161,13 @@ public function getStatus(string $id): array */ public function getDigitableLine(string $id): mixed { - return $this->get("payments/{$id}/identificationField")['identificationField']; + $charge = $this->get("payments/{$id}/identificationField"); + + if (isset($charge['identificationField'])) { + return $charge['identificationField']; + } + + return null; } /** diff --git a/src/Gateways/Asaas/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Asaas/Resources/Charge/Interface/ChargeInterface.php index 4800e0f..c24de77 100644 --- a/src/Gateways/Asaas/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Asaas/Resources/Charge/Interface/ChargeInterface.php @@ -60,12 +60,12 @@ public function restore(string $id): array; public function setCustomer(array $customer): ChargeInterface; /** - * set filter + * set query params * - * @param array $filters + * @param array $queryParams * @return ChargeInterface */ - public function setFilters(array $filters): ChargeInterface; + public function setQueryParams(array $queryParams): ChargeInterface; /** * get status charge by id