<?php /*$endpoint = 'YOUR_ENDPOINT'; $officeId = 'YOUR_OFFICE_ID'; $apiKey = 'YOUR_API_KEY'; //$publicKey = 'YOUR_PUBLIC_KEY'; $pacoEncryptionPublic = 'YOUR_PACO_ENCRYPTION_PUBLIC_KEY'; $pacoSigningPublic = 'YOUR_PACO_SIGNING_PUBLIC_KEY'; $endpoint = 'https://core.demo-paco.2c2p.com/api/1.0/Payment/prePaymentUi'; $officeid = '2206'; $apikey ='7068c343afa741ea978abe75a1b22d51'; $secretKeyspfin= file_get_contents('../key/spfinpublickey.txt'); $pacoEncryptionPublicKey = file_get_contents('../key/PACOEncryptionPublic.txt'); $pacoSigningPublicKey = file_get_contents('../key/PACOSigningPublic.txt');*/ require_once("config/config.php"); /*// สร้างข้อมูลที่จะส่งให้กับ API $data = array( 'param1' => 'value1', 'param2' => 'value2', // ... );*/ $data = array( 'merchant_id' => $officeid, 'order_id' => 'ORDER12345', 'currency' => 'THB', 'amount' => '100.00', 'customer_email' => 'customer@example.com', // ข้อมูลอื่น ๆ ที่ต้องการส่งให้กับ API // ... ); var_dump($data); // ทำการเข้ารหัสข้อมูล $encryptedData = openssl_public_encrypt(json_encode($data), $encrypted, $pacoEncryptionPublic); // สร้าง signature $signature = hash_hmac('sha256', implode('', $data), $pacoSigningPublic); var_dump($signature); // ส่งคำขอไปยัง API $ch = curl_init($endpoint); 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); // ตรวจสอบผลลัพธ์ if ($response === false) { // การส่งคำขอผิดพลาด echo 'Error: ' . curl_error($ch); } else { // ประมวลผลข้อมูลที่ได้รับ // ... echo $response; } ?>