<?php
$api_key = 'fd1535879ba6723c213ecc1b7c9279606de027b01e31b7c2';
$api_secret = '39316324b948128c512d3d6297230691c1adcb99fa238f70a37f78e368446ec1';

$body = [
    'merchant_order_id' => 'TEST_' . time(),
    'amount'            => 500,
    'currency'          => 'PKR',
    'method'            => 'easypaisa',
    'customer_name'     => 'Ali Khan',
    'customer_phone'    => '03001234567',
    'notify_url'        => 'https://pakclub24.club/webhook/',
    'return_url'        => 'https://pakclub24.club/payment/success'
];

$body_json = json_encode($body);
$signature = hash_hmac('sha256', $body_json, $api_secret);

$ch = curl_init('https://gopayx.live/api/public/v1/payins');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => $body_json,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_TIMEOUT        => 30,
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
        'x-api-key: ' . $api_key,
        'x-signature: ' . $signature
    ]
]);
$response = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);

echo "Error: " . $err . "\n";
echo "Response: " . $response . "\n";
