1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Merge pull request #7711 from kishanmnpatel/system_logger_for_forte

System logger added for Forte.
This commit is contained in:
David Bomba 2022-08-09 08:15:25 +10:00 committed by GitHub
commit 3b136a7539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 2 deletions

View File

@ -73,6 +73,7 @@ class CompanyGateway extends BaseModel
// const TYPE_WEPAY = 309;
// const TYPE_PAYFAST = 310;
// const TYPE_PAYTRACE = 311;
// const TYPE_FORTE = 314;
public $gateway_consts = [
'38f2c48af60c7dd69e04248cbb24c36e' => 300,
@ -85,6 +86,7 @@ class CompanyGateway extends BaseModel
'8fdeed552015b3c7b44ed6c8ebd9e992' => 309,
'd6814fc83f45d2935e7777071e629ef9' => 310,
'bbd736b3254b0aabed6ad7fda1298c88' => 311,
'kivcvjexxvdiyqtj3mju5d6yhpeht2xs' => 314,
'65faab2ab6e3223dbe848b1686490baz' => 320,
'b9886f9257f0c6ee7c302f1c74475f6c' => 321,
'hxd6gwg3ekb9tb3v9lptgx1mqyg69zu9' => 322,

View File

@ -100,6 +100,8 @@ class SystemLog extends Model
const TYPE_MOLLIE = 312;
const TYPE_EWAY = 313;
const TYPE_FORTE = 314;
const TYPE_SQUARE = 320;
@ -250,7 +252,9 @@ class SystemLog extends Model
case self::TYPE_WEPAY:
return 'WePay';
case self::TYPE_PAYFAST:
return 'Payfast';
return "Payfast";
case self::TYPE_FORTE:
return "Forte";
default:
return 'undefined';
}

View File

@ -20,6 +20,8 @@ use App\Http\Requests\Request;
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Validator;
use App\PaymentDrivers\FortePaymentDriver;
use App\Jobs\Util\SystemLogger;
use App\Models\SystemLog;
class ACH
{
@ -129,13 +131,36 @@ class ACH
} catch (\Throwable $th) {
throw $th;
}
$message = [
'server_message' => $response->response->response_desc,
'server_response' => $response,
'data' => $payment_hash->data,
];
if ($httpcode>299) {
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_FORTE,
$this->forte->client,
$this->forte->client->company,
);
$error = Validator::make([], []);
$error->getMessageBag()->add('gateway_error', $response->response->response_desc);
return redirect('client/invoices')->withErrors($error);
}
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_FORTE,
$this->forte->client,
$this->forte->client->company,
);
$data = [
'payment_method' => $request->payment_method_id,
'payment_type' => PaymentType::ACH,

View File

@ -21,6 +21,8 @@ use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Validator;
use App\PaymentDrivers\FortePaymentDriver;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Jobs\Util\SystemLogger;
use App\Models\SystemLog;
class CreditCard
{
@ -141,12 +143,36 @@ class CreditCard
} catch (\Throwable $th) {
throw $th;
}
$message = [
'server_message' => $response->response->response_desc,
'server_response' => $response,
'data' => $payment_hash->data,
];
if ($httpcode>299) {
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_FORTE,
$this->forte->client,
$this->forte->client->company,
);
$error = Validator::make([], []);
$error->getMessageBag()->add('gateway_error', $response->response->response_desc);
return redirect('client/invoices')->withErrors($error);
}
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_FORTE,
$this->forte->client,
$this->forte->client->company,
);
$data = [
'payment_method' => $request->payment_method_id,
'payment_type' => PaymentType::parseCardType(strtolower($request->card_brand)) ?: PaymentType::CREDIT_CARD_OTHER,

View File

@ -49,7 +49,7 @@ class FortePaymentDriver extends BaseDriver
return $types;
}
const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model
const SYSTEM_LOG_TYPE = SystemLog::TYPE_FORTE; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model
public function setPaymentMethod($payment_method_id)
{