if (!defined('PRAXIS_API_TEST_DOMAIN')) define('PRAXIS_API_TEST_DOMAIN', 'https://gateway.cashier-test.com'); if (!defined('PRAXIS_API_LIVE_DOMAIN')) define('PRAXIS_API_LIVE_DOMAIN', 'https://gateway.praxispay.com'); $url = PRAXIS_API_TEST_DOMAIN . '/cashier/cashier'; $merchant_id = ''; $merchant_secret = ''; $application_key = ''; $gateway = null; $time = time(); if (empty($merchant_id) || empty($merchant_secret) || empty($application_key)) { die('Variables must be set: $merchant_id, $merchant_secret, $application_key'); } $data = [ 'currency' => 'USD', 'amount' => 300, 'balance' => 10000, 'cid' => 'praxistest-' . $time, 'locale' => 'en-GB', 'gateway' => $gateway, 'version' => '1.3', 'timestamp' => $time, 'country' => 'GB', 'merchant_id' => $merchant_id, 'application_key' => $application_key, 'intent' => 'payment', 'customer_data' => [ 'email' => 'praxistest@nomail.com', 'country' => 'GB', 'zip' => '123456', 'city' => 'Some City', 'address' => 'Some st., 123', ], 'notification_url' => 'https://domain.does.not.exist/notification', 'return_url' => 'https://domain.does.not.exist/return', 'order_id' => 'order_' . $time, ]; $signature = [ $data['merchant_id'], $data['application_key'], $data['timestamp'], $data['intent'], $data['cid'], $data['order_id'], ]; $signature = implode('', $signature); $signature = hash('sha384', $signature . $merchant_secret); $request = curl_init(); curl_setopt_array($request, [ CURLOPT_URL => $url, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYHOST => true, CURLOPT_SSL_VERIFYPEER => false, CURLINFO_HEADER_OUT => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json; charset=utf-8', 'GT-Authentication: ' . $signature, ], ]); $response = curl_exec($request); $info = curl_getinfo($request); curl_close($request); try { $response_data = json_decode($response, true); if (is_array($response_data) && isset($response_data['status']) && $response_data['status'] === 0 && isset($response_data['redirect_url'])) { echo $response_data['redirect_url']; die; } else if (is_array($response_data) && isset($response_data['description'])) { echo $response_data['description']; die; } else { echo 'Something went wrong'; die; } } catch (Exception $e) { echo $e->getMessage(); }