Add successful payments for square to system logs

This commit is contained in:
David Bomba 2023-08-19 10:03:56 +10:00
parent 2b6c92a711
commit c0acc7a15e
2 changed files with 31 additions and 12 deletions

View File

@ -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;
}

View File

@ -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)]);
}