refs #5174 TpvTransaction.confirm code refator to improve debugging
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
5984d6820b
commit
99f8bc6bac
|
@ -32,23 +32,24 @@ module.exports = Self => {
|
|||
|
||||
Self.confirm = async(signatureVersion, merchantParameters, signature) => {
|
||||
const $ = Self.app.models;
|
||||
|
||||
const decodedParams = JSON.parse(
|
||||
base64url.decode(merchantParameters, 'utf8'));
|
||||
const params = {};
|
||||
|
||||
for (const param in decodedParams)
|
||||
params[param] = decodeURIComponent(decodedParams[param]);
|
||||
|
||||
const orderId = params['Ds_Order'];
|
||||
if (!orderId)
|
||||
throw new UserError('Order id not provided');
|
||||
|
||||
const transaction = await Self.findById(orderId, {fields: ['id']});
|
||||
if (!transaction)
|
||||
throw new UserError('Order not found');
|
||||
let transaction;
|
||||
|
||||
try {
|
||||
const decodedParams = JSON.parse(
|
||||
base64url.decode(merchantParameters, 'utf8'));
|
||||
const params = {};
|
||||
|
||||
for (const param in decodedParams)
|
||||
params[param] = decodeURIComponent(decodedParams[param]);
|
||||
|
||||
const orderId = params['Ds_Order'];
|
||||
if (!orderId)
|
||||
throw new UserError('Order id not provided');
|
||||
|
||||
transaction = await Self.findById(orderId, {fields: ['id']});
|
||||
if (!transaction)
|
||||
throw new UserError('Order not found');
|
||||
|
||||
await transaction.updateAttributes({
|
||||
merchantParameters,
|
||||
signature,
|
||||
|
@ -86,11 +87,10 @@ module.exports = Self => {
|
|||
|
||||
return true;
|
||||
} catch (err) {
|
||||
try {
|
||||
if (transaction)
|
||||
await transaction.updateAttribute('responseError', err.message);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
else
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue