From b63972e2500a9aeb3db6b1dffc65504da5f93af7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 2 Dec 2020 11:56:29 +1100 Subject: [PATCH] fixes for payment refunds --- app/Services/Payment/RefundPayment.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index a1acb5adb82f..c42ba39ae35d 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -73,16 +73,18 @@ class RefundPayment { if ($this->refund_data['gateway_refund'] !== false && $this->total_refund > 0) { if ($this->payment->company_gateway) { + $response = $this->payment->company_gateway->driver($this->payment->client)->refund($this->payment, $this->total_refund); - - if ($response['success'] == false) { - throw new PaymentRefundFailed(); - } - $this->payment->refunded += $this->total_refund; $this->createActivity($this->payment); + + if ($response['success'] == false) { + $this->payment->save(); + throw new PaymentRefundFailed(); + } + } } else { $this->payment->refunded += $this->total_refund;