From 148e4f29a44f36f8f4ce4069e836ba4388cef75c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 17:14:58 +1100 Subject: [PATCH 01/11] 5.0.54 --- VERSION.txt | 2 +- config/ninja.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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), From e4ae78cd415e0f977525f3cd9f8aaf9994ce79de Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 20:11:29 +1100 Subject: [PATCH 02/11] Fix for auth.net autobill --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 1a67e58220fb..b08979bd9d17 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; From eb31c6b6d4f1316f12a36dab5a34a54ca6433b77 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 20:13:53 +1100 Subject: [PATCH 03/11] Fix for auth.net autobill --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index b08979bd9d17..759abbee7d4b 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -138,7 +138,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); From 31ff7fcc399dc5593e10fe6df47d661618bd413b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 20:17:27 +1100 Subject: [PATCH 04/11] Fix for auth.net autobill --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 759abbee7d4b..ba0dc246ab40 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -107,6 +107,8 @@ class AuthorizeCreditCard 'data' => $this->formatGatewayResponse($data, $vars), ]; + $payment = $this->storePayment($payment_hash, $data); + SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); return true; From c664428a8178c19f347973799af73c3090f0abd5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 20:31:28 +1100 Subject: [PATCH 05/11] Fix for auth.net autobill --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index ba0dc246ab40..759abbee7d4b 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -107,8 +107,6 @@ class AuthorizeCreditCard 'data' => $this->formatGatewayResponse($data, $vars), ]; - $payment = $this->storePayment($payment_hash, $data); - SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); return true; From 7b08355c7568aa0bdfb98c16b107b6d13e3e38f0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 20:38:11 +1100 Subject: [PATCH 06/11] Fix for auth.net autobill --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 1 + app/PaymentDrivers/AuthorizePaymentDriver.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 759abbee7d4b..cec6d058c995 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -95,6 +95,7 @@ class AuthorizeCreditCard /*Refactor and push to BaseDriver*/ if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { + $this->storePayment($payment_hash, $data); $vars = [ 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); From e1ae7688a8f8ec6b81d75666b7855d8248b0527f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 20:39:52 +1100 Subject: [PATCH 07/11] Fix for auth.net autobill --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index cec6d058c995..3c9ab3258a95 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -95,11 +95,11 @@ class AuthorizeCreditCard /*Refactor and push to BaseDriver*/ if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { - + $this->storePayment($payment_hash, $data); $vars = [ - 'hashed_ids' => $invoice->hashed_id, + 'invoices' => $payment_hash->invoices(), 'amount' => $amount, ]; From d127643405673b27688fc402a26ac88cb1004856 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 20:42:55 +1100 Subject: [PATCH 08/11] Fix for auth.net autobill --- app/PaymentDrivers/Authorize/AuthorizeCreditCard.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 3c9ab3258a95..8ef966b65339 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -96,6 +96,8 @@ 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 = [ From ed853efd19d44732890c9dd2b9abcf6804b72ab8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 20:53:18 +1100 Subject: [PATCH 09/11] Additional logging --- .../Authorize/AuthorizeCreditCard.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 8ef966b65339..669e797a77a4 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -97,7 +97,7 @@ class AuthorizeCreditCard if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { $response = $data['response']; - + $this->storePayment($payment_hash, $data); $vars = [ @@ -114,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; } } From ae3a7fa182b0fe99d1530489197ca29703faf410 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 21:02:12 +1100 Subject: [PATCH 10/11] Fixes for refunds / logging --- .../Authorize/RefundTransaction.php | 116 ++++++++++++------ 1 file changed, 80 insertions(+), 36 deletions(-) diff --git a/app/PaymentDrivers/Authorize/RefundTransaction.php b/app/PaymentDrivers/Authorize/RefundTransaction.php index cc472e18008c..e3b2b6334189 100644 --- a/app/PaymentDrivers/Authorize/RefundTransaction.php +++ b/app/PaymentDrivers/Authorize/RefundTransaction.php @@ -73,61 +73,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); + } } From 09c23e6654f4a400d2bb6f49f13cfa58de87ae45 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Jan 2021 21:03:50 +1100 Subject: [PATCH 11/11] Fixes for refunds / logging --- app/PaymentDrivers/Authorize/RefundTransaction.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/PaymentDrivers/Authorize/RefundTransaction.php b/app/PaymentDrivers/Authorize/RefundTransaction.php index e3b2b6334189..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;