Skip to content

Commit 95cebea

Browse files
PHPAY-34: destroy and cancel charge on efi library (#43)
2 parents b8d6ad5 + 43535a5 commit 95cebea

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

examples/efi/charges.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,18 @@
6060
*/
6161
$phpay
6262
->charge()
63-
->confirmReceipt($chargeId, []);
63+
->confirmReceipt($chargeId);
64+
65+
/**
66+
* destroy charge
67+
*/
68+
$phpay
69+
->charge()
70+
->destroy($chargeId);
71+
72+
/**
73+
* cancel charge
74+
*/
75+
$phpay
76+
->charge()
77+
->cancel($chargeId);

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,22 @@ public function update(string $id, array $data): array
147147
* destroy charge
148148
*
149149
* @param string $id
150-
* @return bool
150+
* @return array<array|mixed>
151+
*/
152+
public function destroy(string $id): array
153+
{
154+
return $this->put("v1/charge/{$id}/cancel", []);
155+
}
156+
157+
/**
158+
* cancel charge
159+
*
160+
* @param string $id
161+
* @return array<array|mixed>
151162
*/
152-
public function destroy(string $id): bool
163+
public function cancel(string $id): array
153164
{
154-
return $this->delete("payments/{$id}");
165+
return $this->put("v1/charge/{$id}/cancel", []);
155166
}
156167

157168
/**
@@ -191,12 +202,11 @@ public function getQrCodePix(string $id): array
191202
* confirm receipt
192203
*
193204
* @param string $id
194-
* @param array<mixed> $data
195205
* @return array<mixed>
196206
*/
197-
public function confirmReceipt(string $id, array $data): array
207+
public function confirmReceipt(string $id): array
198208
{
199-
return $this->put("v1/charge/{$id}/settle", $data);
209+
return $this->put("v1/charge/{$id}/settle", []);
200210
}
201211

202212
/**

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,23 @@ public function setQueryParams(array $queryParams): ChargeInterface;
3939

4040
/**
4141
* @param string $id
42-
* @param array<mixed> $data
4342
* @return array<array|mixed>
4443
*/
45-
public function confirmReceipt(string $id, array $data): array;
44+
public function confirmReceipt(string $id): array;
45+
46+
/**
47+
* delete charge by id
48+
*
49+
* @param string $id
50+
* @return array<array|mixed>
51+
*/
52+
public function destroy(string $id): array;
53+
54+
/**
55+
* cancel charge by id
56+
*
57+
* @param string $id
58+
* @return array<array|mixed>
59+
*/
60+
public function cancel(string $id): array;
4661
}

0 commit comments

Comments
 (0)