Skip to content

Commit bbbf6f4

Browse files
committed
PHPAY-49: set default query params value to get all charges with efi gateway
1 parent 0efbc12 commit bbbf6f4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

examples/efi/charges.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,8 @@
3434
*
3535
* @return array charges
3636
*/
37-
$phpay
37+
$charges = $phpay
3838
->charge()
39-
->setQueryParams([
40-
'charge_type' => 'billet',
41-
'begin_date' => '2024-11-01',
42-
'end_date' => '2024-11-30',
43-
'status' => 'unpaid',
44-
])
4539
->getAll();
4640

4741
/**

src/Gateways/Efi/Resources/Charge/Charge.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ public function setQueryParams(array $queryParams): ChargeInterface
9393
*/
9494
public function getAll(): array
9595
{
96+
if (empty($this->queryParams)) {
97+
$this->setQueryParams([
98+
'charge_type' => 'billet',
99+
'begin_date' => date('Y-m-d', strtotime('-30 days')),
100+
'end_date' => date('Y-m-d'),
101+
'status' => 'unpaid',
102+
]);
103+
}
104+
96105
return $this->get('v1/charges', $this->queryParams);
97106
}
98107

0 commit comments

Comments
 (0)