refactor(erp): make computeErpSignature async and improve signature handling
This commit is contained in:
parent
b234556f92
commit
e1dbe911c9
|
|
@ -443,10 +443,11 @@ function postJson(url, data) {
|
|||
})
|
||||
}
|
||||
|
||||
function computeErpSignature(mercantId, statusCode, nominal, clientId) {
|
||||
async function computeErpSignature(mercantId, statusCode, nominal, clientId) {
|
||||
try {
|
||||
const raw = String(mercantId) + String(statusCode) + String(nominal) + String(clientId)
|
||||
return crypto.createHash('sha512').update(raw).digest('hex')
|
||||
const sign = crypto.createHash('sha512').update(raw).digest('hex')
|
||||
return sign;
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
|
|
@ -483,13 +484,13 @@ async function notifyERP({ orderId, nominal, mercantId }) {
|
|||
logWarn('erp.notify.skip', { orderId, reason: 'missing_mercant_id' })
|
||||
return false
|
||||
}
|
||||
const signature = computeErpSignature(mId, statusCode, nominal, ERP_CLIENT_ID)
|
||||
// Payload ERP harus flat: { mercant_id, nominal, status_code, signature }
|
||||
const signature = await computeErpSignature(mId, statusCode, nominal, ERP_CLIENT_ID)
|
||||
|
||||
const payload = {
|
||||
mercant_id: mId,
|
||||
status_code: statusCode,
|
||||
nominal: nominal,
|
||||
signature,
|
||||
signature: signature,
|
||||
}
|
||||
logInfo('erp.notify.start', { orderId, url: ERP_NOTIFICATION_URL })
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue