From b84dbc8a951c0fc1e049fe5f3e86e1afeb2456ea Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Fri, 27 Dec 2024 02:24:02 -0300 Subject: [PATCH 1/4] PHPAY-34: confirm receipt function on efi library --- examples/efi/charges.php | 2 +- src/Gateways/Efi/Resources/Charge/Charge.php | 5 ++--- .../Efi/Resources/Charge/Interface/ChargeInterface.php | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/efi/charges.php b/examples/efi/charges.php index a35c63e..6fe04de 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -60,4 +60,4 @@ */ $phpay ->charge() - ->confirmReceipt($chargeId, []); + ->confirmReceipt($chargeId); diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index 72de33b..7139447 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -191,12 +191,11 @@ public function getQrCodePix(string $id): array * confirm receipt * * @param string $id - * @param array $data * @return array */ - public function confirmReceipt(string $id, array $data): array + public function confirmReceipt(string $id): array { - return $this->put("v1/charge/{$id}/settle", $data); + return $this->put("v1/charge/{$id}/settle"); } /** diff --git a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php index 3e1e0f0..09591d0 100644 --- a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php @@ -39,8 +39,7 @@ public function setQueryParams(array $queryParams): ChargeInterface; /** * @param string $id - * @param array $data * @return array */ - public function confirmReceipt(string $id, array $data): array; + public function confirmReceipt(string $id): array; } From 9f50d3a218a24b5791aa26c6cc42368f7af36fd0 Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Fri, 27 Dec 2024 02:24:34 -0300 Subject: [PATCH 2/4] PHPAY-34: confirm receipt function on efi library --- src/Gateways/Efi/Resources/Charge/Charge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index 7139447..ecd5d81 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -195,7 +195,7 @@ public function getQrCodePix(string $id): array */ public function confirmReceipt(string $id): array { - return $this->put("v1/charge/{$id}/settle"); + return $this->put("v1/charge/{$id}/settle", []); } /** From 395dd42a1620702cb488cf391aaff26f0c13e1b8 Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Fri, 27 Dec 2024 02:36:10 -0300 Subject: [PATCH 3/4] PHPAY-34: feat: delete charge on efi library --- examples/efi/charges.php | 7 +++++++ src/Gateways/Efi/Resources/Charge/Charge.php | 6 +++--- .../Efi/Resources/Charge/Interface/ChargeInterface.php | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/efi/charges.php b/examples/efi/charges.php index 6fe04de..9182b5f 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -61,3 +61,10 @@ $phpay ->charge() ->confirmReceipt($chargeId); + +/** + * destroy charge + */ +$phpay + ->charge() + ->destroy($chargeId); diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index ecd5d81..9e87b75 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -147,11 +147,11 @@ public function update(string $id, array $data): array * destroy charge * * @param string $id - * @return bool + * @return array */ - public function destroy(string $id): bool + public function destroy(string $id): array { - return $this->delete("payments/{$id}"); + return $this->put("v1/charge/{$id}/cancel", []); } /** diff --git a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php index 09591d0..65bb657 100644 --- a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php @@ -42,4 +42,12 @@ public function setQueryParams(array $queryParams): ChargeInterface; * @return array */ public function confirmReceipt(string $id): array; + + /** + * delete charge by id + * + * @param string $id + * @return array + */ + public function destroy(string $id): array; } From 43535a5c4b1c0cc237756783a902b39d2673880c Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Fri, 27 Dec 2024 02:39:17 -0300 Subject: [PATCH 4/4] PHPAY-34: feat: cancel charge on efi library --- examples/efi/charges.php | 7 +++++++ src/Gateways/Efi/Resources/Charge/Charge.php | 11 +++++++++++ .../Resources/Charge/Interface/ChargeInterface.php | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/examples/efi/charges.php b/examples/efi/charges.php index 9182b5f..a0af6df 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -68,3 +68,10 @@ $phpay ->charge() ->destroy($chargeId); + +/** + * cancel charge + */ +$phpay + ->charge() + ->cancel($chargeId); diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index 9e87b75..e00af13 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -154,6 +154,17 @@ public function destroy(string $id): array return $this->put("v1/charge/{$id}/cancel", []); } + /** + * cancel charge + * + * @param string $id + * @return array + */ + public function cancel(string $id): array + { + return $this->put("v1/charge/{$id}/cancel", []); + } + /** * get status charge * diff --git a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php index 65bb657..23d3e10 100644 --- a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php @@ -50,4 +50,12 @@ public function confirmReceipt(string $id): array; * @return array */ public function destroy(string $id): array; + + /** + * cancel charge by id + * + * @param string $id + * @return array + */ + public function cancel(string $id): array; }