@@ -18,15 +18,13 @@ trait ChargeTrait
1818 */
1919 public function initiateCardCharge (array $ formParams ): array
2020 {
21- $ endpoint = sprintf ('%s%s ' , $ this ->baseUri , FlutterwaveConstant::CHARGE_ENDPOINT );
22-
2321 $ queryParams = [
2422 'type ' => FlutterwaveConstant::CARD_PAYMENT_CHARGE_TYPE ,
2523 ];
2624
2725 return $ this ->makeRequest (
2826 method: 'POST ' ,
29- requestUrl: $ endpoint ,
27+ requestUrl: FlutterwaveConstant:: CHARGE_ENDPOINT ,
3028 formParams: $ this ->encryptPayload ($ formParams ),
3129 isJsonRequest: true ,
3230 queryParams: $ queryParams
@@ -255,15 +253,13 @@ public function chargeUssd(array $formParams): array
255253 */
256254 private function chargePayment (string $ paymentMethod , array $ formParams ): array
257255 {
258- $ endpoint = sprintf ('%s%s ' , $ this ->baseUri , FlutterwaveConstant::CHARGE_ENDPOINT );
259-
260256 $ queryParams = [
261257 'type ' => $ paymentMethod ,
262258 ];
263259
264260 return $ this ->makeRequest (
265261 method: 'POST ' ,
266- requestUrl: $ endpoint ,
262+ requestUrl: FlutterwaveConstant:: CHARGE_ENDPOINT ,
267263 formParams: $ formParams ,
268264 isJsonRequest: true ,
269265 queryParams: $ queryParams
@@ -300,11 +296,9 @@ private function encryptPayload(array $payload): string
300296 */
301297 public function validateCharge (array $ formParams ): array
302298 {
303- $ endpoint = sprintf ('%s%s ' , $ this ->baseUri , FlutterwaveConstant::VALIDATE_CHARGE_ENDPOINT );
304-
305299 return $ this ->makeRequest (
306300 method: 'POST ' ,
307- requestUrl: $ endpoint ,
301+ requestUrl: FlutterwaveConstant:: VALIDATE_CHARGE_ENDPOINT ,
308302 formParams: $ formParams ,
309303 isJsonRequest: true
310304 );
@@ -320,11 +314,9 @@ public function validateCharge(array $formParams): array
320314 */
321315 public function captureCharge (string $ flwRef , array $ formParams ): array
322316 {
323- $ endpoint = sprintf ('%s%s%s/capture ' , $ this ->baseUri , FlutterwaveConstant::CHARGE_ENDPOINT , $ flwRef );
324-
325317 return $ this ->makeRequest (
326318 method: 'POST ' ,
327- requestUrl: $ endpoint ,
319+ requestUrl: FlutterwaveConstant:: CHARGE_ENDPOINT . $ flwRef . ' /capture ' ,
328320 formParams: $ formParams ,
329321 isJsonRequest: true
330322 );
@@ -339,11 +331,9 @@ public function captureCharge(string $flwRef, array $formParams): array
339331 */
340332 public function voidCharge (string $ flwRef ): array
341333 {
342- $ endpoint = sprintf ('%s%s%s/void ' , $ this ->baseUri , FlutterwaveConstant::CHARGE_ENDPOINT , $ flwRef );
343-
344334 return $ this ->makeRequest (
345335 method: 'POST ' ,
346- requestUrl: $ endpoint ,
336+ requestUrl: FlutterwaveConstant:: CHARGE_ENDPOINT . $ flwRef . ' /void ' ,
347337 isJsonRequest: true
348338 );
349339 }
@@ -358,11 +348,9 @@ public function voidCharge(string $flwRef): array
358348 */
359349 public function createRefund (string $ flwRef , array $ formParams ): array
360350 {
361- $ endpoint = sprintf ('%s%s%s/refund ' , $ this ->baseUri , FlutterwaveConstant::CHARGE_ENDPOINT , $ flwRef );
362-
363351 return $ this ->makeRequest (
364352 method: 'POST ' ,
365- requestUrl: $ endpoint ,
353+ requestUrl: FlutterwaveConstant:: CHARGE_ENDPOINT . $ flwRef . ' /refund ' ,
366354 formParams: $ formParams ,
367355 isJsonRequest: true
368356 );
@@ -378,11 +366,9 @@ public function createRefund(string $flwRef, array $formParams): array
378366 */
379367 public function capturePaypalCharge (string $ flwRef , array $ formParams ): array
380368 {
381- $ endpoint = sprintf ('%s%s%s/paypal-capture ' , $ this ->baseUri , FlutterwaveConstant::CHARGE_ENDPOINT , $ flwRef );
382-
383369 return $ this ->makeRequest (
384370 method: 'POST ' ,
385- requestUrl: $ endpoint ,
371+ requestUrl: FlutterwaveConstant:: CHARGE_ENDPOINT . $ flwRef . ' /paypal-capture ' ,
386372 formParams: $ formParams ,
387373 isJsonRequest: true
388374 );
@@ -397,11 +383,9 @@ public function capturePaypalCharge(string $flwRef, array $formParams): array
397383 */
398384 public function voidPaypalCharge (string $ flwRef ): array
399385 {
400- $ endpoint = sprintf ('%s%s%s/void ' , $ this ->baseUri , FlutterwaveConstant::CHARGE_ENDPOINT , $ flwRef );
401-
402386 return $ this ->makeRequest (
403387 method: 'POST ' ,
404- requestUrl: $ endpoint ,
388+ requestUrl: FlutterwaveConstant:: CHARGE_ENDPOINT . $ flwRef . ' /void ' ,
405389 isJsonRequest: true
406390 );
407391 }
0 commit comments