Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
9741f6e82a
@ -552,7 +552,7 @@ $routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationCont
|
||||
$routes->get("employeeRest/getClientDetails", "EmployeeRestController::getClientDetails");
|
||||
$routes->get("employeeRest/getAdvertisementImage", "EmployeeRestController::getAdvertisementImage");
|
||||
|
||||
|
||||
$routes->get("getSSORedirectUrl", "ApiServiceController::getSSORedirectUrl");
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
|
||||
|
||||
@ -213,7 +213,7 @@ class ApiServiceController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
public function getWellnessUrl()
|
||||
public function getWellnessUrl()
|
||||
{
|
||||
|
||||
$emp_id = $this->request->getGet('emp_id');
|
||||
@ -310,6 +310,87 @@ class ApiServiceController extends BaseController
|
||||
|
||||
|
||||
|
||||
function getSSORedirectUrl($email = 'user@example.com')
|
||||
{
|
||||
// ---------- CONFIG ----------
|
||||
$authUrl = env('VIDAL_WELLNESS_BASE_URL'); // Authentication API URL
|
||||
$subscriptionKey = env('VIDAL_WELLNESS_SUBSCRIPTION_KEY');
|
||||
$apiVersion = "1";
|
||||
|
||||
// Provided Base64 AES key
|
||||
$base64Key = env('VIDAL_WELLNESS_BASE64_KEY');
|
||||
$key = base64_decode($base64Key);
|
||||
|
||||
// ---------- STEP 1: Build plaintext payload ----------
|
||||
$plainPayload = json_encode([
|
||||
"email" => $email,
|
||||
"corporateId" => env('VIDAL_WELLNESS_CORPORATE_ID'),
|
||||
"urlIdentifier" => env('VIDAL_WELLNESS_URL_IDENTIFIER')
|
||||
]);
|
||||
|
||||
// ---------- STEP 2: Encrypt payload ----------
|
||||
$iv = random_bytes(16);
|
||||
$encryptedRaw = openssl_encrypt($plainPayload, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $iv);
|
||||
|
||||
$encryptedPayload = base64_encode($iv) . ":" . base64_encode($encryptedRaw);
|
||||
|
||||
// ---------- STEP 3: Call Authentication API ----------
|
||||
$requestBody = json_encode([
|
||||
"payload" => $encryptedPayload,
|
||||
"source" => "portal",
|
||||
"subPartnerId" => env('VIDAL_WELLNESS_SUB_PARTNER_ID')
|
||||
]);
|
||||
|
||||
$headers = [
|
||||
"Ocp-Apim-Subscription-Key: $subscriptionKey",
|
||||
"apiver: $apiVersion",
|
||||
"mode: encrypt",
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
$ch = curl_init($authUrl);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$apiResponse = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$jsonResponse = json_decode($apiResponse, true);
|
||||
|
||||
dd($jsonResponse);
|
||||
|
||||
if (!isset($jsonResponse["data"])) {
|
||||
return ["error" => "Invalid API response", "response" => $apiResponse];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------- STEP 4: Decrypt response ----------
|
||||
list($ivBase64, $cipherBase64) = explode(":", $jsonResponse["data"]);
|
||||
|
||||
$respIv = base64_decode($ivBase64);
|
||||
$respCipher = base64_decode($cipherBase64);
|
||||
|
||||
$decryptedJson = openssl_decrypt($respCipher, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $respIv);
|
||||
|
||||
$decryptedData = json_decode($decryptedJson, true);
|
||||
|
||||
if (!isset($decryptedData["redirectUrl"])) {
|
||||
return ["error" => "redirectUrl missing", "decrypted" => $decryptedData];
|
||||
}
|
||||
|
||||
// ---------- FINAL ----------
|
||||
return $decryptedData["redirectUrl"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2857,21 +2857,25 @@ class EmployeeRestController extends AdminController
|
||||
if ($ClientPolicyValue['policy_type_id'] == 1) {
|
||||
$policyGroup = 'gpa';
|
||||
$data['ticket_type_id'] = 2;
|
||||
$data['ticket_settled_status_id'] = 24;
|
||||
$data['claim_subject'] = "Claim GPA";
|
||||
$data['sum_insured_label'] = "Sum Assured";
|
||||
} else if ($ClientPolicyValue['policy_type_id'] == 6) {
|
||||
$policyGroup = 'other';
|
||||
$data['ticket_type_id'] = 3;
|
||||
$data['ticket_settled_status_id'] = 34;
|
||||
$data['claim_subject'] = "Claim EDLI";
|
||||
$data['sum_insured_label'] = "Sum Assured";
|
||||
} else if ($ClientPolicyValue['policy_type_id'] == 7) {
|
||||
$policyGroup = 'other';
|
||||
$data['ticket_type_id'] = 4;
|
||||
$data['ticket_settled_status_id'] = 44;
|
||||
$data['claim_subject'] = "Claim GTLI";
|
||||
$data['sum_insured_label'] = "Sum Assured";
|
||||
} else {
|
||||
$policyGroup = 'gmc';
|
||||
$data['ticket_type_id'] = 1;
|
||||
$data['ticket_settled_status_id'] = 11;
|
||||
$data['claim_subject'] = "Claim GMC";
|
||||
$data['sum_insured_label'] = "Sum Insured";
|
||||
}
|
||||
@ -2949,8 +2953,22 @@ class EmployeeRestController extends AdminController
|
||||
$data['si_gst_value'] = ($ClientPolicyValue['policy_type_id'] == 1 || $ClientPolicyValue['policy_type_id'] == 2) ? 0 : round($si_gst_value);
|
||||
|
||||
$data['EmployeePolicy'] = $employee_policy;
|
||||
|
||||
//fetch claims data
|
||||
$approvedClaimsAmount = $this->ticketMaster
|
||||
->select('SUM(approved_amount) AS total_settled_amount')
|
||||
->where('emp_code', $employee_policy[0]['emp_code'])
|
||||
->where('client_policy_id', $data['client_policy_id'])
|
||||
->where('claim_status_id', $data['ticket_settled_status_id'])
|
||||
->groupBy('emp_code')
|
||||
->groupBy('client_policy_id')
|
||||
->groupBy('claim_status_id')
|
||||
->get()->getRow();
|
||||
$data['total_settled_amount'] = $approvedClaimsAmount ? ($approvedClaimsAmount->total_settled_amount ?? 0) : 0;
|
||||
array_push($result, $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result, 'emp_name' => $employeeName, 'pre_policy_count' => $prePolicyCount], 200);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user