diff --git a/examples/kopnus/config.json b/examples/kopnus/config.json index 1e6a914..85ae020 100644 --- a/examples/kopnus/config.json +++ b/examples/kopnus/config.json @@ -1,11 +1,12 @@ { "auto_resend": { "delay_ms": 60000, - "max_retry": 1, - "max_age_ms": 240000 + "max_retry": 1 }, "sn_pattern": { "pattern": "SN=(.*?)\\.", "match_idx": 1 - } + }, + "advice_max_age_ms": 240000, + "advice_is_topuprequest": true } diff --git a/lib/partner.js b/lib/partner.js index a79b2d2..cde436d 100644 --- a/lib/partner.js +++ b/lib/partner.js @@ -155,11 +155,18 @@ function _topUpInquiry(task) { } function advice(task) { - if (config && advice_is_not_allowed) { + if (config && config.advice_is_not_allowed) { return; } - if (config && advice_is_topuprequest) { + if (config && config.advice_max_age_ms) { + if (moment() - moment(task.created) > config.advice_max_age_ms) { + logger.verbose('Ignoring advice request because of expired task', {trx_id: task.trx_id, destination: task.destination, product: task.product, created: task.created, max_age: config.advice_max_age_ms}); + return; + } + } + + if (config && config.advice_is_topuprequest) { _topUpRequest(task, true); } else {