diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 68c5ef318d59..0942bbf6bcc4 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -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, diff --git a/app/Models/SystemLog.php b/app/Models/SystemLog.php index 2158c68eef5a..16d0eebac678 100644 --- a/app/Models/SystemLog.php +++ b/app/Models/SystemLog.php @@ -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'; } diff --git a/app/PaymentDrivers/Forte/ACH.php b/app/PaymentDrivers/Forte/ACH.php index 4795f956d6d0..426f96717f71 100644 --- a/app/PaymentDrivers/Forte/ACH.php +++ b/app/PaymentDrivers/Forte/ACH.php @@ -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, diff --git a/app/PaymentDrivers/Forte/CreditCard.php b/app/PaymentDrivers/Forte/CreditCard.php index ad599f32f925..88d8007780d2 100644 --- a/app/PaymentDrivers/Forte/CreditCard.php +++ b/app/PaymentDrivers/Forte/CreditCard.php @@ -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, diff --git a/app/PaymentDrivers/FortePaymentDriver.php b/app/PaymentDrivers/FortePaymentDriver.php index e79df1dd96dd..b243908c2e00 100644 --- a/app/PaymentDrivers/FortePaymentDriver.php +++ b/app/PaymentDrivers/FortePaymentDriver.php @@ -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) {