Callbacks
Last updated
http
POST /callback-endpoint HTTP/1.1
Content-Type: application/json
signature: 3d2e4a5b6c7d8e9f10g11h12i13j14k15l16m17n18o19p20q21r22s23t24u25const crypto = require('crypto');
const apiKey = 'your-api-key'; // The secret API key we provided
const payload = '{"event":"payment","amount":100}'; // The callback payload (JSON stringified)
const customerUuid = 'abc123'; // Your customer UUID
const dataToSign = `${payload}+${customerUuid}`;
const hmac = crypto.createHmac('sha256', apiKey);
hmac.update(dataToSign);
const recreatedSignature = hmac.digest('hex');
console.log('Recreated Signature:', recreatedSignature);const crypto = require('crypto');
const apiKey = Buffer.from('your-api-key', 'utf-8'); // The secret API key
const payload = '{"event":"payment","amount":100}'; // The callback payload (JSON stringified)
const customerUuid = 'abc123'; // The customer UUID
const dataToSign = ${payload}+${customerUuid};
const recreatedSignature = crypto
.createHmac('sha256', apiKey) // Create an HMAC using the SHA-256 algorithm and the API key
.update(dataToSign, 'utf-8') // Specify the data to sign
.digest('hex'); // Generate the hash in hexadecimal format
// Assume header.signature is the signature sent in the request headers
const header = { signature: 'signature-sent-in-header' }; // Placeholder for the header
const isValidSignature = recreatedSignature === header.signature; // Validate the signature
console.log('Is the signature valid?', isValidSignature);