From 1e0c70b4eeb9de61f39b9377369403446baf63c4 Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Sat, 28 Dec 2024 11:22:17 -0300 Subject: [PATCH 1/5] PHPAY-33: refactor: remove destroy function 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 deletions(-) diff --git a/examples/efi/charges.php b/examples/efi/charges.php index a0af6df..02104cb 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -62,13 +62,6 @@ ->charge() ->confirmReceipt($chargeId); -/** - * destroy charge - */ -$phpay - ->charge() - ->destroy($chargeId); - /** * cancel charge */ diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index e00af13..8614e57 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -143,17 +143,6 @@ public function update(string $id, array $data): array return $this->put("payments/{$id}", $data); } - /** - * destroy charge - * - * @param string $id - * @return array - */ - public function destroy(string $id): array - { - return $this->put("v1/charge/{$id}/cancel", []); - } - /** * cancel charge * diff --git a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php index 23d3e10..05b6d65 100644 --- a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php @@ -43,14 +43,6 @@ public function setQueryParams(array $queryParams): ChargeInterface; */ public function confirmReceipt(string $id): array; - /** - * delete charge by id - * - * @param string $id - * @return array - */ - public function destroy(string $id): array; - /** * cancel charge by id * From 68786e446891e8d9120150d0116e13b530992307 Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Sat, 28 Dec 2024 11:35:58 -0300 Subject: [PATCH 2/5] PHPAY-33: feat: add function to update due date on efi library --- examples/efi/charges.php | 9 +++++++++ src/Gateways/Efi/Resources/Charge/Charge.php | 12 ++++++++++++ .../Resources/Charge/Interface/ChargeInterface.php | 7 +++++++ 3 files changed, 28 insertions(+) diff --git a/examples/efi/charges.php b/examples/efi/charges.php index 02104cb..bdddb10 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -68,3 +68,12 @@ $phpay ->charge() ->cancel($chargeId); + +/** + * update due date + */ +$c = $phpay + ->charge() + ->updateDueDate($chargeId, [ + 'expire_at' => '2024-12-30', + ]); diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index 8614e57..73a80ce 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -154,6 +154,18 @@ public function cancel(string $id): array return $this->put("v1/charge/{$id}/cancel", []); } + /** + * update due date + * + * @param string $id + * @param array $data + * @return array + */ + public function updateDueDate(string $id, array $data): array + { + return $this->put("v1/charge/{$id}/billet", $data); + } + /** * get status charge * diff --git a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php index 05b6d65..90ffd3e 100644 --- a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php @@ -50,4 +50,11 @@ public function confirmReceipt(string $id): array; * @return array */ public function cancel(string $id): array; + + /** + * @param string $id + * @param array $data + * @return array + */ + public function updateDueDate(string $id, array $data): array; } From 44024e6f56079bd822317fe6289e137b5c1bc83b Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Sat, 28 Dec 2024 11:41:08 -0300 Subject: [PATCH 3/5] PHPAY-33: refactor: remove unnecessary code on efi library --- src/Gateways/Efi/Resources/Charge/Charge.php | 22 -------------------- 1 file changed, 22 deletions(-) diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index 73a80ce..057d48c 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -177,28 +177,6 @@ public function getStatus(string $id): array return $this->get("payments/{$id}/status"); } - /** - * get digitable line - * - * @param string $id - * @return mixed - */ - public function getDigitableLine(string $id): mixed - { - return $this->get("payments/{$id}/identificationField")['identificationField']; - } - - /** - * get qrcode pix - * - * @param string $id - * @return array - */ - public function getQrCodePix(string $id): array - { - return $this->get("payments/{$id}/pixQrCode"); - } - /** * confirm receipt * From 7e15889917f222008e9c61d47764f97cb006adff Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Sat, 28 Dec 2024 11:53:17 -0300 Subject: [PATCH 4/5] PHPAY-33: feat: update metadata on efi library --- examples/efi/charges.php | 13 ++++++++++++- src/Gateways/Efi/Resources/Charge/Charge.php | 7 ++++--- .../Resources/Charge/Interface/ChargeInterface.php | 10 ++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/examples/efi/charges.php b/examples/efi/charges.php index bdddb10..a621cd5 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -72,8 +72,19 @@ /** * update due date */ -$c = $phpay +$phpay ->charge() ->updateDueDate($chargeId, [ 'expire_at' => '2024-12-30', ]); + +/** + * update billet metadata + * notification_url and custom_id + */ +$phpay + ->charge() + ->updateMetadata($chargeId, [ + 'notification_url' => $notificationUrl, + 'custom_id' => $customId, + ]); diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index 057d48c..65e9827 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -132,15 +132,16 @@ public function create(): array } /** - * update charge + * update billet metadata + * notification_url and custom_id * * @param string $id * @param array $data * @return array */ - public function update(string $id, array $data): array + public function updateMetadata(string $id, array $data): array { - return $this->put("payments/{$id}", $data); + return $this->put("v1/charge/{$id}/metadata", $data); } /** diff --git a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php index 90ffd3e..4c6cffe 100644 --- a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php @@ -57,4 +57,14 @@ public function cancel(string $id): array; * @return array */ public function updateDueDate(string $id, array $data): array; + + /** + * update billet metadata + * notification_url and custom_id + * + * @param string $id + * @param array $data + * @return array + */ + public function updateMetadata(string $id, array $data): array; } From fdfa0a391513e1b95b20f137b4a7d5a97c059a2b Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Sat, 28 Dec 2024 12:17:32 -0300 Subject: [PATCH 5/5] PHPAY-33: refactor: update due date function on efi library --- examples/efi/charges.php | 4 +--- src/Gateways/Efi/Resources/Charge/Charge.php | 8 +++++--- .../Efi/Resources/Charge/Interface/ChargeInterface.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/efi/charges.php b/examples/efi/charges.php index a621cd5..14f5ad4 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -74,9 +74,7 @@ */ $phpay ->charge() - ->updateDueDate($chargeId, [ - 'expire_at' => '2024-12-30', - ]); + ->updateDueDate($chargeId, $dueDate); /** * update billet metadata diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index 65e9827..b63eaf0 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -159,12 +159,14 @@ public function cancel(string $id): array * update due date * * @param string $id - * @param array $data + * @param string $dueDate * @return array */ - public function updateDueDate(string $id, array $data): array + public function updateDueDate(string $id, string $dueDate): array { - return $this->put("v1/charge/{$id}/billet", $data); + return $this->put("v1/charge/{$id}/billet", [ + 'expire_at' => $dueDate, + ]); } /** diff --git a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php index 4c6cffe..4dc6a4b 100644 --- a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php @@ -53,10 +53,10 @@ public function cancel(string $id): array; /** * @param string $id - * @param array $data + * @param string $dueDate * @return array */ - public function updateDueDate(string $id, array $data): array; + public function updateDueDate(string $id, string $dueDate): array; /** * update billet metadata