$appId, "password" => $password, "subscriberId" => "tel:" . $userPhone, "applicationHash" => "y3b84346f63899a", "applicationMetaData" => [ "client" => "MOBILEAPP", "device" => "Samsung S10", "os" => "android8", "appCode"=> "com.firezone.lk" ] ]; $response = callIdeamart($otpRequestUrl, $payload); if (isset($response['statusCode']) && $response['statusCode'] == "S1000") { $message = "ඔබේ දුරකථනයට ලැබුණු PIN අංකය ඇතුළත් කරන්න."; $referenceNo = $response['referenceNo']; $step = "VERIFY_OTP"; } else { $message = "දෝෂයකි: " . ($response['statusDetail'] ?? "නැවත උත්සාහ කරන්න."); } } // --- පියවර 2: OTP එක තහවුරු කිරීම --- if (isset($_POST['action']) && $_POST['action'] == 'verify_otp') { $otp = trim($_POST['otp_pin']); $ref = $_POST['ref_no']; $userPhone = $_POST['phone_hidden']; $payload = [ "applicationId" => $appId, "password" => $password, "referenceNo" => $ref, "otp" => $otp ]; $response = callIdeamart($otpVerifyUrl, $payload); if (isset($response['statusCode']) && $response['statusCode'] == "S1000") { $message = "සුබ පැතුම්! ඔබ සාර්ථකව FireZone VIP සේවාවට ඇතුළත් විය."; $step = "SUCCESS"; } else { $message = "වැරදි PIN අංකයකි. නැවත උත්සාහ කරන්න."; $step = "VERIFY_OTP"; $referenceNo = $ref; } } function callIdeamart($url, $data) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_SLASHES)); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); return json_decode($res, true); } ?>