fix: update webhook signature retrieval and enhance error logging; correct file path in payment link test

This commit is contained in:
Tengku Achmad 2025-12-08 11:58:44 +07:00
parent 164e62c234
commit 1db068bfb2
2 changed files with 3 additions and 2 deletions

View File

@ -708,7 +708,7 @@ function verifyWebhookSignature(body, mode) {
const grossAmount = body?.gross_amount const grossAmount = body?.gross_amount
if (mode === 'SNAP') { if (mode === 'SNAP') {
const signature = req.headers['x-signature'] || req.headers['signature'] || body?.signature const signature = body?.signature_key
if (!signature) return false if (!signature) return false
const data = `${orderId}${statusCode}${grossAmount}${serverKey}` const data = `${orderId}${statusCode}${grossAmount}${serverKey}`
@ -1194,6 +1194,7 @@ app.post('/api/payments/notification', async (req, res) => {
} }
} catch (e) { } catch (e) {
console.log(e);
logError('webhook.error', { message: e?.message, stack: e?.stack }) logError('webhook.error', { message: e?.message, stack: e?.stack })
return res.status(500).json({ return res.status(500).json({
ok: false, ok: false,

View File

@ -3,7 +3,7 @@ const fs = require('fs');
async function createPaymentLink() { async function createPaymentLink() {
// Read file and remove BOM if present // Read file and remove BOM if present
let jsonContent = fs.readFileSync('../temp/tmp-createtransaksi.json', 'utf8'); let jsonContent = fs.readFileSync('temp/tmp-createtransaksi.json', 'utf8');
// Remove BOM // Remove BOM
if (jsonContent.charCodeAt(0) === 0xFEFF) { if (jsonContent.charCodeAt(0) === 0xFEFF) {
jsonContent = jsonContent.slice(1); jsonContent = jsonContent.slice(1);