(Optional) Handle Callback URL for payment status updates
Once the customer completes the payment, PayWay will send the transaction details and other important information to the
return_url.
If return_url is not provided in the request, PayWay will use the default return_url configured in the API Settings.
If you provide a custom return_url, make sure the domain is whitelisted in your merchant profile.
Your return_url endpoint must:Accept the HTTP POST method
Accept Content-Type: application/json
We highly recommend securing this URL to ensure that only PayWay has access to it.
{
"tran_id": "17425401324",
"apv": "619195",
"status": "0",
"return_params": "xxxxxxxxxx"
}
tran_id string
Transaction ID sent during the initial payment process.
apv string
Transaction approval code.
status string
Payment status
return_params string
Extra information sent to the payment gateway during the payment initiation request.
Verify Callback SignatureFor security purposes, PayWay includes a hash signature in the request header.
You should verify this signature to confirm that the callback was sent by PayWay and that the data has not been modified.Below is an example in PHP demonstrating how to:3.
Compare it with the signature received in the header
// Read request body
$response = json_decode(file_get_contents('php://input'), true);
$secretKey = "YOUR_SECRET_KEY";
// 1. Sort fields by key (ascending)
ksort($response);
// 2. Concatenate all values
$b4hash = '';
foreach ($response as $value) {
if (is_array($value)) {
$value = json_encode($value);
}
$b4hash .= $value;
}
// 3. Generate HMAC-SHA512 signature
$signature = base64_encode(
hash_hmac('sha512', $b4hash, $secretKey, true)
);
// 4. Get signature from request header
$receivedSignature = $_SERVER['HTTP_X_PAYWAY_HMAC_SHA512'] ?? '';
// 5. Compare signatures
if (hash_equals($signature, $receivedSignature)) {
// Valid request – process the notification
} else {
// Invalid request
http_response_code(401);
exit('Invalid signature');
}