diff --git a/VERSION.txt b/VERSION.txt index 87620ce1dd94..764d664a1d8d 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.0.53 \ No newline at end of file +5.0.54 \ No newline at end of file diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 1a67e58220fb..669e797a77a4 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -87,7 +87,7 @@ class AuthorizeCreditCard return $this->handleResponse($data, $request); } - private function tokenBilling($cgt, $payment_hash) + public function tokenBilling($cgt, $payment_hash) { $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total; @@ -95,10 +95,13 @@ class AuthorizeCreditCard /*Refactor and push to BaseDriver*/ if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { + + $response = $data['response']; + $this->storePayment($payment_hash, $data); $vars = [ - 'hashed_ids' => $invoice->hashed_id, + 'invoices' => $payment_hash->invoices(), 'amount' => $amount, ]; @@ -111,6 +114,19 @@ class AuthorizeCreditCard return true; } else { + + $vars = [ + 'invoices' => $payment_hash->invoices(), + 'amount' => $amount, + ]; + + $logger_message = [ + 'server_response' => $response->getTransactionResponse()->getTransId(), + 'data' => $this->formatGatewayResponse($data, $vars), + ]; + + SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); + return false; } } @@ -138,7 +154,7 @@ class AuthorizeCreditCard $payment_record = []; $payment_record['amount'] = $amount; $payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER; - ; + $payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId(); $payment = $this->authorize->createPayment($payment_record); diff --git a/app/PaymentDrivers/Authorize/RefundTransaction.php b/app/PaymentDrivers/Authorize/RefundTransaction.php index cc472e18008c..7b07e1578f83 100644 --- a/app/PaymentDrivers/Authorize/RefundTransaction.php +++ b/app/PaymentDrivers/Authorize/RefundTransaction.php @@ -12,7 +12,9 @@ namespace App\PaymentDrivers\Authorize; +use App\Jobs\Util\SystemLogger; use App\Models\Payment; +use App\Models\SystemLog; use App\PaymentDrivers\AuthorizePaymentDriver; use net\authorize\api\contract\v1\CreateTransactionRequest; use net\authorize\api\contract\v1\CustomerProfilePaymentType; @@ -73,61 +75,105 @@ class RefundTransaction $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) { - return [ - 'transaction_reference' => $tresponse->getTransId(), - 'success' => true, - 'description' => $tresponse->getMessages()[0]->getDescription(), - 'code' => $tresponse->getMessages()[0]->getCode(), - 'transaction_response' => $tresponse->getResponseCode(), - ]; + + $data = [ + 'transaction_reference' => $tresponse->getTransId(), + 'success' => true, + 'description' => $tresponse->getMessages()[0]->getDescription(), + 'code' => $tresponse->getMessages()[0]->getCode(), + 'transaction_response' => $tresponse->getResponseCode(), + 'payment_id' => $payment->id, + 'amount' => $amount, + ]; + + SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); + + + return $data; + } else { + if ($tresponse->getErrors() != null) { - return [ - 'transaction_reference' => '', - 'transaction_response' => '', - 'success' => false, - 'description' => $tresponse->getErrors()[0]->getErrorText(), - 'code' => $tresponse->getErrors()[0]->getErrorCode(), - ]; + + $data = [ + 'transaction_reference' => '', + 'transaction_response' => '', + 'success' => false, + 'description' => $tresponse->getErrors()[0]->getErrorText(), + 'code' => $tresponse->getErrors()[0]->getErrorCode(), + 'payment_id' => $payment->id, + 'amount' => $amount, + ]; + + SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); + + return $data; } } } else { echo "Transaction Failed \n"; $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getErrors() != null) { - return [ - 'transaction_reference' => '', - 'transaction_response' => '', - 'success' => false, - 'description' => $tresponse->getErrors()[0]->getErrorText(), - 'code' => $tresponse->getErrors()[0]->getErrorCode(), - ]; + + $data = [ + 'transaction_reference' => '', + 'transaction_response' => '', + 'success' => false, + 'description' => $tresponse->getErrors()[0]->getErrorText(), + 'code' => $tresponse->getErrors()[0]->getErrorCode(), + 'payment_id' => $payment->id, + 'amount' => $amount, + ]; + + SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); + + return $data; + } else { - return [ - 'transaction_reference' => '', - 'transaction_response' => '', - 'success' => false, - 'description' => $response->getMessages()->getMessage()[0]->getText(), - 'code' => $response->getMessages()->getMessage()[0]->getCode(), - ]; + + $data = [ + 'transaction_reference' => '', + 'transaction_response' => '', + 'success' => false, + 'description' => $response->getMessages()->getMessage()[0]->getText(), + 'code' => $response->getMessages()->getMessage()[0]->getCode(), + 'payment_id' => $payment->id, + 'amount' => $amount, + ]; + + SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); + + return $data; } } } else { - return [ + + $data = [ 'transaction_reference' => '', 'transaction_response' => '', 'success' => false, 'description' => 'No response returned', 'code' => 'No response returned', + 'payment_id' => $payment->id, + 'amount' => $amount, ]; + + SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); + + return $data; } - return [ - 'transaction_reference' => '', - 'transaction_response' => '', - 'success' => false, - 'description' => 'No response returned', - 'code' => 'No response returned', - ]; + $data = [ + 'transaction_reference' => '', + 'transaction_response' => '', + 'success' => false, + 'description' => 'No response returned', + 'code' => 'No response returned', + 'payment_id' => $payment->id, + 'amount' => $amount, + ]; + + SystemLogger::dispatch($data, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); + } } diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index a802e5d59712..13efcf6d6d74 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -104,6 +104,8 @@ class AuthorizePaymentDriver extends BaseDriver public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) { + $this->setPaymentHash($payment_hash); + $this->setPaymentMethod($cgt->gateway_type_id); return $this->payment_method->tokenBilling($cgt, $payment_hash); diff --git a/config/ninja.php b/config/ninja.php index f31b91b1efe0..910753f54ea5 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -13,7 +13,7 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', ''), - 'app_version' => '5.0.53', + 'app_version' => '5.0.54', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false),