From af34af9958d157f8811526134a960c3361899e1f Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Tue, 2 Dec 2025 18:16:57 +0530 Subject: [PATCH] GWM : App signature --- app/Config/Feature.php | 2 +- app/Config/Filters.php | 6 +- app/Config/Routes.php | 106 ++++----- app/Controllers/MediAssistApiController.php | 8 +- app/Controllers/VidalApiController.php | 232 ++++++++++++++------ app/Filters/VerifyAppSignature.php | 36 +++ 6 files changed, 266 insertions(+), 124 deletions(-) create mode 100644 app/Filters/VerifyAppSignature.php diff --git a/app/Config/Feature.php b/app/Config/Feature.php index 0bc45c6f..af762917 100755 --- a/app/Config/Feature.php +++ b/app/Config/Feature.php @@ -21,7 +21,7 @@ class Feature extends BaseConfig * - property $filtersInfo, instead of $filterInfo * - CodeIgniter\Router\RouteCollection::getFiltersForRoute(), instead of getFilterForRoute() */ - public bool $multipleFilters = false; + public bool $multipleFilters = true; /** * Use improved new auto routing instead of the default legacy version. diff --git a/app/Config/Filters.php b/app/Config/Filters.php index 00faa273..fcdd999a 100755 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -14,6 +14,7 @@ use App\Filters\HttpRequestLog; use App\Filters\CloseDbConnection; use App\Filters\AuthClientApi; use App\Filters\CommissionApiFilter; +use App\Filters\VerifyAppSignature; use App\Filters\AuthJWT; @@ -37,8 +38,9 @@ class Filters extends BaseConfig 'HttpRequestLog' => HttpRequestLog::class, 'authJWT' => AuthJWT::class, 'AuthClientApi' => AuthClientApi::class, - 'CloseDbConnection' => CloseDbConnection::class, - 'CommissionApiFilter' => CommissionApiFilter::class + 'CloseDbConnection' => CloseDbConnection::class, + 'CommissionApiFilter'=> CommissionApiFilter::class, + 'appSignature' => VerifyAppSignature::class, ]; /** diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 634252a7..822e8d4b 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -504,34 +504,7 @@ $routes->cli('cli/insurerRFQRemainder', 'LeadsController::remainderForQcr'); $routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery'); -//Employee login api's -$routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber"); -$routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); -$routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId"); -$routes->post("/employeeRest/updateEmpOTP", "RestAuthenticationController::updateEmpOTP"); -// MPIN api's -$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); -$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin"); -$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin"); -$routes->post("/employeeRest/checkMpin", "RestAuthenticationController::checkMpin"); -$routes->post("/employeeRest/updateEmpMPIN", "RestAuthenticationController::updateEmpMPIN"); -$routes->post("employeeRest/forgotMPIN", "RestAuthenticationController::forgotMPIN"); -$routes->post("employeeRest/updateMobileNumber", "RestAuthenticationController::updateMobileNumber"); - -// PASSWORD api's -$routes->post("employeeRest/savePassword", "RestAuthenticationController::savePassword"); -$routes->post("employeeRest/changePassword", "RestAuthenticationController::changePassword"); -$routes->post("employeeRest/verifyPassword", "RestAuthenticationController::verifyPassword"); -$routes->post("employeeRest/verifyOtp", "RestAuthenticationController::verifyOtp"); -$routes->post("employeeRest/checkPassword", "RestAuthenticationController::checkPassword"); - -//HR login api's -$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); -$routes->post("/employeeRest/verifyHrWithEmail", "RestAuthenticationController::verifyHrWithEmail"); -$routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData"); -$routes->post("/employeeRest/updateHROTP", "RestAuthenticationController::updateHROTP"); -$routes->get("/employeeRest/getHRAccessData", "RestAuthenticationController::getHRAccessData"); // Test initiate Claim $routes->post('initiateClaim',"EmployeeRestController::initiateClaim"); @@ -546,58 +519,47 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); }); -$routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth"); -// $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity"); -$routes->get("employeeRest/getClientDetails", "EmployeeRestController::getClientDetails"); -$routes->get("employeeRest/getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); $routes->get("getSSORedirectUrl", "ApiServiceController::getSSORedirectUrl"); + $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); -$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { +$routes->group("employeeRest", ["filter" => ["authJWT" , "appSignature"]], function ($routes) { $routes->post("ecardRequest", "ApiServiceController::ecardRequest"); - $routes->get("getWellnessURL", "ApiServiceController::getWellnessURL"); + $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity"); $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); - $routes->post("storeFireBase", "EmployeeRestController::storeFireBase"); - // $routes->post("updateMpin", "RestAuthenticationController::updateMpin"); + $routes->post("getChatResponse", "ChatBotController::getChatResponse"); + + + $routes->post("storeFireBase", "EmployeeRestController::storeFireBase"); $routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile"); - $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); - $routes->get("relationshipList", "EmployeeRestController::relationshipList"); - $routes->get("getEmployeeAndDependence", "EmployeeRestController::getEmployeeAndDependence"); $routes->post("editEmployeeAndDependence", "EmployeeRestController::editEmployeeAndDependence"); $routes->post("addEmployeeAndDependence", "EmployeeRestController::addEmployeeAndDependence"); - $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); $routes->post("createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount"); $routes->get("deleteDependence", "EmployeeRestController::deleteDependence"); $routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId"); $routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); - $routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); - $routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId"); - $routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData"); - $routes->post("calculatePremium", "EmployeeRestController::calculatePremium"); - $routes->get("getEmployeeOldPolicy", "EmployeeRestController::getEmployeeOldPolicy"); $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy"); $routes->get("getFEContent", "EmployeeRestController::getFEContent"); $routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); - $routes->get("getEcardURL", "EmployeeRestController::getEcardURL"); - //$routes->post('postDataForTicket',"EmployeeRestController::postDataForTicket"); + //hr api's @@ -607,6 +569,11 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->match( ['get', 'post'], 'claimsSearch','EmployeeRestController::claimsSearch'); $routes->get("claimView", "EmployeeRestController::claimView"); $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); + $routes->get("hrFileList", "EmployeeRestController::hrFileList"); + $routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters"); + $routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload"); + $routes->post("hrFileUpload", "EmployeeRestController::hrFileUpload"); + $routes->post("updateHrFileUploadData", "EmployeeRestController::updateHrFileUploadData"); //thz_master's @@ -617,11 +584,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("ticketHistoryList", "ThzController::ticketHistoryList"); $routes->match(['get','post','put'], 'ticketType', 'ThzController::ticketType'); - $routes->get("hrFileList", "EmployeeRestController::hrFileList"); - $routes->get("hrFileUploadMasters", "EmployeeRestController::hrFileUploadMasters"); - $routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload"); - $routes->post("hrFileUpload", "EmployeeRestController::hrFileUpload"); - $routes->post("updateHrFileUploadData", "EmployeeRestController::updateHrFileUploadData"); + //claims $routes->post('initiateClaim',"EmployeeRestController::initiateClaim"); @@ -630,6 +593,46 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { }); + +$routes->group("employeeRest", ['filter' => ["appSignature"] ], function ($routes) { + + //Employee login api's + $routes->post("verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber"); + $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); + $routes->post("verifyEmployeeEmailId", "RestAuthenticationController::verifyEmployeeWithEmailId"); + $routes->post("updateEmpOTP", "RestAuthenticationController::updateEmpOTP"); + + // MPIN api's + $routes->post("saveMpin", "RestAuthenticationController::saveMpin"); + $routes->post("updateMpin", "RestAuthenticationController::updateMpin"); + $routes->post("verifyMpin", "RestAuthenticationController::verifyMpin"); + $routes->post("checkMpin", "RestAuthenticationController::checkMpin"); + $routes->post("updateEmpMPIN", "RestAuthenticationController::updateEmpMPIN"); + $routes->post("forgotMPIN", "RestAuthenticationController::forgotMPIN"); + $routes->post("updateMobileNumber", "RestAuthenticationController::updateMobileNumber"); + + // PASSWORD api's + $routes->post("savePassword", "RestAuthenticationController::savePassword"); + $routes->post("changePassword", "RestAuthenticationController::changePassword"); + $routes->post("verifyPassword", "RestAuthenticationController::verifyPassword"); + $routes->post("verifyOtp", "RestAuthenticationController::verifyOtp"); + $routes->post("checkPassword", "RestAuthenticationController::checkPassword"); + + //HR login api's + $routes->post("verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); + $routes->post("verifyHrWithEmail", "RestAuthenticationController::verifyHrWithEmail"); + $routes->post("getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData"); + $routes->post("updateHROTP", "RestAuthenticationController::updateHROTP"); + $routes->get("getHRAccessData", "RestAuthenticationController::getHRAccessData"); + + $routes->post("getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth"); + + $routes->get("getClientDetails", "EmployeeRestController::getClientDetails"); + $routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); + +}); + + $routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload"); $routes->post("hrFileList", "EmployeeRestController::hrFileList"); $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy"); @@ -638,7 +641,6 @@ $routes->post("sendEmail", "EmployeeRestController::send_email"); $routes->get("getPolicyLevelEmployeeSummaryData", "EmployeeRestController::getPolicyLevelEmployeeSummaryData"); $routes->get("cdTransactionData", "EmployeeRestController::cdTransactionData"); $routes->match( ['get', 'post'], 'claimsSearch','EmployeeRestController::claimsSearch'); - $routes->get("getBackToEnrolledDetails", "EmployeeRestController::getBackToEnrolledDetails"); // Ticketing System diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index 621a187f..80bdecb7 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -34,10 +34,6 @@ class MediAssistApiController extends BaseController 'Password:'. getenv('MEDI_ASSIST_API_PASSWORD').'', ]; - - //Prepare body data - $db = \Config\Database::connect(); - //Prepare body data $db = \Config\Database::connect(); // Fetch the data from DB @@ -52,7 +48,7 @@ class MediAssistApiController extends BaseController tm.claim_amount as claimAmount, cp.policy_no as policyNo, e.id as empId, - e.emp_code as memberId, + tm.tpa_no as memberId, tn.note as disease, tn.note as reasonForHospitalization, cf.url as fileName, @@ -126,6 +122,8 @@ class MediAssistApiController extends BaseController // ] // ]; + log_message('error', 'TPA CLAIM PUSH | claimId: '.$claimId.' | payload: '.json_encode($body)); + $response = call_third_party_api($url, $method, $headers, $body); diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index 3a6e8b56..3dd1b69c 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -13,19 +13,23 @@ class VidalApiController extends BaseController } - function fileUploadToVidal() + function uploadFileToVidal($filePath,$filename) { $apiUrl = "https://devapigw.vidalhealthtpa.com/partner-integration/api/files/upload-url"; $subscriptionKey = getenv('VIDAL_API_SUBSCRIPTION_KEY'); + log_message('error', "Starting file upload process for filename: $filename | Path: $filePath"); + // Step 1: Get signed URL from Vidal API - $filePath = '/opt/lampp/htdocs/nhance/writable/uploads/claim_files/1760013019_73d94af7b96ddc2e3d51.png'; - $payload = json_encode(["scope" => 'document type' , 'fileName' => '1760013019_73d94af7b96ddc2e3d51.png']); + // $filePath = '/opt/lampp/htdocs/nhance/writable/uploads/claim_files/1760013019_73d94af7b96ddc2e3d51.png'; + $payload = json_encode(["scope" => 'document type' , 'fileName' => $filename]); $headers = [ "Content-Type: application/json", "Ocp-Apim-Subscription-Key: $subscriptionKey" ]; + log_message('error', "Requesting signed URL from Vidal API: $apiUrl | Payload: $payload"); + $ch = curl_init($apiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); @@ -34,19 +38,23 @@ class VidalApiController extends BaseController $response = curl_exec($ch); if (curl_errno($ch)) { - die("Curl error while requesting signed URL: " . curl_error($ch)); + log_message('error', "Curl error while requesting signed URL: " . curl_error($ch)); + return ["status" => false, "message" => curl_error($ch)]; } curl_close($ch); $responseData = json_decode($response, true); - - if (!isset($responseData['data']['signedUrl'])) { - die("Failed to get signed URL. Response: " . $response); + + if (!isset($responseData['data']['signedUrl']) || !isset($responseData['data']['fileId'])) { + log_message('error', "Invalid signed URL response received: " . json_encode($responseData)); + return ["status" => false, "message" => "Invalid signed URL response", "response" => $responseData]; } $signedUrl = $responseData['data']['signedUrl']; $fileId = $responseData['data']['fileId']; + log_message('error', "Received signed URL & fileId. fileId: $fileId"); + // Step 2: Upload file to signed URL using PUT (Azure Blob) $fileSize = filesize($filePath); $fileContent = fopen($filePath, 'r'); @@ -62,26 +70,170 @@ class VidalApiController extends BaseController ]); $uploadResponse = curl_exec($ch2); - $httpCode = curl_getinfo($ch2, CURLINFO_HTTP_CODE); - if (curl_errno($ch2)) { - die("Curl error while uploading file: " . curl_error($ch2)); - } + $curlErr = curl_error($ch2); + fclose($fileContent); curl_close($ch2); - if ($httpCode !== 201 && $httpCode !== 200) { - die("File upload failed. HTTP Code: $httpCode\nResponse: $uploadResponse"); + if ($curlErr) { + log_message('error', "Curl error during file upload: $curlErr"); + return ["status" => false, "message" => "File upload failed", "data" => $curlErr]; + } + + if ($httpCode !== 200 && $httpCode !== 201) { + log_message('error', "File upload failed with HTTP Code: $httpCode | Response: $uploadResponse"); + return [ + "status" => false, + "message" => "File upload failed", + "httpCode" => $httpCode, + "response" => $uploadResponse + ]; } // Step 3: Return File ID for reference - return $this->response->setJSON( [ + return [ "status" => true, "message" => "File uploaded successfully", "fileId" => $fileId, "signedUrl" => $signedUrl, - "uploadResponse" => json_decode($uploadResponse, true) - ]); + "uploadResponse" => json_decode($uploadResponse, true) + ]; + } + + public function SubmitClaim ($claimId = 515) + { + helper('api'); + + //Prepare body data + $db = \Config\Database::connect(); + // Fetch the data from DB + $data = $db->table('ticket_master tm') + ->select(' + tm.id, + tm.emp_mobile as mobileNo, + tm.emp_mail as emailId, + tm.doa as admissionDate, + tm.dod as dischargeDate, + tm.hospital_name as hospitalName, + tm.claim_amount as requestedAmount, + cp.policy_no as policyNo, + e.id as dependentUniqueId, + e.emp_code as memberId, + tn.note as disease, + tn.note as reasonForHospitalization, + cf.url as fileName, + cf.url as filePath, + pt.policy_type as typeOfClaim, + ep.tpa_id as empanelmentNo, + ') + ->join('employees e', 'e.id = tm.emp_id', 'left') + ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') + ->join('policy_type pt', 'pt.id = cp.policy_type_id', 'left') + ->join('employee_polices ep', 'ep.employee_id = e.id AND ep.client_policy_id = cp.id', 'left') + ->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left') + ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 and cf.mime_type = 'application/pdf'", 'left') + ->where('tm.id', $claimId) + ->get() + ->getRowArray(); // single record + + if (count($data) && $data['filePath'] == null) { + log_message('error', "Submit claim failed - Claim or File Missing"); + return $this->response->setJSON(['status' => false,'message' => 'Claim or File Missing', ]); + } + + $filePath = $data['filePath'] ?? ''; + $filename = basename($filePath); + $filePath = WRITEPATH . 'uploads/claim_files/'.$filename; + + // dd($data); + // Upload file first + + $upload = $this->uploadFileToVidal($filePath,$filename); + if ($upload['status'] !== true) { + log_message('error', "Submit claim failed - File upload failed"); + return $this->response->setJSON([ + 'status' => false, + 'message' => 'File upload failed', + 'data' => $upload + ]); + } + + $fileId = $upload['fileId']; + // $url = 'https://devapigw.vidalhealthtpa.com/partner-integration/api/claims/submit'; + $url = getenv('VIDAL_API_BASE_URL').'/claims/submit'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Ocp-Apim-Subscription-Key:' .getenv('VIDAL_API_SUBSCRIPTION_KEY').'', + ]; + + $body = [ + 'policyNo' => $data['policyNo'], + 'dependentUniqueId' => $data['dependentUniqueId'], + 'typeOfClaim' => $data['typeOfClaim'], + 'claimSubType' => "Test", + 'requestedAmount' => $data['requestedAmount'], + 'ailmentType' => "Non covid", + 'admissionDate' => change_date_format($data['admissionDate'], 'Y-m-d', 'd-m-Y'), + 'dischargeDate' => change_date_format($data['dischargeDate'], 'Y-m-d', 'd-m-Y'), + 'hospitalName' => $data['hospitalName'], + 'empanelmentNo' => $data['empanelmentNo'], + "ailmentName" => "Fever", + "hospitalAddress" => "No. 6, Officers Colony, Puthur.,dfgdfgdfg,dfgdfg,560058", + "hospitalState" => "karnataka", + "hospitalCity" => "bangalore", + "hospitalPinCode" => "560036", + "hospitalPhoneNo" => "1234567890", + "fileId" => $fileId, + "bankDetails" => [ + "accountHolderName" =>"Testing claim", + "accountType" =>"savings", + "accountNo" =>"1234567890", + "ifscCode" =>"ICICI098768" + ], + ]; + // dd($body); + log_message('error', "Submit claim failed - payload ". json_encode($body )); + // $body = [ + // 'policyNo' => "351500/D0534/PP/20-20/PC", + // 'dependentUniqueId' => "EN000000182-C-41", + // 'typeOfClaim' => "Main hospitalization claim", + // 'claimSubType' => "Hospitalization", + // 'requestedAmount' => "2500", + // 'ailmentType' => "Non covid", + // 'admissionDate' => "01-12-2025", + // 'dischargeDate' => "01-12-2025", + // 'hospitalName' => "AKSHAY SUPER SPECIALITY HOSPITAL", + // 'empanelmentNo' => "HOS-MUM-031423", + // "ailmentName" => "Cold", + // "hospitalAddress" => "No. 6, Officers Colony, Puthur.,dfgdfgdfg,dfgdfg,560058", + // "hospitalState" => "karnataka", + // "hospitalCity" => "bangalore", + // "hospitalPinCode" => "560036", + // "hospitalPhoneNo" => "1234567890", + // "bankDetails" => [ + // "accountHolderName" =>"Testing claim", + // "accountType" =>"savings", + // "accountNo" =>"1234567890", + // "ifscCode" =>"ICICI098768" + // ], + // "fileId" => "https://devapigw.vidalhealthtpa.com/doc-storage/api/private/691eda388973c60b83f80568" + // ]; + + + $response = call_third_party_api($url, $method, $headers, $body); + + if($response['status'] != true){ + return $this->response->setJSON([ + 'status' => false, + 'message' => 'failed.', + 'data' => $response + ]); + } + + return $this->response->setJSON($response); } public function fileUpload() @@ -132,54 +284,6 @@ class VidalApiController extends BaseController } - public function SubmitClaim ($claimId = null) - { - helper('api'); - - $url = getenv('VIDAL_API_BASE_URL').'/claims/submit'; - $method = 'POST'; - - $headers = [ - 'Content-Type: application/json', - 'Ocp-Apim-Subscription-Key:' .getenv('VIDAL_API_SUBSCRIPTION_KEY').'', - ]; - - $body = [ - 'policyNo' => "351500/D0534/PP/20-20/PC", - 'enrollmentId' => "BLR-NC-D0534-004-0000033-A", - 'typeOfClaim' => "Main hospitalization claim", - 'claimSubType' => "Hospitalization", - 'requestedAmount' => "3500", - 'ailmentType' => "Non covid", - 'admissionDate' => "20-07-2023", - 'dischargeDate' => "23-07-2023", - 'hospitalName' => "DELL HOSPITAL PVT LTD", - 'empanelmentNo' => "HOS-BLR-021280", - 'documentType' => "Claim", - 'ailmentName' => "Cold", - 'hospitalAddress' => "abc", - 'hospitalState' => "karnataka", - 'hospitalCity' => "bangalore", - 'hospitalPinCode' => "560036", - 'hospitalPhoneNo' => "7656879899", - 'fileId' => "https://devapigw.vidalhealthtpa.com/doc-storage/api/private/69130dfad1414b35a775480f", - ]; - - - - $response = call_third_party_api($url, $method, $headers, $body); - - if($response['status'] != true){ - return $this->response->setJSON([ - 'status' => false, - 'message' => 'failed.', - 'data' => $response - ]); - } - - return $this->response->setJSON($response); - } - public function claimStatus ($claimId = null) { helper('api'); diff --git a/app/Filters/VerifyAppSignature.php b/app/Filters/VerifyAppSignature.php new file mode 100644 index 00000000..a5257b21 --- /dev/null +++ b/app/Filters/VerifyAppSignature.php @@ -0,0 +1,36 @@ +getHeaderLine('App-Signature'); + + // Load the server's expected signature from the .env + $validSignature = getenv('APP_SIGNATURE'); + + // Check if signature is valid + if ($clientSignature !== $validSignature) { + return service('response') + ->setStatusCode(403) + ->setJSON([ + 'status' => false, + 'message' => 'Forbidden: Invalid App Signature', + ]); + } + + // allow request to proceed + } + + public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) + { + // nothing to do after response + } +}