65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Repos\System\Settings\Legal\PassportRepo;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class FetchLoanRemainingController extends Controller
|
|
{
|
|
/**
|
|
* Fetch card history
|
|
*
|
|
* @param Request $request
|
|
*/
|
|
public function index(Request $request): JsonResponse
|
|
{
|
|
$request->validate([
|
|
'passport_serie' => ['required', 'string', Rule::in(array_keys(PassportRepo::values()))],
|
|
'passport_id' => ['required', 'numeric', 'digits:6'],
|
|
'account_number' => ['required', 'string', 'max:255'],
|
|
]);
|
|
|
|
$passport_serie = $request->passport_serie;
|
|
$passport_id = $request->passport_id;
|
|
$account_number = $request->account_number;
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, [
|
|
CURLOPT_URL => 'http://10.3.158.102:9999/api/loaninfo',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
CURLOPT_POSTFIELDS => sprintf('
|
|
{
|
|
"idSeria": "%s",
|
|
"idNo": "%s",
|
|
"accountCode": "%s"
|
|
}
|
|
',
|
|
$passport_serie,
|
|
$passport_id,
|
|
$account_number,
|
|
),
|
|
CURLOPT_HTTPHEADER => [
|
|
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
|
'Content-Type: application/json',
|
|
],
|
|
]);
|
|
|
|
/** @var array<string, int|bool|null|string>|bool */
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
|
|
return response()->json($response);
|
|
}
|
|
}
|