Commit 0aafc75582514c98ffeefa17fef11ac9878bfa86
1 parent
f53e5df1dc
Exists in
master
komodoRc
Showing 1 changed file with 10 additions and 6 deletions Side-by-side Diff
lib/partner.js
... | ... | @@ -17,11 +17,17 @@ const resendDelay = require('komodo-sdk/gateway/resend-delay'); |
17 | 17 | |
18 | 18 | const st24 = require('./st24'); |
19 | 19 | |
20 | +if (config.partner.use_sslv3) { | |
21 | + https.globalAgent.options.secureProtocol = 'SSLv3_method'; | |
22 | +} | |
23 | + | |
20 | 24 | const partnerRc = fs.existsSync(__dirname + '/../rc-local.json') ? require('../rc-local.json') : require('./partner-rc.json'); |
21 | 25 | logger.verbose('Partner RC dictionary loaded', {partner_rc: partnerRc}); |
22 | 26 | |
23 | -if (config.partner.use_sslv3) { | |
24 | - https.globalAgent.options.secureProtocol = 'SSLv3_method'; | |
27 | +const RESPONSECODE_TAG = config.responsecode_tag ? config.responsecode_tag : 'RESPONSECODE'; | |
28 | + | |
29 | +function komodoRc(rc) { | |
30 | + return (config.partner.override_rc ? config.partner.override_rc[rc] : null) || partnerRc[value[rc]] || '40'; | |
25 | 31 | } |
26 | 32 | |
27 | 33 | function createXmlRpcClient(endpoint) { |
... | ... | @@ -89,11 +95,9 @@ function _topUpRequest(task, isAdvice) { |
89 | 95 | logger.info('Got XMLRPC response from partner for', {method: xmlrpcMethod, trx_id: task.trx_id, destination: task.destination, response: value}); |
90 | 96 | matrix.last_topupRequest_ack = value; |
91 | 97 | |
92 | - const RESPONSECODE_TAG = config.responsecode_tag ? config.responsecode_tag : 'RESPONSECODE'; | |
93 | - | |
94 | 98 | report({ |
95 | 99 | trx_id: task.trx_id, |
96 | - rc: partnerRc[value[RESPONSECODE_TAG]] || '40', | |
100 | + rc: komodoRc(value[RESPONSECODE_TAG]) || '40', | |
97 | 101 | message: stringify(value), |
98 | 102 | sn: (value.SN || '').replace(/;$/, '') || st24.extractSnFromMessage(value.MESSAGE, config.sn_pattern), |
99 | 103 | amount: value.PRICE || st24.extractPriceFromMsg(value.MESSAGE, config.amount_pattern), |
... | ... | @@ -141,7 +145,7 @@ function _topUpInquiry(task) { |
141 | 145 | |
142 | 146 | report({ |
143 | 147 | trx_id: task.trx_id, |
144 | - rc: partnerRc[value.RESPONSECODE] || '40', | |
148 | + rc: rc: komodoRc(value[RESPONSECODE_TAG]) || '40', | |
145 | 149 | message: stringify(value), |
146 | 150 | sn: (value.SN || '').replace(/;$/, '') || st24.extractSnFromMessage(value.MESSAGE, config.sn_pattern), |
147 | 151 | amount: value.PRICE || st24.extractPriceFromMsg(value.MESSAGE, config.amount_pattern), |