From bd02d7babd0f819eb2e410cf11255b7e0e03888f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 23:09:08 +1100 Subject: [PATCH] Fixes for payment failer mailer --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 7 +++++++ app/PaymentDrivers/CheckoutCom/CreditCard.php | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 669e797a77..76e52594cf 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -12,6 +12,7 @@ namespace App\PaymentDrivers\Authorize; +use App\Jobs\Mail\PaymentFailureMailer; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; @@ -125,6 +126,8 @@ class AuthorizeCreditCard 'data' => $this->formatGatewayResponse($data, $vars), ]; + PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransactionResponse()->getTransId(), $this->authorize->client->company, $amount); + SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); return false; @@ -205,6 +208,10 @@ class AuthorizeCreditCard private function processFailedResponse($data, $request) { + $response = $data['response']; + + PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransactionResponse()->getTransId(), $this->authorize->client->company, $data['amount_with_fee']); + throw new \Exception(ctrans('texts.error_title')); } diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php index a610b44763..d9855594d1 100644 --- a/app/PaymentDrivers/CheckoutCom/CreditCard.php +++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php @@ -13,6 +13,7 @@ namespace App\PaymentDrivers\CheckoutCom; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; +use App\Jobs\Mail\PaymentFailureMailer; use App\PaymentDrivers\CheckoutComPaymentDriver; use Checkout\Library\Exceptions\CheckoutHttpException; use Checkout\Models\Payments\IdSource; @@ -155,11 +156,14 @@ class CreditCard if ($response->status == 'Declined') { $this->checkout->unWindGatewayFees($this->checkout->payment_hash); + PaymentFailureMailer::dispatch($this->checkout->client, $response->response_summary, $this->checkout->client->company, $this->checkout->payment_hash->data->value); + + return $this->processUnsuccessfulPayment($response); } } catch (CheckoutHttpException $e) { - $this->checkout->unWindGatewayFees($this->checkout->payment_hash); + $this->checkout->unWindGatewayFees($this->checkout->payment_hash); return $this->checkout->processInternallyFailedPayment($this->checkout, $e); } }