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(
stan
=
iso_for_host
.
get_stan
()
data
=
[
ip_port_source
,
iso_response
]
if
ip_port_target
in
iso_process
:
iso_process
[
ip_port_target
][
stan
]
=
data
iso_process
[
ip_port_target
][
stan
]
=
data
else
:
iso_process
[
ip_port_target
]
=
{
stan
:
data
}
...
...
@@ -221,7 +221,7 @@ class RequestHandler(BaseRequestHandler, CommonConnection):
def
run
(
self
):
try
:
BaseRequestHandler
.
run
(
self
)
except
:
except
Exception
:
self
.
log_unknown
()
...
...
@@ -287,7 +287,7 @@ class Client(BaseClient, CommonConnection):
def
run
(
self
):
try
:
BaseClient
.
run
(
self
)
except
:
except
Exception
:
self
.
log_unknown
()
...
...
@@ -337,7 +337,7 @@ class Parser(Log):
self
.
log_decode
(
from_iso
)
try
:
iso
=
self
.
connection
.
job
.
process
(
from_iso
)
except
:
except
Exception
:
self
.
log_unknown
()
self
.
running
=
False
return
...
...
@@ -349,7 +349,7 @@ class Parser(Log):
if
for_host
:
try
:
self
.
send_iso_for_host
(
iso
)
except
:
except
Exception
:
self
.
log_unknown
()
else
:
self
.
send
(
iso
)
...
...
@@ -376,7 +376,7 @@ class Parser(Log):
try
:
iso
.
continue_response
(
from_iso
)
ok
=
True
except
:
except
Exception
:
self
.
log_unknown
()
ok
=
False
if
ok
:
...
...
@@ -389,7 +389,7 @@ class Parser(Log):
conn
.
log_encode
(
iso
)
raw
=
iso
.
getRawIso
()
conn
.
send
(
raw
)
def
send
(
self
,
iso
):
self
.
log_ack
(
iso
)
self
.
send_by_conn
(
iso
,
self
.
connection
)
...
...
iso8583_web/scripts/views/jsonrpc.py
View file @
f89c092
...
...
@@ -34,7 +34,7 @@ class View(BaseView):
data
=
iso_to_dict
(
iso_resp
)
r
=
dict
(
code
=
0
,
message
=
'OK'
,
data
=
data
)
self
.
log_send
(
r
)
return
r
return
r
def
not_found_error
(
self
,
hostname
):
# Override
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 (
log_web_info
,
log_web_error
,
)
from
.
.
import
(
from
.
import
(
WebJob
as
BaseWebJob
,
View
as
BaseView
,
)
...
...
@@ -42,15 +42,20 @@ from pyramid_linkaja.exceptions import (
PaymentNotFound
,
LinkError
,
)
from
pyramid_linkaja.response
import
(
from
pyramid_linkaja.response
s
import
(
InquiryResponse
,
PaymentResponse
,
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'
RENDERER
=
'csv'
conf
=
dict
()
...
...
@@ -97,7 +102,7 @@ def profile2name(profile):
def
get_ok_notify
(
data
):
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
''
...
...
@@ -154,7 +159,7 @@ class View(BaseView):
if
data
.
get
(
'amount'
):
row
.
amount
=
int
(
data
[
'amount'
])
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'
]
with
transaction
.
manager
:
DBSession
.
add
(
row
)
...
...
@@ -178,9 +183,10 @@ class View(BaseView):
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
=
profile2name
(
profile
)
web_data
[
'Biller Name'
]
=
row
.
biller_name
=
\
profile2name
(
profile
)
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
err
=
None
elif
iso_data
[
39
]
in
[
'33'
,
'55'
]:
...
...
@@ -198,7 +204,7 @@ class View(BaseView):
err
=
BaseError
()
if
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
)
row
.
resp_code
=
web_data
[
'Response Code'
]
row
.
resp_msg
=
web_data
[
'Notification Message'
]
...
...
@@ -268,22 +274,22 @@ class View(BaseView):
def
view_not_found
(
self
):
msg
=
f
'Path {self.request.path} tidak ada'
self
.
log_receive
(
msg
,
True
)
return
self
.
request
.
exception
return
self
.
request
.
exception
def
log_prefix
(
request
):
web_conf
=
web_path_conf
.
get
(
request
.
path
)
name
=
web_conf
[
'name'
]
return
f
'{request.client_addr} {name} {id(request)}'
@view_config
(
context
=
BaseError
)
def
view_exception
(
exc
,
request
):
r
=
InquiryResponse
()
r
=
InquiryResponse
()
r
[
'Response Code'
]
=
exc
.
code
r
[
'Notification Message'
]
=
exc
.
message
prefix
=
log_prefix
(
request
)
msg
=
'{} {} {}'
.
format
(
prefix
,
'Send'
,
r
)
msg
=
f
'{prefix} Send {r}'
log_web_error
(
msg
)
response
=
Response
(
str
(
r
))
response
.
status_int
=
200
...
...
iso8583_web/scripts/web_client.py
View file @
f89c092
...
...
@@ -12,10 +12,10 @@ from argparse import ArgumentParser
headers
=
{
'content-type'
:
'application/json'
}
threads
=
dict
()
end_threads
=
list
()
durations
=
dict
()
json_responses
=
dict
()
threads
=
dict
()
end_threads
=
list
()
durations
=
dict
()
json_responses
=
dict
()
server_info
=
dict
()
default_url
=
'http://localhost:7000/rpc'
...
...
@@ -36,7 +36,6 @@ def error(s):
sys
.
exit
()
def
log_info
(
s
):
t
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S.
%
f'
)
t
=
t
[:
-
3
]
...
...
@@ -75,7 +74,7 @@ def send(p):
else
:
log_info
(
'Status Code: {}'
.
format
(
resp
.
status_code
))
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
:
durations
[
key
]
=
time
()
-
start
log_info
(
'Response: {}'
.
format
(
e
))
...
...
@@ -143,7 +142,8 @@ def show_durations():
if
key_fastest
!=
key_slowest
:
log_info
(
'Tercepat {}'
.
format
(
messages
[
key_fastest
]))
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
)
...
...
iso8583_web/scripts/web_client_linkaja.py
View file @
f89c092
...
...
@@ -8,17 +8,17 @@ from time import (
)
from
threading
import
Thread
from
argparse
import
ArgumentParser
from
.views.linkaja.structure
import
(
from
pyramid_linkaja.responses
import
(
InquiryResponse
,
PaymentResponse
,
)
headers
=
{
'content-type'
:
'application/x-www-form-urlencoded'
}
threads
=
dict
()
end_threads
=
list
()
durations
=
dict
()
csv_responses
=
dict
()
threads
=
dict
()
end_threads
=
list
()
durations
=
dict
()
csv_responses
=
dict
()
server_info
=
dict
()
default_url
=
'http://localhost:7000/linkaja'
...
...
@@ -71,7 +71,7 @@ def get_option(argv):
parser
.
add_argument
(
'--merchant'
,
default
=
default_merchant
,
help
=
help_merchant
)
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
(
'--msg'
,
default
=
''
)
parser
.
add_argument
(
...
...
@@ -90,7 +90,7 @@ def send(thread_id, p):
data
=
p
[
'trx_type'
]
==
'021'
and
InquiryResponse
()
or
\
PaymentResponse
()
if
resp
.
status_code
==
200
:
data
.
from_raw
(
resp
.
text
)
data
.
from_raw
(
resp
.
text
)
log_info
(
'Response {}: {} -> {}'
.
format
(
resp
.
status_code
,
[
resp
.
text
],
data
.
values
))
csv_responses
[
thread_id
]
=
resp
...
...
@@ -137,14 +137,14 @@ def show_durations():
messages
[
tid
]
=
msg
=
resp
.
text
.
strip
()
if
tid_fastest
:
if
duration
<
durations
[
tid_fastest
]:
tid_fastest
=
tid
tid_fastest
=
tid
else
:
tid_fastest
=
tid
if
tid_slowest
:
if
duration
>
durations
[
tid_slowest
]:
tid_slowest
=
tid
tid_slowest
=
tid
else
:
tid_slowest
=
tid
tid_slowest
=
tid
total_duration
+=
duration
else
:
err
=
msg
=
resp
.
text
.
split
(
'
\n
'
)[
0
]
.
strip
()
...
...
@@ -159,7 +159,8 @@ def show_durations():
if
tid_fastest
!=
tid_slowest
:
log_info
(
'Tercepat {}'
.
format
(
messages
[
tid_fastest
]))
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
)
...
...
setup.py
View file @
f89c092
...
...
@@ -34,7 +34,7 @@ requires = [
'opensipkd-base @ git+https://git.opensipkd.com/sugiana/opensipkd-base.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/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