Commit 280ee07e by Owo Sugiana

Penyesuaian LinkAja dimana tahun bisa saja di field msg

1 parent 93329a02
0.3.2 2020-08-27
----------------
- Penyesuaian linkaja dimana tahun bisa saja di msg.
0.3.1 2020-08-19
----------------
- Bug fixed web service saat ISO8583 offline
......
......@@ -71,5 +71,9 @@ request_bits =
43:AGRATEK-LINKAJA
49:360
59:PAY
60:123
63:214
# Bit 60 diisi sesuai prefix bit 61 (Invoice ID)
bit_60 =
3271:123
3676:142
3275:120
......@@ -160,6 +160,28 @@ class csv_method(object):
return wrapped
def profile2name(profile):
msg = [profile['Nama'].strip()]
fields = [('Tagihan', 'Pok'), ('Denda', 'Den'), ('Discount', 'Disk')]
for field, label in fields:
s = profile[field].strip().lstrip('0')
if s:
msg.append(f'{label} {s}')
fields = ['Nama Kelurahan', 'Nama Kecamatan', 'Lokasi']
for field in fields:
s = profile[field].strip()
if s:
msg.append(s)
return ', '.join(msg)
def get_ok_notify(data):
for key in conf['notification_message']:
if data['acc_no'].find(key) == 0:
return conf['notification_message'][key]
return ''
class View(BaseView):
def get_web_job_cls(self): # Override
return WebJob
......@@ -229,14 +251,14 @@ class View(BaseView):
web_data = get_template_response(data)
if iso_data[39] == '00':
web_data['Response Code'] = '00'
web_data['Notification Message'] = get_ok_notify(data)
if is_inquiry(data):
web_data['Bill Ref'] = str(row.id)
if iso_data.get(62):
profile = FixLength(INVOICE_PROFILE)
profile.set_raw(iso_data[62])
iso_log.bit_062_data = profile.to_dict()
web_data['Biller Name'] = row.biller_name = \
profile['Nama'].strip()
web_data['Biller Name'] = row.biller_name = profile2name(profile)
web_data['Bill Amount'] = iso_data[4].lstrip('0')
if iso_data.get(47):
web_data['Transaction ID'] = row.ntp = iso_data[47] # NTP
......@@ -266,7 +288,10 @@ class View(BaseView):
return web_data
def get_response(self, data):
p = dict(invoice_id=data['acc_no'])
invoice_id = data['acc_no']
if len(invoice_id) == 18:
invoice_id += data['msg']
p = dict(invoice_id=invoice_id)
inq = pay = None
if not is_inquiry(data):
p['amount'] = data['amount']
......@@ -350,6 +375,17 @@ def init(cfg):
conf.update(cfg)
def str2dict(s):
r = dict()
for token in s.split('\n'):
s = token.strip()
if not s:
continue
key, value = s.split(':')
r[key] = value
return r
# Dipanggil forwarder.py
def pyramid_init(config):
config.add_renderer(RENDERER, 'iso8583_web.scripts.views.linkaja.Renderer')
......@@ -362,3 +398,4 @@ def pyramid_init(config):
session_factory = sessionmaker(bind=engine)
conf['db_session'] = scoped_session(session_factory)
register(conf['db_session'])
conf['notification_message'] = str2dict(conf['notification_message'])
......@@ -71,6 +71,7 @@ def get_option(argv):
parser.add_argument('--terminal', default=default_terminal)
parser.add_argument('--pwd', default=default_pwd)
parser.add_argument('--msisdn', default=default_msisdn)
parser.add_argument('--msg', default='')
return parser.parse_args(argv)
......@@ -199,7 +200,8 @@ class App:
pwd=self.option.pwd,
msisdn=self.option.msisdn,
acc_no=self.option.invoice_id,
trx_date=datetime.now().strftime('%Y%m%d%H%M%S'))
trx_date=datetime.now().strftime('%Y%m%d%H%M%S'),
msg=self.option.msg)
p['trx_type'] = self.get_method()
if self.option.payment or self.option.reversal:
required('amount')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!