Commit f4b66436 by tdgiang

Add shared MegaPay signing helper for the admin module

Implements signRequest and signResponse functions that compute
MegaPay/Epay HMAC-SHA256 signatures per MGP_Merchant_Interface
specification sections 5.1 and 5.3. These functions will be consumed
by Tasks 7 and 9 of the admin transaction management feature.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
parent 85867919
"use strict";
var sha256 = require("sha256");
function signRequest(timeStamp, merTrxId, merId, amount, encodeKey, payToken) {
var base = timeStamp + merTrxId + merId + amount;
return payToken
? sha256(base + payToken + encodeKey)
: sha256(base + encodeKey);
}
function signResponse(resultCd, timeStamp, merTrxId, trxId, merId, amount, encodeKey, payToken) {
return sha256(
resultCd + timeStamp + merTrxId + trxId + merId + amount + (payToken || "") + encodeKey
);
}
module.exports = {
signRequest: signRequest,
signResponse: signResponse,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment