@php
$b_token_valid = \App\Http\Controllers\HomeController::is_token_still_valid(config('starspin.config.session_timeout'));
if (!$b_token_valid) {
\App\Http\Controllers\HomeController::do_logout();
}
$login_link = config('starspin.config.starguide_login_url') . '?redirect=' . action('HomeController@checkout') . '&utm_source=StarSpin&utm_medium=online&utm_campaign=Star_Spin_Registration';
$logout = config('starspin.config.starguide_logout_url') . '?redirect=' . config('starspin.config.root_url') . '&utm_source=StarSpin&utm_medium=online&utm_campaign=Star_Spin_Registration';
$is_login = \App\Http\Controllers\HomeController::is_loggedin();
if (!$is_login) {
$token = isset($_GET['token']) ? $_GET['token'] : '';
$user_id = isset($_GET['user_id']) ? $_GET['user_id'] : '';
}
if (!$is_login && $user_id && $token) {
$arr_val = [
'USER_ID' => $user_id,
'ACCESS_TOKEN' => config('starspin.config.access_token'),
'TOKEN' => $token,
];
// GET user
$url_get_user = config('starspin.config.api_host') . \App\Http\Controllers\HomeController::template2content(config('starspin.config.uri_get_user'), $arr_val);
$response = \App\Http\Controllers\HomeController::callAPI('GET', $url_get_user, false);
$user_data = $response ? json_decode($response, true) : null;
if ($user_data && isset($user_data['api_status']) && $user_data['api_status'] == 'success') {
$full_name = isset($user_data['full_name']) ? $user_data['full_name'] : '';
$mobile = isset($user_data['mobile']) ? $user_data['mobile'] : '';
$city = isset($user_data['location']) ? $user_data['location'] : '';
$email = isset($user_data['email']) ? $user_data['email'] : '';
$user = \App\Member::query()
->where('id', '=', $user_id)
->first();
if ($user == null) {
$user = new \App\Member();
$user->id = $user_id;
$user->starguide_user_id = $user_id;
$user->email = $email;
$user->full_name = $full_name;
$user->mobile = $mobile;
$user->city = $city;
$user->ip_address = \App\Http\Controllers\HomeController::get_client_ip_address();
$user->added_date = date('Y-m-d H:i:s');
$user->save();
}
if ($user) {
\App\Http\Controllers\HomeController::set_login($user, $token);
$is_login = \App\Http\Controllers\HomeController::is_loggedin();
}
}
} else {
$userInfo = \App\Http\Controllers\HomeController::get_current_user_object();
$user_id = $userInfo ? $userInfo->id : '';
}
@endphp
@if ($is_login && $user_id != '')
@else
@endif
{{ __('messages.checkout.delivery_information_1') }}
@include('home.elements.invoice')
@if ($isMobile)
@include('home.elements.payment-referral')