refs #5122 Hotfix: Basic implementation for payment confirmation
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2023-01-30 12:39:47 +01:00
parent 3d6ec3c033
commit 109556ae2e
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,47 @@
module.exports = Self => {
Self.remoteMethod('confirm', {
description: 'Confirms electronic payment transaction',
accessType: 'WRITE',
accepts: [
{
arg: 'Ds_SignatureVersion',
type: 'string',
required: true,
}, {
arg: 'Ds_MerchantParameters',
type: 'string',
required: true,
}, {
arg: 'Ds_Signature',
type: 'string',
required: true,
}
],
returns: {
type: 'Boolean',
root: true
},
http: {
path: `/confirm`,
verb: 'POST'
}
});
Self.confirm = async(signatureVersion, merchantParameters, signature) => {
const buffer = Buffer.from(merchantParameters, 'base64');
const params = JSON.parse(buffer.toString());
console.debug('Payment confirmation received:', params);
await Self.rawSql(
'CALL hedera.tpvTransaction_confirm(?, ?, ?, ?, ?, ?)', [
params['Ds_Amount'],
params['Ds_Order'],
params['Ds_MerchantCode'],
params['Ds_Currency'],
params['Ds_Response'],
params['Ds_ErrorCode']
]
);
return true;
};
};

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/tpv-transaction/confirm')(Self);
};