Skip to content

Commit

Permalink
removes filtering from hashVerification (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterSlave authored Nov 13, 2023
1 parent 6ce79f5 commit 7f1e96b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/adapter/PaymentAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,15 @@ export default class PaymentAdapter extends BaseAdapter {

async is3DSecureCallbackVerified(threeDSecureCallbackKey: string, params: Map<string, string>): Promise<boolean> {
const hash = params['hash'];
let hashString: string = [
const hashString: string = [
threeDSecureCallbackKey,
params['status'],
params['completeStatus'],
params['paymentId'],
params['conversationData'],
params['conversationId'],
params['callbackStatus']
]
.filter(s => !!s)
.join('###');
hashString += '###';
].join('###');

const hashed = calculateHash(hashString);
return hash == hashed;
Expand Down
30 changes: 30 additions & 0 deletions test/adapter/PaymentAdapter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1060,3 +1060,33 @@ test('should search stored cards', async t => {
t.is(result.items[1].cardBrand, 'İşbank Maximum Card')
t.is(result.items[1].cardBankName, 'İşbank')
});

test('should verify 3ds callback hash', async t => {
const threeDSecureCallbackKey = "6UkASNuafM2TdannfMacixxjMaN5ycTJ";

const params = new Map();
params["hash"] = "768d4e056a9720e7355294b359fe597929dbb363315b543325f1c52612d55edc";
params["paymentId"] = "415449";
params["conversationId"] = "d1811bb0-25a2-40c7-ba71-c8b605259611";
params["status"] = "SUCCESS";
params["completeStatus"] = "WAITING";

const isVerified = await paymentAdapter.is3DSecureCallbackVerified(threeDSecureCallbackKey, params);
t.is(isVerified, true)
});

test('should verify 3ds callback hash with all information', async t => {
const threeDSecureCallbackKey = "6UkASNuafM2TdannfMacixxjMaN5ycTJ";

const params = new Map();
params["hash"] = "8f97746284f91a4295f99ae1e50dd70ccd3c932fd58437855e91a3a2fe86b293";
params["status"] = "FAILURE";
params["completeStatus"] = "";
params["paymentId"] = "417145";
params["conversationData"] = "";
params["conversationId"] = "d1811bb0-25a2-40c7-ba71-c8b605259611";
params["callbackStatus"] = "ALREADY_RETURNED";

const isVerified = await paymentAdapter.is3DSecureCallbackVerified(threeDSecureCallbackKey, params);
t.is(isVerified, true)
});

0 comments on commit 7f1e96b

Please sign in to comment.