test_info.py
3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import sys
import os
from optparse import OptionParser
import locale
import importlib
from datetime import datetime
import imp
from opensipkd.forwarder.base.iso8583_forwarder import conf
from opensipkd.forwarder.base.modules.ws_tools import send_rpc
def main(argv=sys.argv):
# global listen_ports
# global ip_conf
# global allowed_ips
# global hosts
# global logs
# global stop_dir
# global running
# global log
##############
# Blok Utama #
##############
global conf
conf_file = os.path.join('conf', 'forwarder.py')
host_name = 'bjb'
log_dir = 'logs'
method = 'get_tagihan'
host = 'bjb'
no_rangka = ""
no_ktp = ""
no_invoice = ""
amount = 0
pars = OptionParser()
pars.add_option('-p', '--no-pol')
pars.add_option('-r', '--no-rangka', default=no_rangka, help='diisi 5 digit no rangka')
pars.add_option('-k', '--no-ktp', default=no_ktp, help='diisi dengan no identitas')
pars.add_option('-a', '--amount', default=amount, help='diisi nilai pembayaran')
pars.add_option('-c', '--conf-file', default=conf_file, help='default ' + conf_file)
pars.add_option('-o', '--host', default=host, help='default ' + host)
pars.add_option('-i', '--invoice', default=no_invoice, help='no tagihan')
pars.add_option('-m', '--method', default=method, help='default ' + method)
option, remain = pars.parse_args(argv[1:])
conf_file = os.path.realpath(option.conf_file)
# print(conf_file)
conf = imp.load_source('conf', conf_file)
method = option.method
host = option.host
no_pol = option.no_pol
no_rangka = option.no_rangka
no_ktp = option.no_ktp
no_invoice = option.invoice
amount = option.amount
_host = conf.host
rpc = _host[host]['samsat_banten']
kini = datetime.now()
tgl_transaksi = kini.strftime("%Y%m%d")
jam_transaksi = kini.strftime("%H%M%S")
message = dict(kd_bank=conf.host[host]['id'],
kd_biller=rpc['kd_biller'],
kd_channel='6010',
kd_produk=rpc['kd_produk'],
)
if method == 'get_tagihan':
message.update(dict(no_polisi=no_pol))
elif method == 'get_kd_bayar':
message.update(
dict(no_polisi=no_pol,
no_identitas=no_ktp,
no_rangka=no_rangka
)
)
elif method == 'inquiry':
message.update(
dict(
invoice_no=no_invoice
)
)
elif method == 'payment':
message.update(
dict(
invoice_no=no_invoice,
ntb='12345BHJJJK',
amount=int(amount),
tgl_transaksi=tgl_transaksi,
jam_transaksi=jam_transaksi,
)
)
elif method == 'reversal':
message.update(
dict(
invoice_no=no_invoice,
ntb='12345BHJJJK',
amount=int(amount),
tgl_transaksi=tgl_transaksi,
jam_transaksi=jam_transaksi,
ntp='1993797040'
)
)
# rpc = conf.rpc
rows = send_rpc(rpc['user'], rpc['key'], rpc['url'], method, message)
# print(rpc['user'], rpc['key'], rpc['url'], method, message)