Merge pull request #4765 from turbo124/v5-develop

Fixes for auth.net auto billing
This commit is contained in:
David Bomba 2021-01-26 21:47:09 +11:00 committed by GitHub
commit 88bac69e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 105 additions and 41 deletions

View File

@ -1 +1 @@
5.0.53 5.0.54

View File

@ -87,7 +87,7 @@ class AuthorizeCreditCard
return $this->handleResponse($data, $request); 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; $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
@ -95,10 +95,13 @@ class AuthorizeCreditCard
/*Refactor and push to BaseDriver*/ /*Refactor and push to BaseDriver*/
if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') {
$response = $data['response'];
$this->storePayment($payment_hash, $data); $this->storePayment($payment_hash, $data);
$vars = [ $vars = [
'hashed_ids' => $invoice->hashed_id, 'invoices' => $payment_hash->invoices(),
'amount' => $amount, 'amount' => $amount,
]; ];
@ -111,6 +114,19 @@ class AuthorizeCreditCard
return true; return true;
} else { } 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; return false;
} }
} }
@ -138,7 +154,7 @@ class AuthorizeCreditCard
$payment_record = []; $payment_record = [];
$payment_record['amount'] = $amount; $payment_record['amount'] = $amount;
$payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER; $payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
;
$payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId(); $payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId();
$payment = $this->authorize->createPayment($payment_record); $payment = $this->authorize->createPayment($payment_record);

View File

@ -12,7 +12,9 @@
namespace App\PaymentDrivers\Authorize; namespace App\PaymentDrivers\Authorize;
use App\Jobs\Util\SystemLogger;
use App\Models\Payment; use App\Models\Payment;
use App\Models\SystemLog;
use App\PaymentDrivers\AuthorizePaymentDriver; use App\PaymentDrivers\AuthorizePaymentDriver;
use net\authorize\api\contract\v1\CreateTransactionRequest; use net\authorize\api\contract\v1\CreateTransactionRequest;
use net\authorize\api\contract\v1\CustomerProfilePaymentType; use net\authorize\api\contract\v1\CustomerProfilePaymentType;
@ -73,61 +75,105 @@ class RefundTransaction
$tresponse = $response->getTransactionResponse(); $tresponse = $response->getTransactionResponse();
if ($tresponse != null && $tresponse->getMessages() != null) { if ($tresponse != null && $tresponse->getMessages() != null) {
return [
$data = [
'transaction_reference' => $tresponse->getTransId(), 'transaction_reference' => $tresponse->getTransId(),
'success' => true, 'success' => true,
'description' => $tresponse->getMessages()[0]->getDescription(), 'description' => $tresponse->getMessages()[0]->getDescription(),
'code' => $tresponse->getMessages()[0]->getCode(), 'code' => $tresponse->getMessages()[0]->getCode(),
'transaction_response' => $tresponse->getResponseCode(), '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 { } else {
if ($tresponse->getErrors() != null) { if ($tresponse->getErrors() != null) {
return [
$data = [
'transaction_reference' => '', 'transaction_reference' => '',
'transaction_response' => '', 'transaction_response' => '',
'success' => false, 'success' => false,
'description' => $tresponse->getErrors()[0]->getErrorText(), 'description' => $tresponse->getErrors()[0]->getErrorText(),
'code' => $tresponse->getErrors()[0]->getErrorCode(), '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 { } else {
echo "Transaction Failed \n"; echo "Transaction Failed \n";
$tresponse = $response->getTransactionResponse(); $tresponse = $response->getTransactionResponse();
if ($tresponse != null && $tresponse->getErrors() != null) { if ($tresponse != null && $tresponse->getErrors() != null) {
return [
$data = [
'transaction_reference' => '', 'transaction_reference' => '',
'transaction_response' => '', 'transaction_response' => '',
'success' => false, 'success' => false,
'description' => $tresponse->getErrors()[0]->getErrorText(), 'description' => $tresponse->getErrors()[0]->getErrorText(),
'code' => $tresponse->getErrors()[0]->getErrorCode(), '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 { } else {
return [
$data = [
'transaction_reference' => '', 'transaction_reference' => '',
'transaction_response' => '', 'transaction_response' => '',
'success' => false, 'success' => false,
'description' => $response->getMessages()->getMessage()[0]->getText(), 'description' => $response->getMessages()->getMessage()[0]->getText(),
'code' => $response->getMessages()->getMessage()[0]->getCode(), '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 { } else {
return [
$data = [
'transaction_reference' => '', 'transaction_reference' => '',
'transaction_response' => '', 'transaction_response' => '',
'success' => false, 'success' => false,
'description' => 'No response returned', 'description' => 'No response returned',
'code' => '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 [ $data = [
'transaction_reference' => '', 'transaction_reference' => '',
'transaction_response' => '', 'transaction_response' => '',
'success' => false, 'success' => false,
'description' => 'No response returned', 'description' => 'No response returned',
'code' => '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);
} }
} }

View File

@ -104,6 +104,8 @@ class AuthorizePaymentDriver extends BaseDriver
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{ {
$this->setPaymentHash($payment_hash);
$this->setPaymentMethod($cgt->gateway_type_id); $this->setPaymentMethod($cgt->gateway_type_id);
return $this->payment_method->tokenBilling($cgt, $payment_hash); return $this->payment_method->tokenBilling($cgt, $payment_hash);

View File

@ -13,7 +13,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true), 'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', ''), 'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.0.53', 'app_version' => '5.0.54',
'minimum_client_version' => '5.0.16', 'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1', 'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false), 'api_secret' => env('API_SECRET', false),