fix: update webhook signature retrieval and enhance error logging; correct file path in payment link test #22
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue