diff --git a/app/Models/SystemLog.php b/app/Models/SystemLog.php index e402d09f468e..781e2b1a7a48 100644 --- a/app/Models/SystemLog.php +++ b/app/Models/SystemLog.php @@ -195,7 +195,10 @@ class SystemLog extends Model */ public function scopeCompany($query) { - $query->where('company_id', auth()->user()->companyId()); + /** @var \App\Models\User $user */ + $user = auth()->user(); + + $query->where('company_id', $user->companyId()); return $query; } diff --git a/app/PaymentDrivers/Square/CreditCard.php b/app/PaymentDrivers/Square/CreditCard.php index f3589b98333f..9d61f652ffa1 100644 --- a/app/PaymentDrivers/Square/CreditCard.php +++ b/app/PaymentDrivers/Square/CreditCard.php @@ -12,20 +12,22 @@ namespace App\PaymentDrivers\Square; -use App\Exceptions\PaymentFailed; -use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -use App\Models\ClientGatewayToken; -use App\Models\GatewayType; use App\Models\Payment; -use App\Models\PaymentType; -use App\PaymentDrivers\Common\MethodInterface; -use App\PaymentDrivers\SquarePaymentDriver; -use App\Utils\Traits\MakesHash; -use Illuminate\Http\RedirectResponse; -use Illuminate\Http\Request; -use Illuminate\Support\Str; +use App\Models\SystemLog; use Illuminate\View\View; +use App\Models\GatewayType; +use App\Models\PaymentType; +use Illuminate\Support\Str; +use Illuminate\Http\Request; use Square\Http\ApiResponse; +use App\Jobs\Util\SystemLogger; +use App\Utils\Traits\MakesHash; +use App\Exceptions\PaymentFailed; +use App\Models\ClientGatewayToken; +use Illuminate\Http\RedirectResponse; +use App\PaymentDrivers\SquarePaymentDriver; +use App\PaymentDrivers\Common\MethodInterface; +use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; class CreditCard implements MethodInterface { @@ -152,6 +154,20 @@ class CreditCard implements MethodInterface $payment = $this->square_driver->createPayment($payment_record, Payment::STATUS_COMPLETED); + $message = [ + 'server_response' => $body, + 'data' => $this->square_driver->payment_hash->data, + ]; + + SystemLogger::dispatch( + $message, + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_SQUARE, + $this->square_driver->client, + $this->square_driver->client->company, + ); + return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); }