Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
iso8583
/
bjb-samsat-banten
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 cc370123
authored
Mar 31, 2019
by
Aplikasi Samsat Banten
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
http://git.opensipkd.com/iso8583/bjb-samsat-banten
2 parents
1cee63be
8b84f7c2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
29 deletions
opensipkd/iso8583/bjb/samsat/banten/doc.py
opensipkd/iso8583/bjb/samsat/banten/job.py
opensipkd/iso8583/bjb/samsat/structure.py
opensipkd/iso8583/bjb/samsat/transaction.py
opensipkd/iso8583/bjb/samsat/banten/doc.py
View file @
cc37012
import
traceback
import
json
# from opensipkd.iso8583.base.modules.network import models
import
re
from
opensipkd.iso8583.bjb.samsat.transaction
import
Transaction
from
datetime
import
datetime
import
sys
import
traceback
import
requests
from
opensipkd.iso8583.bjb.samsat.structure
import
(
INVOICE_ID
,
INVALID_NIK
,
INVOICE_PROFILE
,
INQUIRY_CODE
,
PAYMENT_CODE
,
RC_OK
,
RC_NOT_AVAILABLE
,
RC_ALREADY_PAID
,
RC_INVALID_NIK
,
RC_INVALID_NUMBER
,
RC_EXPIRE
,
RC_DUPLIKASI_TGL_AKHIR_PAJAK
,
...
...
@@ -20,11 +18,9 @@ from opensipkd.iso8583.bjb.samsat.structure import (
ERR_INVALID_NUMBER_2
,
ERR_NOT_AVAILABLE
,
ERR_ALREADY_PAID
,
ERR_INVALID_CHANNEL
,
ERR_INQUIRY_TIMEOUT
,
ERR_PAYMENT_TIMEOUT
,
ERR_PAYMENT_FAILED
,
ERR_OTHER
,
ERR_PAYMENT_NOT_FOUND
,
ERR_REVERSAL_DONE
,
ERR_REVERSAL_TIMEOUT
,
...
...
@@ -36,12 +32,9 @@ from opensipkd.iso8583.bjb.samsat.structure import (
ERR_EXPIRE
,
ERR_DUPLIKASI_TGL_AKHIR_PAJAK
,
)
from
opensipkd.iso8583.bjb.samsat.transaction
import
Transaction
from
opensipkd.string
import
FixLength
import
sys
import
json
import
requests
from
opensipkd.jsonrpc
import
get_random_number
# todo: harusnya diimport daro opensipkd.tools.rpc
from
..api
import
get_header
,
get_jsonrpc
...
...
@@ -50,27 +43,17 @@ if sys.version < '3':
else
:
from
io
import
StringIO
CODE_54
=
[
'05'
,
'23'
]
CODE_55
=
[
'01'
,
'02'
,
'03'
,
'04'
,
'06'
,
'09'
,
'10'
,
'11'
,
'12'
,
'15'
,
'99'
,
'24'
,
'22'
]
def
date2str
(
d
):
return
d
and
d
.
strftime
(
'
%
Y
%
m
%
d'
)
or
None
class
Doc
(
Transaction
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
conf
=
kwargs
[
"conf"
]
self
.
mod_conf
=
dict
()
for
key
in
self
.
conf
[
'module_conf'
]:
if
key
.
find
(
'samsat_banten_'
)
<
0
:
continue
name
=
key
[
14
:]
self
.
mod_conf
[
name
]
=
self
.
conf
[
'module_conf'
][
key
]
del
kwargs
[
"conf"
]
self
.
invoice_id
=
FixLength
(
INVOICE_ID
)
self
.
invalid_nik
=
FixLength
(
INVALID_NIK
)
self
.
invoice_profile
=
FixLength
(
self
.
get_invoice_profile_definition
())
...
...
@@ -80,6 +63,8 @@ class Doc(Transaction):
if
not
self
.
mod_conf
:
raise
ValueError
(
"Perbaiki konfigurasi"
)
self
.
invoice_id_raw
=
None
def
get_channel
(
self
):
return
self
.
get_channel_id
()
...
...
@@ -102,7 +87,6 @@ class Doc(Transaction):
self
.
log_info
(
"RESPONSE {}"
.
format
(
rows
))
return
rows
# @staticmethod
def
get_invoice_profile_definition
(
self
):
return
INVOICE_PROFILE
...
...
@@ -125,7 +109,6 @@ class Doc(Transaction):
self
.
setMTI
(
'0200'
)
self
.
set_stan
()
def
inquiry_response_
(
self
):
if
not
self
.
is_allowed
():
return
self
.
ack_not_allowed
()
...
...
@@ -292,6 +275,12 @@ class Doc(Transaction):
###########
# Payment #
###########
def
payment_request
(
self
,
data
):
for
p
in
data
:
self
.
setBit
(
int
(
p
),
data
[
p
])
self
.
setMTI
(
'0200'
)
self
.
set_stan
()
def
payment_response
(
self
):
self
.
payment_response_
()
...
...
opensipkd/iso8583/bjb/samsat/banten/job.py
View file @
cc37012
...
...
@@ -18,3 +18,9 @@ class Job(NetworkJob):
iso
=
self
.
create_iso
()
iso
.
inquiry_request
(
p
[
'data'
])
return
iso
def
payment
(
self
,
p
):
self
.
echo_time
=
time
()
iso
=
self
.
create_iso
()
iso
.
payment_request
(
p
[
'data'
])
return
iso
opensipkd/iso8583/bjb/samsat/structure.py
View file @
cc37012
...
...
@@ -123,3 +123,11 @@ INVOICE_PROFILE = [
(
'Keterangan'
,
90
,
'A'
),
(
'Kode Wilayah'
,
5
,
'A'
),
]
ERR_INVALID_NUMBER
=
'Invoice ID {invoice_id} tidak benar'
ERR_INVALID_BANK
=
'Bank ID {id} tidak diperkenankan'
ERR_SETTLEMENT_DATE
=
'Settlement date {raw} tidak benar'
ERR_TRANSACTION_DATETIME
=
'Transaction datetime {raw} tidak benar'
ERR_TRANSACTION_DATE
=
'Transaction date {raw} tidak benar'
ERR_TRANSACTION_TIME
=
'Transaction time {raw} tidak benar'
\ No newline at end of file
opensipkd/iso8583/bjb/samsat/transaction.py
View file @
cc37012
...
...
@@ -2,7 +2,7 @@ from datetime import datetime
from
ISO8583.ISOErrors
import
BitNotSet
from
opensipkd.string
import
(
DateTimeVar
,
DateVar
,
DateVar
,
TimeVar
,
exception_message
,
)
...
...
@@ -17,7 +17,18 @@ from .structure import (
ERR_TRANSACTION_DATE
,
ERR_SETTLEMENT_DATE
,
ERR_OTHER
,
ERR_TRANSACTION_DATETIME
,
RC_INVALID_NUMBER
,
ERR_SETTLEMENT_DATE
,
ERR_TRANSACTION_DATETIME
,
ERR_TRANSACTION_DATE
,
ERR_INVALID_BANK
,
ERR_INVALID_NUMBER
,
ERR_TRANSACTION_TIME
,
)
from
opensipkd.waktu
import
create_datetime
from
iso8583_web.scripts.forwarder
import
Log
...
...
@@ -34,10 +45,21 @@ CHANNEL_NAMES = {
class
Transaction
(
BaseTransaction
,
Log
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
conf
=
kwargs
[
"conf"
]
self
.
mod_conf
=
dict
()
for
key
in
self
.
conf
[
'module_conf'
]:
if
key
.
find
(
'samsat_banten_'
)
<
0
:
continue
name
=
key
[
14
:]
self
.
mod_conf
[
name
]
=
self
.
conf
[
'module_conf'
][
key
]
del
kwargs
[
"conf"
]
BaseTransaction
.
__init__
(
self
,
*
args
,
**
kwargs
)
self
.
transmission_datetime
=
DateTimeVar
()
self
.
transaction_date
=
DateVar
()
self
.
settlement_date
=
DateVar
()
self
.
transaction_time
=
TimeVar
()
self
.
transaction_datetime
=
DateTimeVar
()
# Override
def
get_bit_definition
(
self
):
...
...
@@ -100,7 +122,7 @@ class Transaction(BaseTransaction, Log):
return
code
=
self
.
get_transaction_code
()
return
code
in
(
PAYMENT_CODE
,
REPRINT1_CODE
,
REPRINT2_CODE
)
and
\
'payment_response'
'payment_response'
def
is_reprint
(
self
):
return
self
.
get_transaction_code
()
in
(
REPRINT1_CODE
,
REPRINT2_CODE
)
...
...
@@ -141,6 +163,42 @@ class Transaction(BaseTransaction, Log):
msg
=
ERR_SETTLEMENT_DATE
.
format
(
d
=
raw
)
self
.
ack_other
(
msg
)
def
get_transaction_date_raw
(
self
):
return
self
.
get_value
(
13
)
def
get_transaction_datetime_raw
(
self
):
return
self
.
get_transaction_date_raw
()
+
self
.
get_transaction_time_raw
()
def
get_transaction_datetime
(
self
):
raw
=
self
.
get_transaction_datetime_raw
()
self
.
transaction_datetime
.
set_raw
(
raw
)
try
:
return
self
.
transaction_datetime
.
get_value
()
except
ValueError
:
self
.
ack_transaction_datetime
()
def
get_transaction_time_raw
(
self
):
return
self
.
get_value
(
12
)
def
get_transaction_time
(
self
):
raw
=
self
.
get_transaction_time_raw
()
self
.
transaction_time
.
set_raw
(
raw
)
try
:
return
self
.
transaction_time
.
get_value
()
except
ValueError
:
self
.
ack_transaction_time
()
def
ack_transaction_datetime
(
self
):
raw
=
self
.
get_transaction_datetime_raw
()
msg
=
ERR_TRANSACTION_DATETIME
.
format
(
raw
=
[
raw
])
self
.
ack_other
(
msg
)
def
ack_transaction_time
(
self
):
raw
=
self
.
get_transaction_time_raw
()
msg
=
ERR_TRANSACTION_TIME
.
format
(
raw
=
[
raw
])
self
.
ack_other
(
msg
)
@staticmethod
def
get_bit_invoice_profile
(
self
):
return
61
...
...
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