From 34e8a3bface67dfaedbfe6c5c095cea7fb5febbb Mon Sep 17 00:00:00 2001 From: seunex17 Date: Sat, 11 Nov 2023 16:37:56 +0100 Subject: [PATCH] Refactor the refund codes --- README.md | 6 +++--- src/Flutterwave/Transaction.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7b62dd0..ad4e154 100644 --- a/README.md +++ b/README.md @@ -182,13 +182,13 @@ In the redrected page (method) add this below code to verify you payment. ### Refund a transaction Whenever your customer pay you, it is advisable to store the transaction information return by flutterwave. -To create a refund we needed the amount paid and flutterwave references (flw_ref). +To create a refund we needed the amount paid and transaction id (transaction_id). ```php - $flutterwaveRef = "FLW-MOCK-a728cc7f95ecff4bc92388a2f1f69cc3"; + $transactionId = "4717164"; $amount = 500; - Transaction::refund($flutterwaveRef, $amount); + Transaction::refund($transactionId, $amount); ``` diff --git a/src/Flutterwave/Transaction.php b/src/Flutterwave/Transaction.php index 247c84e..bc3b031 100644 --- a/src/Flutterwave/Transaction.php +++ b/src/Flutterwave/Transaction.php @@ -23,12 +23,12 @@ class Transaction /** * @throws \Exception */ - public static function refund(string $references, int $amount) + public static function refund(string $transactionId, int $amount) { $flutterwave = new Flutterwave(); $client = Services::curlrequest(); - $request = $client->request('POST', "{$flutterwave->baseUrl}/charges/{$references}/refund", [ + $request = $client->request('POST', "{$flutterwave->baseUrl}/transactions/{$transactionId}/refund", [ 'headers' => [ 'Authorization' => 'Bearer ' . env('FLUTTERWAVE_SECRET_KEY'), ], @@ -41,7 +41,7 @@ public static function refund(string $references, int $amount) $response = json_decode($request->getBody()); if ($request->getStatusCode() !== 200) { - throw new Exception($response->message); + throw new Exception($response->data); } return $response;