Skip to main content

Callback Security

Security measures and best practices for webhook notifications.

Hash Validation (MD5)

MVPAY callbacks include a hash field in the body. This hash is created by concatenating specific fields in a specific order and taking the MD5.

Format

Concatenate in the following order:

processID + "|" + amount + "|" + userID + "|" + type + "|" + apiKey

Example string:

TEST-PROCESS-ID-T1|100|2|withdraw|YOUR_API_KEY

Note: Order matters. The amount value must be treated as a string. Prefer timing-safe comparison functions (e.g., hash_equals) when comparing.

Verification Code

import crypto from "crypto";

export function validateMVPayCallback(callbackData, yourApiKey) {
const hashString = `${callbackData.processID}|${callbackData.amount}|${callbackData.userID}|${callbackData.type}|${yourApiKey}`;
const expectedHash = crypto.createHash("md5").update(hashString).digest("hex");
// Timing-safe comparison
return crypto.timingSafeEqual(Buffer.from(expectedHash), Buffer.from(callbackData.hash));
}