phpstan errors fixing
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class FetchLoanHistoryController extends Controller
|
class FetchLoanHistoryController extends Controller
|
||||||
@@ -10,7 +11,7 @@ class FetchLoanHistoryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Fetch loan history
|
* Fetch loan history
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'passport_serie' => ['required', 'string', 'max:255'],
|
'passport_serie' => ['required', 'string', 'max:255'],
|
||||||
@@ -50,10 +51,13 @@ class FetchLoanHistoryController extends Controller
|
|||||||
|
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
|
||||||
return $response;
|
return response()->json($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sampleRequest()
|
/**
|
||||||
|
* Sample request for dev mode
|
||||||
|
*/
|
||||||
|
public function sampleRequest(): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'recipient' => [
|
'recipient' => [
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class RegisterController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Get a validator for an incoming registration request.
|
* Get a validator for an incoming registration request.
|
||||||
*
|
*
|
||||||
|
* @param array<string, int|string> $data
|
||||||
* @return \Illuminate\Contracts\Validation\Validator
|
* @return \Illuminate\Contracts\Validation\Validator
|
||||||
*/
|
*/
|
||||||
protected function validator(array $data)
|
protected function validator(array $data)
|
||||||
@@ -78,6 +79,7 @@ class RegisterController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Create a new user instance after a valid registration.
|
* Create a new user instance after a valid registration.
|
||||||
*
|
*
|
||||||
|
* @param array<string, int|string> $data
|
||||||
* @return \App\Models\User
|
* @return \App\Models\User
|
||||||
*/
|
*/
|
||||||
protected function create(array $data)
|
protected function create(array $data)
|
||||||
@@ -96,7 +98,7 @@ class RegisterController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Sms verification
|
* Sms verification
|
||||||
*/
|
*/
|
||||||
public function smsVerification()
|
public function smsVerification(): View
|
||||||
{
|
{
|
||||||
return view('vendor.nova.pages.sms-verification');
|
return view('vendor.nova.pages.sms-verification');
|
||||||
}
|
}
|
||||||
@@ -104,7 +106,7 @@ class RegisterController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Verify sms code
|
* Verify sms code
|
||||||
*/
|
*/
|
||||||
public function verifySmsCode(Request $request)
|
public function verifySmsCode(Request $request): \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'code' => ['required', 'integer', new PhoneCodeVerification(auth()->user()->phone)],
|
'code' => ['required', 'integer', new PhoneCodeVerification(auth()->user()->phone)],
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ResetPasswordController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Store new password
|
* Store new password
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'username' => ['required', 'string', 'max:250', 'exists:users,username'],
|
'username' => ['required', 'string', 'max:250', 'exists:users,username'],
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ class FetchCardHistoryController extends Controller
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'passport_serie' => ['required', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
'passport_serie' => ['required', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
||||||
@@ -60,10 +61,13 @@ class FetchCardHistoryController extends Controller
|
|||||||
|
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
|
||||||
return $response;
|
return response()->json($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sampleResponse()
|
/**
|
||||||
|
* Sample request
|
||||||
|
*/
|
||||||
|
public function sampleResponse(): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'idSeria' => 'I-AS',
|
'idSeria' => 'I-AS',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ class FetchLoanRemainingController extends Controller
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'passport_serie' => ['required', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
'passport_serie' => ['required', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
||||||
@@ -57,10 +58,13 @@ class FetchLoanRemainingController extends Controller
|
|||||||
|
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
|
||||||
return $response;
|
return response()->json($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sampleResponse()
|
/**
|
||||||
|
* Sample request
|
||||||
|
*/
|
||||||
|
public function sampleResponse(): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'idSeria' => 'I-AS',
|
'idSeria' => 'I-AS',
|
||||||
|
|||||||
@@ -3,81 +3,35 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Requests\OnlinePaymentStoreRequest;
|
use App\Http\Requests\OnlinePaymentStoreRequest;
|
||||||
use App\Models\Payment\OnlinePaymentHistory;
|
|
||||||
use App\Repos\Payment\OnlinePaymentRepo;
|
use App\Repos\Payment\OnlinePaymentRepo;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class OnlinePaymentController extends Controller
|
class OnlinePaymentController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Online payment
|
* Card online payment
|
||||||
*/
|
*/
|
||||||
public function store(OnlinePaymentStoreRequest $request)
|
public function store(OnlinePaymentStoreRequest $request): View
|
||||||
{
|
{
|
||||||
// Find order from history
|
$data = OnlinePaymentRepo::checkCardOrderPayment($request);
|
||||||
$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) {
|
|
||||||
Log::channel('halkbank_payment_check_error')
|
|
||||||
->error('Related resource not found', [
|
|
||||||
'orderId' => $request->orderId,
|
|
||||||
'onlinePaymentHistory_id' => $paymentHistory->id,
|
|
||||||
'related_resource' => [
|
|
||||||
'type' => $paymentHistory->online_paymantable_type,
|
|
||||||
'id' => $paymentHistory->online_paymantable_id,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$resource->load('branch');
|
|
||||||
|
|
||||||
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [
|
|
||||||
'language' => 'ru',
|
|
||||||
'orderId' => $request->orderId,
|
|
||||||
'userName' => $resource->branch->billing_username,
|
|
||||||
'password' => $resource->branch->billing_password,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$payment_status = $response['ErrorCode'] == '0';
|
|
||||||
|
|
||||||
if ($payment_status) {
|
|
||||||
$resource->update([
|
|
||||||
'paid' => true,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$paymentHistory->update([
|
|
||||||
'paymentStatus' => OnlinePaymentRepo::PAID,
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
$paymentHistory->update([
|
|
||||||
'paymentStatus' => OnlinePaymentRepo::FAILED,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return view(OnlinePaymentRepo::statusView(), [
|
|
||||||
'success' => $payment_status,
|
|
||||||
'title' => $payment_status ? __('Payment is successful') : __('Payment has failed'),
|
|
||||||
'pnr' => $paymentHistory->orderNumber,
|
|
||||||
'branch_name' => $resource->branch->name,
|
|
||||||
'price_amount' => $paymentHistory->amount,
|
|
||||||
'return_url' => $resource->panelUrl('index'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function visaMaster(OnlinePaymentStoreRequest $request)
|
|
||||||
{
|
|
||||||
$data = OnlinePaymentRepo::checkPaymentVisaMaster($request);
|
|
||||||
OnlinePaymentRepo::syncWithBilling();
|
|
||||||
|
|
||||||
return view(OnlinePaymentRepo::statusView(), $data);
|
return view(OnlinePaymentRepo::statusView(), $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sber(OnlinePaymentStoreRequest $request)
|
/**
|
||||||
|
* Visa-master online payment
|
||||||
|
*/
|
||||||
|
public function visaMaster(OnlinePaymentStoreRequest $request): View
|
||||||
|
{
|
||||||
|
$data = OnlinePaymentRepo::checkPaymentVisaMaster($request);
|
||||||
|
|
||||||
|
return view(OnlinePaymentRepo::statusView(), $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sber online payment
|
||||||
|
*/
|
||||||
|
public function sber(OnlinePaymentStoreRequest $request): View
|
||||||
{
|
{
|
||||||
$data = OnlinePaymentRepo::checkPaymentSber($request);
|
$data = OnlinePaymentRepo::checkPaymentSber($request);
|
||||||
|
|
||||||
|
|||||||
65
app/Repos/Payment/Card/HandlesCardOrderPayments.php
Normal file
65
app/Repos/Payment/Card/HandlesCardOrderPayments.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\Repos\Payment;
|
|||||||
|
|
||||||
use App\Models\Payment\OnlinePaymentHistory;
|
use App\Models\Payment\OnlinePaymentHistory;
|
||||||
use App\Repos\Payment\Billing\HandlesBillingSyncing;
|
use App\Repos\Payment\Billing\HandlesBillingSyncing;
|
||||||
|
use App\Repos\Payment\Card\HandlesCardOrderPayments;
|
||||||
use App\Repos\Payment\Sber\HandlesSberPeyments;
|
use App\Repos\Payment\Sber\HandlesSberPeyments;
|
||||||
use App\Repos\Payment\VisaMaster\HandlesVisaMasterPayments;
|
use App\Repos\Payment\VisaMaster\HandlesVisaMasterPayments;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -14,6 +15,7 @@ use Laravel\Nova\Makeable;
|
|||||||
class OnlinePaymentRepo
|
class OnlinePaymentRepo
|
||||||
{
|
{
|
||||||
use HandlesBillingSyncing;
|
use HandlesBillingSyncing;
|
||||||
|
use HandlesCardOrderPayments;
|
||||||
use HandlesSberPeyments;
|
use HandlesSberPeyments;
|
||||||
use HandlesVisaMasterPayments;
|
use HandlesVisaMasterPayments;
|
||||||
use Makeable;
|
use Makeable;
|
||||||
|
|||||||
Reference in New Issue
Block a user