$pin, "amount" => $amount, "callback" => $callback, "card_number" => $card ]; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://panel.aqayepardakht.ir/api/v2/create', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 10, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Content-Length: ' . strlen(json_encode($data)) ], )); $response = curl_exec($curl); if ($response === false) { echo 'Curl error: ' . curl_error($curl); return null; } curl_close($curl); return json_decode($response); } function createSepalTransaction($apiKey, $amount, $callbackUrl, $invoiceNumber) { $url = 'https://sepal.ir/api/sandbox/request.json'; $payload = [ 'apiKey' => $apiKey, 'amount' => intval($amount), 'callbackUrl' => $callbackUrl, 'invoiceNumber' => $invoiceNumber ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if (isset($result['status']) && $result['status'] === true) { return $result['paymentNumber']; } else { return false; } }