Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Owo Sugiana
/
opensipkd-iso8583
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 f7a845f9
authored
Sep 24, 2020
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Bug fixed streamer pos
1 parent
ac93356a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
65 deletions
CHANGES.txt
opensipkd/iso8583/doc.py
opensipkd/iso8583/network/doc.py
opensipkd/iso8583/network/job.py
opensipkd/streamer/pos.py
opensipkd/tcp/connection.py
CHANGES.txt
View file @
f7a845f
0.1.7 2020-09-24
----------------
- Bug fixed streamer pos (untuk PT POS) terkait Python 3
0.1.6 2020-06-24
----------------
- Perubahan rumus StanGenerator
...
...
opensipkd/iso8583/doc.py
View file @
f7a845f
...
...
@@ -15,13 +15,17 @@ class BaseISO8583(ISO8583):
value
=
"
%
s"
%
value
if
len
(
value
)
>
self
.
getBitLimit
(
bit
):
value
=
value
[
0
:
self
.
getBitLimit
(
bit
)]
raise
ValueTooLarge
(
'Error: value up to size! Bit[
%
s] of type
%
s limit size =
%
s'
%
(
bit
,
self
.
getBitType
(
bit
),
self
.
getBitLimit
(
bit
)))
raise
ValueTooLarge
(
'Error: value up to size! Bit[
%
s] of type
%
s '
'limit size =
%
s'
%
(
bit
,
self
.
getBitType
(
bit
),
self
.
getBitLimit
(
bit
)))
data_form
=
self
.
getBitFormat
(
bit
)
if
data_form
==
"A"
:
self
.
BITMAP_VALUES
[
bit
]
=
value
.
ljust
(
self
.
getBitLimit
(
bit
))
.
encode
()
self
.
BITMAP_VALUES
[
bit
]
=
value
.
ljust
(
self
.
getBitLimit
(
bit
))
.
\
encode
()
elif
data_form
==
"E"
:
self
.
BITMAP_VALUES
[
bit
]
=
value
.
zfill
(
self
.
getBitLimit
(
bit
))
.
encode
(
'cp1148'
)
self
.
BITMAP_VALUES
[
bit
]
=
value
.
zfill
(
self
.
getBitLimit
(
bit
))
.
\
encode
(
'cp1148'
)
def
redefineBit
(
self
,
bit
,
short_name
,
long_name
,
type_
,
size
,
valueType
):
if
type_
in
(
'LL'
,
'LLL'
):
...
...
@@ -33,15 +37,6 @@ class BaseISO8583(ISO8583):
self
,
bit
,
short_name
,
long_name
,
type_
,
LenForm
,
size
,
valueType
,
format_
)
#def getRawIso(self):
# raw = ISO8583.getRawIso(self)
# if isinstance(raw, bytes):
# raw = raw.decode('utf-8')
# return raw.upper()
#def setIsoContent(self, raw):
# ISO8583.setIsoContent(self, raw.encode('utf-8'))
def
get_bit_definition
(
self
):
return
{}
...
...
opensipkd/iso8583/network/doc.py
View file @
f7a845f
...
...
@@ -89,7 +89,7 @@ class Doc(BaseISO8583):
def
get_name
(
self
):
return
self
.
is_echo
()
or
self
.
is_sign_on
()
or
self
.
is_sign_off
()
or
\
self
.
is_reversal
()
or
self
.
is_inquiry
()
or
self
.
is_payment
()
def
get_transaction_code
(
self
):
return
self
.
getBit
(
3
)
...
...
@@ -131,13 +131,11 @@ class Doc(BaseISO8583):
# Override, please
def
copy_inquiry_bits
(
self
):
#self.copy([2, 3, 11])
pass
# Override, please
def
copy_payment_bits
(
self
):
self
.
copy_inquiry_bits
()
#self.copy([4, 48]) # amount, NTB
def
set_transaction_request
(
self
):
self
.
setMTI
(
'0200'
)
...
...
@@ -148,8 +146,8 @@ class Doc(BaseISO8583):
def
set_inquiry_request
(
self
):
# sebagai bank
self
.
set_transaction_request
()
self
.
set_transaction_code
(
self
.
get_inquiry_code
())
def
set_inquiry_response
(
self
):
# sebagai pemda
def
set_inquiry_response
(
self
):
# sebagai pemda
self
.
set_transaction_response
()
self
.
copy_inquiry_bits
()
...
...
@@ -158,7 +156,7 @@ class Doc(BaseISO8583):
def
get_amount
(
self
):
return
int
(
self
.
getBit
(
4
))
def
set_payment_request
(
self
):
# sebagai bank
self
.
set_transaction_request
()
self
.
setBit
(
3
,
self
.
get_payment_code
())
...
...
@@ -166,7 +164,7 @@ class Doc(BaseISO8583):
def
set_payment_response
(
self
):
# sebagai pemda
self
.
set_transaction_response
()
self
.
copy_payment_bits
()
def
set_reversal_request
(
self
):
# sebagai bank
self
.
setMTI
(
'0400'
)
self
.
setBit
(
3
,
self
.
get_payment_code
())
...
...
@@ -280,7 +278,7 @@ class Doc(BaseISO8583):
self
.
set_network_response
()
self
.
ack
()
def
sign_on_done
(
self
):
# Sebagai bank
def
sign_on_done
(
self
):
# Sebagai bank
pass
#####################
...
...
@@ -337,7 +335,7 @@ class Doc(BaseISO8583):
###############
# Transaction #
###############
def
inquiry_response
(
self
):
# Sebagai pemda
def
inquiry_response
(
self
):
# Sebagai pemda
pass
def
inquiry_done
(
self
):
# Sebagai bank
...
...
opensipkd/iso8583/network/job.py
View file @
f7a845f
...
...
@@ -7,8 +7,8 @@ from . import Doc
class
Job
:
def
__init__
(
self
,
connection
):
self
.
connection
=
connection
self
.
conf
=
connection
.
conf
self
.
echo_time
=
None
self
.
conf
=
connection
.
conf
self
.
echo_time
=
None
self
.
sign_on_time
=
False
self
.
do_echo
=
self
.
is_need_echo
()
...
...
@@ -34,12 +34,12 @@ class Job:
return
self
.
echo_request
()
# Dipanggil Parser.run()
def
raw_to_iso
(
self
,
raw
):
def
raw_to_iso
(
self
,
raw
):
iso
=
self
.
create_iso
()
iso
.
setIsoContent
(
raw
)
return
iso
# Dipanggil Connection.process()
# Dipanggil Connection.process()
def
process
(
self
,
from_iso
):
if
from_iso
.
is_response
():
if
self
.
sign_on_time
:
...
...
@@ -50,7 +50,7 @@ class Job:
iso
=
self
.
create_iso
(
from_iso
=
from_iso
)
try
:
iso
.
process
()
except
:
except
Exception
:
with
StringIO
()
as
f
:
traceback
.
print_exc
(
file
=
f
)
iso
.
ack_other
(
f
.
getvalue
())
...
...
opensipkd/streamer/pos.py
View file @
f7a845f
from
.
import
Streamer
as
BaseStreamer
# 2 byte pertama size
# Dalam 1 request bisa saja ada 2 transaksi, bahkan
# bisa saja string transaksi yang belum lengkap
from
.mitracomm
import
Streamer
as
BaseStreamer
class
Streamer
(
BaseStreamer
):
def
get_size
(
self
,
raw
):
def
get_size
(
self
,
raw
):
# Override
a
,
b
=
raw
a
=
ord
(
a
)
b
=
ord
(
b
)
*
256
return
a
+
b
# Override Stremer.get
def
get
(
self
,
raw
):
if
self
.
size
:
size
=
self
.
size
-
len
(
self
.
raw
)
else
:
raw
=
self
.
raw
+
raw
if
len
(
raw
)
<
2
:
self
.
raw
=
raw
return
size
=
self
.
size
=
self
.
get_size
(
raw
[:
2
])
self
.
raw
=
b
''
raw
=
raw
[
2
:]
self
.
raw
+=
raw
[:
size
]
if
len
(
self
.
raw
)
==
self
.
size
:
raw_iso
=
self
.
raw
self
.
size
=
0
self
.
raw
=
raw
[
size
:]
# Sisa
return
raw_iso
self
.
raw
+=
raw
[
size
:]
b
=
b
*
256
return
b
+
a
# Override Stremer.set
def
set
(
self
,
raw
):
def
set
(
self
,
raw
):
# Override
size
=
len
(
raw
)
a
=
size
%
256
b
=
size
/
256
header
=
bytes
([
a
])
+
bytes
([
b
])
b
=
size
%
256
a
=
int
(
size
/
256
)
header
=
bytes
([
b
])
+
bytes
([
a
])
return
header
+
raw
opensipkd/tcp/connection.py
View file @
f7a845f
...
...
@@ -14,7 +14,7 @@ def join_ip_port(ip, port):
class
Connection
:
def
__init__
(
self
,
conf
=
None
):
self
.
conf
=
conf
self
.
connected_time
=
None
self
.
connected_time
=
None
self
.
running
=
False
self
.
created_time
=
time
()
...
...
@@ -137,8 +137,7 @@ class Connection:
class
ConnectionManager
:
def
__init__
(
self
):
# Kumpulan class Connection
self
.
conns
=
[]
self
.
conns
=
[]
# Kumpulan class Connection
def
count
(
self
,
ip_port
):
count
=
0
...
...
@@ -161,7 +160,7 @@ class ConnectionManager:
for
this_ip_port
,
conn
in
self
.
conns
:
index
+=
1
if
this_ip_port
==
ip_port
:
found_conn
=
conn
found_conn
=
conn
found_index
=
index
return
found_conn
,
found_index
...
...
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