<?php require_once("config/config.php"); /*$apiUrl = 'https://core.demo-paco.2c2p.com/api/1.0/Payment/prePaymentUi'; $officeId = 'YOUR_OFFICE_ID'; $apiKey = 'YOUR_API_KEY'; $publicKey = 'YOUR_PUBLIC_KEY'; $pacoEncryptionPublic = 'YOUR_PACO_ENCRYPTION_PUBLIC_KEY'; $pacoSigningPublic = 'YOUR_PACO_SIGNING_PUBLIC_KEY'; // สร้างข้อมูลที่จะส่งให้กับ API $data = array( 'param1' => 'value1', 'param2' => 'value2', // ... );*/ $apiUrl=$endpoint; $data = array( 'merchant_id' => $officeid, 'order_id' => 'ORDER12345', 'currency' => 'THB', 'amount' => '100.00', 'customer_email' => 'customer@example.com', // ข้อมูลอื่น ๆ ที่ต้องการส่งให้กับ API // ... ); var_dump($data); // เข้ารหัสข้อมูลโดยใช้ PACOEncryptionPublic key $encryptedData = openssl_public_encrypt(json_encode($data), $encrypted, $pacoEncryptionPublic); // สร้าง signature โดยใช้ PACOSigningPublic key $signature = hash_hmac('sha256', implode('', $data), $pacoSigningPublic); // ส่งคำขอไปยัง API $ch = curl_init($apiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Office-Id: ' . $officeId, 'Api-Key: ' . $apiKey, 'Signature: ' . $signature )); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($encrypted)); $response = curl_exec($ch); curl_close($ch); var_dump(json_encode($encrypted)); // ตรวจสอบผลลัพธ์ /*if ($response === false) { echo 'Error: ' . curl_error($ch); } else { // ประมวลผลข้อมูลที่ได้รับ $responseData = json_decode($response, true); if (isset($responseData['result']) && $responseData['result'] === 'SUCCESS') { // แสดง URL ที่ได้รับจากการตอบกลับ $paymentUrl = $responseData['paymentUrl']; echo 'Payment URL: ' . $paymentUrl; } else { // การตอบกลับไม่สำเร็จ echo 'API Response Error'; } }*/ ?>