$publicKey, "Secret" => $activationCode, "Serial" => $serialNumber ]; //$bodyJson = json_encode($body, JSON_UNESCAPED_SLASHES); $bodyJson = trim(stripslashes(json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS)),'"'); //$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); // 1. توليد هاش SHA256 للـ JSON //$bodyHash = hash('sha256', $bodyJson, true); // 2. تحميل المفتاح الخاص للتوقيع $privateKey = openssl_pkey_get_private(file_get_contents("private_key.pem")); // تأكد من وجود هذا الملف بجانب السكربت // 3. توقيع الهاش openssl_sign($bodyJson, $signature, $privateKey, OPENSSL_ALGO_SHA256); // 4. تحويل التوقيع إلى Base64 $xSignature = base64_encode($signature); // 5. إرسال الطلب $headers = [ "Content-Type: application/json", "Accept-Language: en", "Request-Name: pos_web/pos/activate", "Subject: $terminalId", "X-Signature: $xSignature" ]; $ch = curl_init("https://cashmobile.mtnsyr.com:9000"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyJson); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // ✅ النتيجة header('Content-Type: application/json'); echo json_encode([ "httpCode" => $httpCode, "response" => json_decode($response, true), "sentBody" => $body, ]);