Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Owo Sugiana
/
iso8583-web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f89c092d
authored
Sep 15, 2020
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Bug fixed penggunaan pyramid_linkaja
1 parent
caa7ba2d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
39 deletions
iso8583_web/scripts/forwarder.py
iso8583_web/scripts/views/jsonrpc.py
iso8583_web/scripts/views/linkaja.py
iso8583_web/scripts/web_client.py
iso8583_web/scripts/web_client_linkaja.py
setup.py
iso8583_web/scripts/forwarder.py
View file @
f89c092
...
@@ -75,7 +75,7 @@ def append_iso_process(
...
@@ -75,7 +75,7 @@ def append_iso_process(
stan
=
iso_for_host
.
get_stan
()
stan
=
iso_for_host
.
get_stan
()
data
=
[
ip_port_source
,
iso_response
]
data
=
[
ip_port_source
,
iso_response
]
if
ip_port_target
in
iso_process
:
if
ip_port_target
in
iso_process
:
iso_process
[
ip_port_target
][
stan
]
=
data
iso_process
[
ip_port_target
][
stan
]
=
data
else
:
else
:
iso_process
[
ip_port_target
]
=
{
stan
:
data
}
iso_process
[
ip_port_target
]
=
{
stan
:
data
}
...
@@ -221,7 +221,7 @@ class RequestHandler(BaseRequestHandler, CommonConnection):
...
@@ -221,7 +221,7 @@ class RequestHandler(BaseRequestHandler, CommonConnection):
def
run
(
self
):
def
run
(
self
):
try
:
try
:
BaseRequestHandler
.
run
(
self
)
BaseRequestHandler
.
run
(
self
)
except
:
except
Exception
:
self
.
log_unknown
()
self
.
log_unknown
()
...
@@ -287,7 +287,7 @@ class Client(BaseClient, CommonConnection):
...
@@ -287,7 +287,7 @@ class Client(BaseClient, CommonConnection):
def
run
(
self
):
def
run
(
self
):
try
:
try
:
BaseClient
.
run
(
self
)
BaseClient
.
run
(
self
)
except
:
except
Exception
:
self
.
log_unknown
()
self
.
log_unknown
()
...
@@ -337,7 +337,7 @@ class Parser(Log):
...
@@ -337,7 +337,7 @@ class Parser(Log):
self
.
log_decode
(
from_iso
)
self
.
log_decode
(
from_iso
)
try
:
try
:
iso
=
self
.
connection
.
job
.
process
(
from_iso
)
iso
=
self
.
connection
.
job
.
process
(
from_iso
)
except
:
except
Exception
:
self
.
log_unknown
()
self
.
log_unknown
()
self
.
running
=
False
self
.
running
=
False
return
return
...
@@ -349,7 +349,7 @@ class Parser(Log):
...
@@ -349,7 +349,7 @@ class Parser(Log):
if
for_host
:
if
for_host
:
try
:
try
:
self
.
send_iso_for_host
(
iso
)
self
.
send_iso_for_host
(
iso
)
except
:
except
Exception
:
self
.
log_unknown
()
self
.
log_unknown
()
else
:
else
:
self
.
send
(
iso
)
self
.
send
(
iso
)
...
@@ -376,7 +376,7 @@ class Parser(Log):
...
@@ -376,7 +376,7 @@ class Parser(Log):
try
:
try
:
iso
.
continue_response
(
from_iso
)
iso
.
continue_response
(
from_iso
)
ok
=
True
ok
=
True
except
:
except
Exception
:
self
.
log_unknown
()
self
.
log_unknown
()
ok
=
False
ok
=
False
if
ok
:
if
ok
:
...
@@ -389,7 +389,7 @@ class Parser(Log):
...
@@ -389,7 +389,7 @@ class Parser(Log):
conn
.
log_encode
(
iso
)
conn
.
log_encode
(
iso
)
raw
=
iso
.
getRawIso
()
raw
=
iso
.
getRawIso
()
conn
.
send
(
raw
)
conn
.
send
(
raw
)
def
send
(
self
,
iso
):
def
send
(
self
,
iso
):
self
.
log_ack
(
iso
)
self
.
log_ack
(
iso
)
self
.
send_by_conn
(
iso
,
self
.
connection
)
self
.
send_by_conn
(
iso
,
self
.
connection
)
...
...
iso8583_web/scripts/views/jsonrpc.py
View file @
f89c092
...
@@ -34,7 +34,7 @@ class View(BaseView):
...
@@ -34,7 +34,7 @@ class View(BaseView):
data
=
iso_to_dict
(
iso_resp
)
data
=
iso_to_dict
(
iso_resp
)
r
=
dict
(
code
=
0
,
message
=
'OK'
,
data
=
data
)
r
=
dict
(
code
=
0
,
message
=
'OK'
,
data
=
data
)
self
.
log_send
(
r
)
self
.
log_send
(
r
)
return
r
return
r
def
not_found_error
(
self
,
hostname
):
# Override
def
not_found_error
(
self
,
hostname
):
# Override
msg
=
'Host {} tidak ditemukan di konfigurasi'
.
format
(
hostname
)
msg
=
'Host {} tidak ditemukan di konfigurasi'
.
format
(
hostname
)
...
...
iso8583_web/scripts/views/linkaja.py
View file @
f89c092
...
@@ -24,7 +24,7 @@ from iso8583_web.scripts.logger import (
...
@@ -24,7 +24,7 @@ from iso8583_web.scripts.logger import (
log_web_info
,
log_web_info
,
log_web_error
,
log_web_error
,
)
)
from
.
.
import
(
from
.
import
(
WebJob
as
BaseWebJob
,
WebJob
as
BaseWebJob
,
View
as
BaseView
,
View
as
BaseView
,
)
)
...
@@ -42,15 +42,20 @@ from pyramid_linkaja.exceptions import (
...
@@ -42,15 +42,20 @@ from pyramid_linkaja.exceptions import (
PaymentNotFound
,
PaymentNotFound
,
LinkError
,
LinkError
,
)
)
from
pyramid_linkaja.response
import
(
from
pyramid_linkaja.response
s
import
(
InquiryResponse
,
InquiryResponse
,
PaymentResponse
,
PaymentResponse
,
get_trx_date
,
get_trx_date
,
is_inquiry
,
is_payment
,
is_reversal
,
)
)
from
pyramid_linkaja.decorator
import
csv_method
from
pyramid_linkaja.structure
import
RENDERER
from
pyramid_linkaja.form
import
get_form
ROUTE
=
'linkaja'
ROUTE
=
'linkaja'
RENDERER
=
'csv'
conf
=
dict
()
conf
=
dict
()
...
@@ -97,7 +102,7 @@ def profile2name(profile):
...
@@ -97,7 +102,7 @@ def profile2name(profile):
def
get_ok_notify
(
data
):
def
get_ok_notify
(
data
):
for
key
in
conf
[
'notification_message'
]:
for
key
in
conf
[
'notification_message'
]:
if
data
[
'acc_no'
]
.
find
(
key
)
==
0
:
if
data
[
'acc_no'
]
.
find
(
key
)
==
0
:
return
conf
[
'notification_message'
][
key
]
return
conf
[
'notification_message'
][
key
]
return
''
return
''
...
@@ -154,7 +159,7 @@ class View(BaseView):
...
@@ -154,7 +159,7 @@ class View(BaseView):
if
data
.
get
(
'amount'
):
if
data
.
get
(
'amount'
):
row
.
amount
=
int
(
data
[
'amount'
])
row
.
amount
=
int
(
data
[
'amount'
])
if
not
is_inquiry
(
data
):
if
not
is_inquiry
(
data
):
row
.
inquiry_id
=
inq
and
inq
.
id
or
pay
.
inquiry_id
row
.
inquiry_id
=
inq
and
inq
.
id
or
pay
.
inquiry_id
row
.
ntb
=
data
[
'trx_id'
]
row
.
ntb
=
data
[
'trx_id'
]
with
transaction
.
manager
:
with
transaction
.
manager
:
DBSession
.
add
(
row
)
DBSession
.
add
(
row
)
...
@@ -178,9 +183,10 @@ class View(BaseView):
...
@@ -178,9 +183,10 @@ class View(BaseView):
profile
=
FixLength
(
INVOICE_PROFILE
)
profile
=
FixLength
(
INVOICE_PROFILE
)
profile
.
set_raw
(
iso_data
[
62
])
profile
.
set_raw
(
iso_data
[
62
])
iso_log
.
bit_062_data
=
profile
.
to_dict
()
iso_log
.
bit_062_data
=
profile
.
to_dict
()
web_data
[
'Biller Name'
]
=
row
.
biller_name
=
profile2name
(
profile
)
web_data
[
'Biller Name'
]
=
row
.
biller_name
=
\
profile2name
(
profile
)
web_data
[
'Bill Amount'
]
=
iso_data
[
4
]
.
lstrip
(
'0'
)
web_data
[
'Bill Amount'
]
=
iso_data
[
4
]
.
lstrip
(
'0'
)
if
iso_data
.
get
(
47
):
if
iso_data
.
get
(
47
):
web_data
[
'Transaction ID'
]
=
row
.
ntp
=
iso_data
[
47
]
# NTP
web_data
[
'Transaction ID'
]
=
row
.
ntp
=
iso_data
[
47
]
# NTP
err
=
None
err
=
None
elif
iso_data
[
39
]
in
[
'33'
,
'55'
]:
elif
iso_data
[
39
]
in
[
'33'
,
'55'
]:
...
@@ -198,7 +204,7 @@ class View(BaseView):
...
@@ -198,7 +204,7 @@ class View(BaseView):
err
=
BaseError
()
err
=
BaseError
()
if
err
:
if
err
:
web_data
.
from_err
(
err
)
web_data
.
from_err
(
err
)
row
.
resp_msg
=
web_data
[
'Notification Message'
]
row
.
resp_msg
=
web_data
[
'Notification Message'
]
self
.
log_send
(
web_data
.
values
)
self
.
log_send
(
web_data
.
values
)
row
.
resp_code
=
web_data
[
'Response Code'
]
row
.
resp_code
=
web_data
[
'Response Code'
]
row
.
resp_msg
=
web_data
[
'Notification Message'
]
row
.
resp_msg
=
web_data
[
'Notification Message'
]
...
@@ -268,22 +274,22 @@ class View(BaseView):
...
@@ -268,22 +274,22 @@ class View(BaseView):
def
view_not_found
(
self
):
def
view_not_found
(
self
):
msg
=
f
'Path {self.request.path} tidak ada'
msg
=
f
'Path {self.request.path} tidak ada'
self
.
log_receive
(
msg
,
True
)
self
.
log_receive
(
msg
,
True
)
return
self
.
request
.
exception
return
self
.
request
.
exception
def
log_prefix
(
request
):
def
log_prefix
(
request
):
web_conf
=
web_path_conf
.
get
(
request
.
path
)
web_conf
=
web_path_conf
.
get
(
request
.
path
)
name
=
web_conf
[
'name'
]
name
=
web_conf
[
'name'
]
return
f
'{request.client_addr} {name} {id(request)}'
return
f
'{request.client_addr} {name} {id(request)}'
@view_config
(
context
=
BaseError
)
@view_config
(
context
=
BaseError
)
def
view_exception
(
exc
,
request
):
def
view_exception
(
exc
,
request
):
r
=
InquiryResponse
()
r
=
InquiryResponse
()
r
[
'Response Code'
]
=
exc
.
code
r
[
'Response Code'
]
=
exc
.
code
r
[
'Notification Message'
]
=
exc
.
message
r
[
'Notification Message'
]
=
exc
.
message
prefix
=
log_prefix
(
request
)
prefix
=
log_prefix
(
request
)
msg
=
'{} {} {}'
.
format
(
prefix
,
'Send'
,
r
)
msg
=
f
'{prefix} Send {r}'
log_web_error
(
msg
)
log_web_error
(
msg
)
response
=
Response
(
str
(
r
))
response
=
Response
(
str
(
r
))
response
.
status_int
=
200
response
.
status_int
=
200
...
...
iso8583_web/scripts/web_client.py
View file @
f89c092
...
@@ -12,10 +12,10 @@ from argparse import ArgumentParser
...
@@ -12,10 +12,10 @@ from argparse import ArgumentParser
headers
=
{
'content-type'
:
'application/json'
}
headers
=
{
'content-type'
:
'application/json'
}
threads
=
dict
()
threads
=
dict
()
end_threads
=
list
()
end_threads
=
list
()
durations
=
dict
()
durations
=
dict
()
json_responses
=
dict
()
json_responses
=
dict
()
server_info
=
dict
()
server_info
=
dict
()
default_url
=
'http://localhost:7000/rpc'
default_url
=
'http://localhost:7000/rpc'
...
@@ -36,7 +36,6 @@ def error(s):
...
@@ -36,7 +36,6 @@ def error(s):
sys
.
exit
()
sys
.
exit
()
def
log_info
(
s
):
def
log_info
(
s
):
t
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S.
%
f'
)
t
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S.
%
f'
)
t
=
t
[:
-
3
]
t
=
t
[:
-
3
]
...
@@ -75,7 +74,7 @@ def send(p):
...
@@ -75,7 +74,7 @@ def send(p):
else
:
else
:
log_info
(
'Status Code: {}'
.
format
(
resp
.
status_code
))
log_info
(
'Status Code: {}'
.
format
(
resp
.
status_code
))
log_info
(
'Body: {}'
.
format
([
resp
.
text
]))
log_info
(
'Body: {}'
.
format
([
resp
.
text
]))
json_responses
[
key
]
=
dict
(
fatal
=
resp
.
text
)
json_responses
[
key
]
=
dict
(
fatal
=
resp
.
text
)
except
requests
.
exceptions
.
ConnectionError
as
e
:
except
requests
.
exceptions
.
ConnectionError
as
e
:
durations
[
key
]
=
time
()
-
start
durations
[
key
]
=
time
()
-
start
log_info
(
'Response: {}'
.
format
(
e
))
log_info
(
'Response: {}'
.
format
(
e
))
...
@@ -143,7 +142,8 @@ def show_durations():
...
@@ -143,7 +142,8 @@ def show_durations():
if
key_fastest
!=
key_slowest
:
if
key_fastest
!=
key_slowest
:
log_info
(
'Tercepat {}'
.
format
(
messages
[
key_fastest
]))
log_info
(
'Tercepat {}'
.
format
(
messages
[
key_fastest
]))
log_info
(
'Terlama {}'
.
format
(
messages
[
key_slowest
]))
log_info
(
'Terlama {}'
.
format
(
messages
[
key_slowest
]))
log_info
(
'Rerata {} detik / request'
.
format
(
total_duration
/
len
(
durations
)))
log_info
(
'Rerata {} detik / request'
.
format
(
total_duration
/
len
(
durations
)))
show_errors
(
errors
)
show_errors
(
errors
)
...
...
iso8583_web/scripts/web_client_linkaja.py
View file @
f89c092
...
@@ -8,17 +8,17 @@ from time import (
...
@@ -8,17 +8,17 @@ from time import (
)
)
from
threading
import
Thread
from
threading
import
Thread
from
argparse
import
ArgumentParser
from
argparse
import
ArgumentParser
from
.views.linkaja.structure
import
(
from
pyramid_linkaja.responses
import
(
InquiryResponse
,
InquiryResponse
,
PaymentResponse
,
PaymentResponse
,
)
)
headers
=
{
'content-type'
:
'application/x-www-form-urlencoded'
}
headers
=
{
'content-type'
:
'application/x-www-form-urlencoded'
}
threads
=
dict
()
threads
=
dict
()
end_threads
=
list
()
end_threads
=
list
()
durations
=
dict
()
durations
=
dict
()
csv_responses
=
dict
()
csv_responses
=
dict
()
server_info
=
dict
()
server_info
=
dict
()
default_url
=
'http://localhost:7000/linkaja'
default_url
=
'http://localhost:7000/linkaja'
...
@@ -71,7 +71,7 @@ def get_option(argv):
...
@@ -71,7 +71,7 @@ def get_option(argv):
parser
.
add_argument
(
parser
.
add_argument
(
'--merchant'
,
default
=
default_merchant
,
help
=
help_merchant
)
'--merchant'
,
default
=
default_merchant
,
help
=
help_merchant
)
parser
.
add_argument
(
'--terminal'
,
default
=
default_terminal
)
parser
.
add_argument
(
'--terminal'
,
default
=
default_terminal
)
parser
.
add_argument
(
'--pwd'
,
default
=
default_pwd
)
parser
.
add_argument
(
'--pwd'
,
default
=
default_pwd
)
parser
.
add_argument
(
'--msisdn'
,
default
=
default_msisdn
)
parser
.
add_argument
(
'--msisdn'
,
default
=
default_msisdn
)
parser
.
add_argument
(
'--msg'
,
default
=
''
)
parser
.
add_argument
(
'--msg'
,
default
=
''
)
parser
.
add_argument
(
parser
.
add_argument
(
...
@@ -90,7 +90,7 @@ def send(thread_id, p):
...
@@ -90,7 +90,7 @@ def send(thread_id, p):
data
=
p
[
'trx_type'
]
==
'021'
and
InquiryResponse
()
or
\
data
=
p
[
'trx_type'
]
==
'021'
and
InquiryResponse
()
or
\
PaymentResponse
()
PaymentResponse
()
if
resp
.
status_code
==
200
:
if
resp
.
status_code
==
200
:
data
.
from_raw
(
resp
.
text
)
data
.
from_raw
(
resp
.
text
)
log_info
(
'Response {}: {} -> {}'
.
format
(
log_info
(
'Response {}: {} -> {}'
.
format
(
resp
.
status_code
,
[
resp
.
text
],
data
.
values
))
resp
.
status_code
,
[
resp
.
text
],
data
.
values
))
csv_responses
[
thread_id
]
=
resp
csv_responses
[
thread_id
]
=
resp
...
@@ -137,14 +137,14 @@ def show_durations():
...
@@ -137,14 +137,14 @@ def show_durations():
messages
[
tid
]
=
msg
=
resp
.
text
.
strip
()
messages
[
tid
]
=
msg
=
resp
.
text
.
strip
()
if
tid_fastest
:
if
tid_fastest
:
if
duration
<
durations
[
tid_fastest
]:
if
duration
<
durations
[
tid_fastest
]:
tid_fastest
=
tid
tid_fastest
=
tid
else
:
else
:
tid_fastest
=
tid
tid_fastest
=
tid
if
tid_slowest
:
if
tid_slowest
:
if
duration
>
durations
[
tid_slowest
]:
if
duration
>
durations
[
tid_slowest
]:
tid_slowest
=
tid
tid_slowest
=
tid
else
:
else
:
tid_slowest
=
tid
tid_slowest
=
tid
total_duration
+=
duration
total_duration
+=
duration
else
:
else
:
err
=
msg
=
resp
.
text
.
split
(
'
\n
'
)[
0
]
.
strip
()
err
=
msg
=
resp
.
text
.
split
(
'
\n
'
)[
0
]
.
strip
()
...
@@ -159,7 +159,8 @@ def show_durations():
...
@@ -159,7 +159,8 @@ def show_durations():
if
tid_fastest
!=
tid_slowest
:
if
tid_fastest
!=
tid_slowest
:
log_info
(
'Tercepat {}'
.
format
(
messages
[
tid_fastest
]))
log_info
(
'Tercepat {}'
.
format
(
messages
[
tid_fastest
]))
log_info
(
'Terlama {}'
.
format
(
messages
[
tid_slowest
]))
log_info
(
'Terlama {}'
.
format
(
messages
[
tid_slowest
]))
log_info
(
'Rerata {} detik / request'
.
format
(
total_duration
/
len
(
durations
)))
log_info
(
'Rerata {} detik / request'
.
format
(
total_duration
/
len
(
durations
)))
show_errors
(
errors
)
show_errors
(
errors
)
...
...
setup.py
View file @
f89c092
...
@@ -34,7 +34,7 @@ requires = [
...
@@ -34,7 +34,7 @@ requires = [
'opensipkd-base @ git+https://git.opensipkd.com/sugiana/opensipkd-base.git'
,
'opensipkd-base @ git+https://git.opensipkd.com/sugiana/opensipkd-base.git'
,
'opensipkd-iso8583 @ git+https://git.opensipkd.com/sugiana/opensipkd-iso8583.git'
,
'opensipkd-iso8583 @ git+https://git.opensipkd.com/sugiana/opensipkd-iso8583.git'
,
'opensipkd-hitung @ git+https://git.opensipkd.com/sugiana/opensipkd-hitung.git'
,
'opensipkd-hitung @ git+https://git.opensipkd.com/sugiana/opensipkd-hitung.git'
,
'
opensipkd-hitung
@ git+https://git.opensipkd.com/sugiana/pyramid-linkaja.git'
,
'
pyramid-linkaja
@ git+https://git.opensipkd.com/sugiana/pyramid-linkaja.git'
,
]
]
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment