Skip to content

Commit 06a11e7

Browse files
PHPAY-31: fix: replace setFilters to setParams (#38)
2 parents 706c2f9 + 90d1a14 commit 06a11e7

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

examples/asaas/charges.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
*/
6060
$phpay
6161
->charge()
62-
->setFilters(['limit' => 5])
62+
->setQueryParams(['limit' => 5])
6363
->getAll();
6464

6565
/**
@@ -69,7 +69,7 @@
6969
*/
7070
$phpay
7171
->charge()
72-
->update($chargeCreated['id'], [
72+
->update($chargeId, [
7373
'description' => 'Teste de fatura atualizado',
7474
]);
7575

@@ -80,7 +80,7 @@
8080
*/
8181
$phpay
8282
->charge()
83-
->destroy($chargeCreated['id']);
83+
->destroy($chargeId);
8484

8585
/**
8686
* restore charge
@@ -89,7 +89,7 @@
8989
*/
9090
$phpay
9191
->charge()
92-
->restore($chargeCreated['id']);
92+
->restore($chargeId);
9393

9494
/**
9595
* get charge status
@@ -98,7 +98,7 @@
9898
*/
9999
$phpay
100100
->charge()
101-
->getStatus($chargeCreated['id']);
101+
->getStatus($chargeId);
102102

103103
/**
104104
* get digitable line charge
@@ -107,7 +107,7 @@
107107
*/
108108
$phpay
109109
->charge()
110-
->getDigitableLine($chargeCreated['id']);
110+
->getDigitableLine($chargeId);
111111

112112
/**
113113
* get qrcode charge
@@ -116,7 +116,7 @@
116116
*/
117117
$qrcode = $phpay
118118
->charge()
119-
->getQrCodePix($chargeCreated['id']);
119+
->getQrCodePix($chargeId);
120120

121121
/**
122122
* confirm receipt charge
@@ -125,7 +125,7 @@
125125
*/
126126
$confirmed = $phpay
127127
->charge()
128-
->confirmReceipt($chargeCreated['id'], [
128+
->confirmReceipt($chargeId, [
129129
'paymentDate' => date('Y-m-d'),
130130
'value' => 100.00,
131131
'notifyCustomer' => true,
@@ -138,4 +138,4 @@
138138
*/
139139
$phpay
140140
->charge()
141-
->undoConfirmReceipt($chargeCreated['id']);
141+
->undoConfirmReceipt($chargeId);

src/Gateways/Asaas/Resources/Charge/Charge.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Charge implements ChargeInterface
2323
/**
2424
* @var array<mixed>
2525
*/
26-
private array $filter = [];
26+
private array $queryParams = [];
2727

2828
/**
2929
* construct
@@ -43,14 +43,14 @@ public function __construct(
4343
}
4444

4545
/**
46-
* set filters
46+
* set query params
4747
*
48-
* @param array<mixed> $filters
48+
* @param array<mixed> $queryParams
4949
* @return ChargeInterface
5050
*/
51-
public function setFilters(array $filters): ChargeInterface
51+
public function setQueryParams(array $queryParams): ChargeInterface
5252
{
53-
$this->filter = $filters;
53+
$this->queryParams = $queryParams;
5454

5555
return $this;
5656
}
@@ -91,7 +91,7 @@ public function find(string $id): array
9191
*/
9292
public function getAll(): array
9393
{
94-
return $this->get('payments', $this->filter);
94+
return $this->get('payments', $this->queryParams);
9595
}
9696

9797
/**
@@ -161,7 +161,13 @@ public function getStatus(string $id): array
161161
*/
162162
public function getDigitableLine(string $id): mixed
163163
{
164-
return $this->get("payments/{$id}/identificationField")['identificationField'];
164+
$charge = $this->get("payments/{$id}/identificationField");
165+
166+
if (isset($charge['identificationField'])) {
167+
return $charge['identificationField'];
168+
}
169+
170+
return null;
165171
}
166172

167173
/**

src/Gateways/Asaas/Resources/Charge/Interface/ChargeInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public function restore(string $id): array;
6060
public function setCustomer(array $customer): ChargeInterface;
6161

6262
/**
63-
* set filter
63+
* set query params
6464
*
65-
* @param array<mixed> $filters
65+
* @param array<mixed> $queryParams
6666
* @return ChargeInterface
6767
*/
68-
public function setFilters(array $filters): ChargeInterface;
68+
public function setQueryParams(array $queryParams): ChargeInterface;
6969

7070
/**
7171
* get status charge by id

0 commit comments

Comments
 (0)