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
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6dcd0e02
authored
Apr 26, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Refactor ISO8583Processor to improve MTI handling and logging; include invoice I…
…D in performance logs
1 parent
3c485e6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
iso8583_web/iso8583/processor.py
iso8583_web/iso8583/processor.py
View file @
6dcd0e0
...
...
@@ -40,17 +40,23 @@ class ISO8583Processor:
# print(f"[process_file] db_config: {db_config}")
iso
=
ISO8583
(
iso
=
data
)
print
(
iso
.
showBitmap
())
# print(iso.showBitmap())
# try:
# invoice_id = iso.getBit(61) if iso.getBit(61) else None
# log.info(f"Processing file: {filename}, MTI: {iso.getMTI()}, Invoice ID (Bit 61): {invoice_id}")
# except Exception as e:
# log.error(f"Error parsing ISO8583 message from {filename}: {e}")
bit39
=
'00'
mti
=
iso
.
getMTI
()
if
iso
.
getMTI
()
else
'0000'
log
.
info
(
f
"MTI detected: {mti}"
)
response
=
b
''
invoice_id
=
""
if
mti
==
'0800'
:
log
.
info
(
f
"Handling network management MTI: {mti}"
)
iso
.
setMTI
(
'0810'
)
elif
mti
in
(
'0200'
,
'0210'
):
logging
.
info
(
f
"Handling transaction MTI: {mti}"
)
func
=
iso
.
getBit
(
3
)
if
iso
.
getBit
(
3
)
else
'000000'
invid
=
iso
.
getBit
(
61
)
if
iso
.
getBit
(
37
)
else
None
invoice_id
=
re
.
sub
(
r'\D'
,
''
,
invid
)
if
invid
else
'000000'
...
...
@@ -109,19 +115,16 @@ class ISO8583Processor:
logging
.
info
(
f
"Handling reversal MTI: {mti}"
)
response
=
b
'RESP:0400/0420'
# Add bit 7, 4, 62, 39 as needed
else
:
logging
.
warning
(
f
"Unknown MTI: {mti}"
)
response
=
b
'UNKNOWN MTI'
if
response
==
b
'UNKNOWN MTI'
:
logging
.
info
(
f
"Removed unprocessable file: {filename}"
)
return
response
else
:
iso
.
setBit
(
7
,
self
.
get_bit7
())
iso
.
setBit
(
39
,
bit39
)
response
=
iso
.
getRawIso
()
log
.
info
(
f
"[WRITE] Prepared response for {filename}, data: {response.hex() if isinstance(response, bytes) else response}"
)
return
response
logging
.
error
(
f
"Unknown MTI: {mti}"
)
bit39
=
'96'
# System malfunction
iso
.
setBit
(
7
,
self
.
get_bit7
())
iso
.
setBit
(
39
,
bit39
)
response
=
iso
.
getRawIso
()
log
.
info
(
f
"[WRITE] Prepared response for {filename}, data: {response.hex() if isinstance(response, bytes) else response}"
)
end_time
=
time
.
time
()
elapsed
=
end_time
-
start_time
log
.
info
(
f
"[PERF] Processed {filename} in {elapsed:.3f} seconds (MTI={mti})"
)
f
"[PERF] Processed {filename} {invoice_id} in {elapsed:.3f} seconds (MTI={mti})"
)
return
response
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