Skip to content

Commit 66adc5f

Browse files
Merge pull request #11 from Kount/develo-k360-sfra
Kount feedback fixes from emails
2 parents 59ed52a + 660e6d4 commit 66adc5f

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

cartridges/int_kount_360_sfra/caches.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"caches": [
33
{
44
"id": "Kount360",
5-
"expireAfterSeconds": 1140
5+
"expireAfterSeconds": 900
66
}
77
]
88
}

cartridges/int_kount_360_sfra/cartridge/scripts/helpers/kount360Helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function getCachedToken() {
2828
if (
2929
currentToken &&
3030
currentToken.token &&
31-
currentToken.expiresAt - 60 > today.getTime()
31+
(currentToken.expiresAt - 60000) > today.getTime()
3232
) {
3333
return currentToken.token;
3434
}

cartridges/int_kount_360_sfra/cartridge/scripts/helpers/kount360OrderModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ function getKountTransactions(order) {
159159
transactions.push({
160160
merchantTransactionId: transaction.transactionID || '',
161161
processor: transaction.paymentProcessor ? transaction.paymentProcessor.ID : '',
162-
subtotal: order.adjustedMerchandizeTotalNetPrice && order.adjustedMerchandizeTotalNetPrice.available ? order.adjustedMerchandizeTotalNetPrice.multiply(100).value : null,
163-
orderTotal: order.adjustedMerchandizeTotalPrice && order.adjustedMerchandizeTotalPrice.available ? order.adjustedMerchandizeTotalPrice.multiply(100).value : null,
162+
subtotal: order.adjustedMerchandizeTotalPrice && order.adjustedMerchandizeTotalPrice.available ? order.adjustedMerchandizeTotalPrice.multiply(100).value : null,
163+
orderTotal: order.totalGrossPrice && order.totalGrossPrice.available ? order.totalGrossPrice.multiply(100).value : null,
164164
currency: order.currencyCode || '',
165165
tax: {
166166
isTaxable: order.totalTax && order.totalTax.available ? order.totalTax.value > 0 : false,

cartridges/int_kount_360_sfra/cartridge/scripts/kount/libKount.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ var kount360Mappings = require('*/cartridge/kount360mappings/index');
1010
var basePostRISRequest = base.postRISRequest;
1111
var basePostRiskCall = base.postRiskCall;
1212

13+
/**
14+
* @description Maps UDF fields to Kount 360 format
15+
* @param {dw.order.Order} order Order
16+
* @returns {Object} Object with UDF fields mapped to Kount 360 format
17+
*/
18+
function mapKount360UDFFields(order) {
19+
var baseUDFFields = base.getUDFFields(order);
20+
var kount360UDFFields = {customFields: {}};
21+
22+
for (var i = 0; i < baseUDFFields.length; i++) {
23+
kount360UDFFields.customFields[baseUDFFields[i].label] = baseUDFFields[i].value;
24+
}
25+
26+
return kount360UDFFields;
27+
}
28+
1329
/**
1430
* @description Makes POST request. Sends orders details for evaluating
1531
* @param {Object} RequiredInquiryKeysVal Payload to send to Kount risk service
@@ -40,8 +56,10 @@ function postRISRequest(RequiredInquiryKeysVal) {
4056
var inquirySource = mappingUtils.applyCustomMapping(RequiredInquiryKeysVal, kount360Mappings.kount360ReqValueMapping);
4157
var requestBody = mappingUtils.transform(kount360Mappings.kount360ReqMapping, inquirySource);
4258
var extendedOrderModel = orderModel.error || RequiredInquiryKeysVal.MODE === 'U' ? requestBody : kountUtils.extend(requestBody, orderModel);
59+
var kount360UDFFields = mapKount360UDFFields(order);
60+
var finalRequestBody = kountUtils.extend(extendedOrderModel, kount360UDFFields);
4361
var response = kount360APIService.call({
44-
requestBody: extendedOrderModel,
62+
requestBody: finalRequestBody,
4563
params: {
4664
riskInquiry: RequiredInquiryKeysVal.MODE !== 'U' ? 'true' : 'false'
4765
},

0 commit comments

Comments
 (0)