From 1d99f336afd185da9142590f35f4782a89c99055 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 17 Aug 2021 18:58:27 +1000 Subject: [PATCH] Fixes for Authorize --- .../Authorize/AuthorizeCreditCard.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index d9ab5f01ce7f..cac57328bb92 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -204,9 +204,18 @@ class AuthorizeCreditCard $response = $data['response']; $amount = array_key_exists('amount_with_fee', $data) ? $data['amount_with_fee'] : 0; - PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransId(), $this->authorize->client->company, $data['amount_with_fee']); + $code = "Error"; + $description = "There was an error processing the payment"; + + if ($response->getErrors() != null) { + $code = $response->getErrors()[0]->getErrorCode(); + $description = $response->getErrors()[0]->getErrorText(); + } + + PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransId(), $this->authorize->client->company, $amount); + + throw new PaymentFailed($description, $code); - throw new \Exception(ctrans('texts.error_title')); } private function formatGatewayResponse($data, $vars)