phpstan errors fixing

This commit is contained in:
2025-03-10 16:53:53 +05:00
parent 11df811e0c
commit 3b83acf39c
8 changed files with 111 additions and 76 deletions

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Repos\Payment\Card;
use App\Models\Payment\OnlinePaymentHistory;
use App\Repos\Payment\OnlinePaymentRepo;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
trait HandlesCardOrderPayments
{
/**
* Check payment payment visa master
*
* @param Request $request
* @return array<string, bool|string>
*/
public static function checkCardOrderPayment(Request $request): array
{
// Find order from history
$paymentHistory = OnlinePaymentHistory::where('orderId', $request->orderId)->first();
// Find related resource
$resource = (new $paymentHistory->online_paymantable_type)->find(id: $paymentHistory->online_paymantable_id);
// If resource could not be found or does not exist, then inform it via logs
if (! $resource) {
static::logResourceNotFound($request, $paymentHistory);
return static::resourceNotFound();
}
$resource->load('branch');
$bank_branch = $resource->branch;
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [
'language' => 'ru',
'orderId' => $request->orderId,
'userName' => $bank_branch->billing_username,
'password' => $bank_branch->billing_password,
]);
$payment_status = $response['ErrorCode'] == '0';
$returnURL = $resource->panelUrl('index');
if ($payment_status) {
$resource->update([
'paid' => true,
]);
$paymentHistory->update([
'paymentStatus' => OnlinePaymentRepo::PAID,
]);
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
}
$paymentHistory->update([
'paymentStatus' => OnlinePaymentRepo::FAILED,
]);
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Repos\Payment;
use App\Models\Payment\OnlinePaymentHistory;
use App\Repos\Payment\Billing\HandlesBillingSyncing;
use App\Repos\Payment\Card\HandlesCardOrderPayments;
use App\Repos\Payment\Sber\HandlesSberPeyments;
use App\Repos\Payment\VisaMaster\HandlesVisaMasterPayments;
use Illuminate\Http\Request;
@@ -14,6 +15,7 @@ use Laravel\Nova\Makeable;
class OnlinePaymentRepo
{
use HandlesBillingSyncing;
use HandlesCardOrderPayments;
use HandlesSberPeyments;
use HandlesVisaMasterPayments;
use Makeable;