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 751094a2
authored
Sep 07, 2020
by
aa.gusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add struture sambat
1 parent
ebdba6d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
300 additions
and
0 deletions
iso8583_web/scripts/views/sambat/structure.py
iso8583_web/scripts/views/sambat/structure.py
0 → 100644
View file @
751094a
# import colander
# from opensipkd.string.row import Row
# from .exceptions import InternalError
from
iso8583_web.scripts.logger
import
(
log_web_info
,
log_web_debug
)
import
requests
from
iso8583_web.scripts.views.linkaja
import
get_db_session
,
AlreadyPaidError
,
BillRefNotFound
,
BaseError
from
iso8583_web.scripts.views.linkaja.models
import
LogSam
from
iso8583_web.tools.this_framework
import
get_settings
from
datetime
import
datetime
import
requests
INQ_REQ
=
{
"primaryAccountNumber"
:
"622011888888888888"
,
"processingCode"
:
"321000"
,
"amountTransaction"
:
""
,
"settlementDate"
:
"0326"
,
"merchantType"
:
"6015"
,
"aggregatorCode"
:
"W0216"
,
"caCode"
:
"CA1830"
,
"terminalAggregator"
:
{
"terminalIdentifierNumber"
:
"7782"
,
"terminalName"
:
"BJBSAM"
,
"cardAcceptorName"
:
"BJBSAM"
},
"currencyCode"
:
"360"
,
"amountInformation"
:
{
"billAmount"
:
""
,
"feeBJB"
:
""
,
"feeAggregator"
:
""
,
"totalAmount"
:
""
},
"pay"
:
"PAY"
,
"featureCode"
:
"009"
,
"billInformation"
:
{
"bills"
:
[{
"info"
:
"1000000108767"
}
]
},
"sourceAccountNumber"
:
"10023269392100"
,
"destinationAccountNumber"
:
"1"
,
"systemTraceAuditNumber"
:
""
,
"additionalData"
:
""
,
"timeLocalTransaction"
:
"090210"
,
"localTransactionDate"
:
"0326"
,
"transmissionDateTime"
:
"0903173122"
,
"posEntryModeCode"
:
"110"
,
"track2Data"
:
"622011888888888888=9912?"
,
"sequenceNumber"
:
"1"
}
PAY_REQ
=
\
{
"processingCode"
:
"521000"
,
"sequenceNumber"
:
""
,
"sourceAccountNumber"
:
"0098889231001"
,
"systemTraceAuditNumber"
:
""
,
"terminalAggregator"
:
{
"cardAcceptorName"
:
"NAEE "
,
"terminalIdentifierNumber"
:
"1 "
,
"terminalName"
:
"TERM "
},
"settlementDate"
:
"0326"
,
"timeLocalTransaction"
:
"090210"
,
"track2Data"
:
"622011888888888888=9912?"
,
"transmissionDateTime"
:
"0107180458"
}
def
send_data
(
json_data
):
settings
=
get_settings
()
pload
=
{
'username'
:
'olivia'
,
'password'
:
'123'
}
bjb_sambat_url
=
"bjb_sambat_url"
in
settings
and
settings
[
"bjb_sambat_url"
]
or
\
"http://localhost:7001/bjb/sambat/test"
data
=
json_data
# todo butuh server buat testing json sementara pake static response
if
json_data
[
"processingCode"
]
==
'321000'
:
return
INQ_RESP
elif
json_data
[
"processingCode"
]
==
'521000'
:
return
PAY_RESP
r
=
requests
.
post
(
bjb_sambat_url
,
data
=
data
)
if
r
.
text
:
try
:
return
r
.
json
()
except
:
log_web_info
(
r
.
text
)
raise
BaseError
return
class
Transaksi
(
object
):
def
__init__
(
self
,
p
,
method
,
inq
,
pay
):
self
.
settings
=
get_settings
()
self
.
response
=
None
if
method
==
"reversal"
:
# data Payment ada (berarti reversal)
self
.
mti
=
"0400"
self
.
data
[
"processingCode"
]
=
"521000"
elif
method
==
"payment"
:
# data Inq ada (berarti payment)
db_session
=
get_db_session
()
pay
=
db_session
.
query
(
LogSam
)
.
filter_by
(
rpc_id
=
inq
.
id
,
mti
=
"0200"
,
bit_003
=
'521000'
)
.
first
()
if
pay
:
pay
=
db_session
.
query
(
LogSam
)
.
filter_by
(
rpc_id
=
inq
.
id
,
mti
=
"0210"
,
bit_003
=
'521000'
)
.
first
()
if
pay
:
raise
AlreadyPaidError
()
inq
=
db_session
.
query
(
LogSam
)
.
filter_by
(
rpc_id
=
inq
.
id
,
mti
=
"0200"
,
bit_003
=
'321000'
)
.
first
()
if
not
inq
:
raise
BillRefNotFound
()
self
.
mti
=
"0200"
self
.
data
=
inq
.
message
self
.
data
[
"processingCode"
]
=
"521000"
self
.
set_local_time
()
else
:
self
.
mti
=
"0200"
self
.
data
=
INQ_REQ
.
copy
()
self
.
data
[
"caCode"
]
=
"ca_code"
in
self
.
settings
and
self
.
settings
[
"ca_code"
]
or
"1234"
self
.
data
[
"processingCode"
]
=
"321000"
self
.
data
[
"billInformation"
][
"bills"
][
0
][
"info"
]
=
p
[
"invoice_id"
]
self
.
set_local_time
()
def
set_local_time
(
self
):
time
=
datetime
.
now
()
self
.
data
[
"timeLocalTransaction"
]
=
time
.
strftime
(
"
%
HHmiss"
)
self
.
data
[
"localTransactionDate"
]
=
time
.
strftime
(
"
%
MMDD"
)
self
.
data
[
"transmissionDateTime"
]
=
time
.
strftime
(
"
%
MMDDHHmiss"
)
def
get_stan
(
self
):
return
self
.
data
[
"systemTraceAuditNumber"
]
def
send
(
self
):
self
.
response
=
send_data
(
self
.
data
)
self
.
mti
=
self
.
mti
==
"0200"
and
"0210"
or
"0410"
INVOICE_PROFILE
=
[
(
"NOMOR BAYAR"
,
16
,
"N"
),
(
"NOMOR RANGKA"
,
25
),
(
"NOMOR MESIN"
,
25
),
(
"NOMOR IDENTITAS"
,
18
,
"N"
),
(
"NAMA PEMILIK"
,
25
),
(
"ALAMAT PEMILIK"
,
40
),
(
"NOMOR POLISI"
,
9
),
(
"WARNA PLAT"
,
6
),
(
"MILIK KE"
,
3
,
"N"
),
(
"NAMA JENIS KB"
,
15
),
(
"NAMA MEREK KB"
,
15
),
(
"NAMA MODEL KB"
,
30
),
(
"TAHUN BUATAN"
,
4
,
"N"
),
(
"TGL AKHIR PAJAK LAMA"
,
8
,
"N"
),
(
"TGL AKHIR PAJAK BARU"
,
8
,
"N"
),
(
"POKOK BBN"
,
12
,
"N"
),
(
"DENDA BBN"
,
12
,
"N"
),
(
"POKOK PKB"
,
12
,
"N"
),
(
"DENDA PKB"
,
12
,
"N"
),
(
"POKOK SWD"
,
12
,
"N"
),
(
"DENDA SWD"
,
12
,
"N"
),
(
"POKOK ADM"
,
12
,
"N"
),
# ("STNK POKOK", 12, "N"),
(
"ADM TNKB"
,
12
,
"N"
),
(
"JUMLAH"
,
12
,
"N"
),
(
"KETERANGAN"
,
90
),
(
"RESERVED_01"
,
5
)
]
INQ_RESP
=
\
{
"additionalData"
:
"361198483250691012345678901234564 54P879211 3603110611710004 TUMINO NUANSA MEKARSARI B - 1 / 15 RT 004/006 KA 3538 XCBIRU 001SEPEDA MOTOR R2YAMAHA 54P (CAST WHEEL) AT 20132020090920210909000000000000000000000000000000154000000000000000000000035000000000000000000000000000000000000000000000189000SUKSES 01"
,
"aggregatorCode"
:
"W0216"
,
"amountInformation"
:
{
"billAmount"
:
"890000"
,
"feeAggregator"
:
"0"
,
"feeBJB"
:
"0"
,
"totalAmount"
:
"890000"
},
"amountTransaction"
:
"890000"
,
"billInformation"
:
{
"bills"
:
[
{
"info"
:
"1000000108767"
},
{
"info"
:
"ALBUS DUMBLEDORE"
},
{
"info"
:
"BLACK MAGIC"
},
{
"info"
:
"BLACK MAGIC 101"
},
{
"info"
:
"890000"
},
{
"info"
:
"0"
},
{
"info"
:
"2019"
},
{
"info"
:
"0"
},
{
"info"
:
" "
},
{
"info"
:
" REG"
},
{
"info"
:
" "
}
]
},
"caCode"
:
"CA1830"
,
"currencyCode"
:
"360"
,
"destinationAccountNumber"
:
"0012199936360 "
,
"featureCode"
:
"009"
,
"localTransactionDate"
:
"0326"
,
"merchantType"
:
"6015"
,
"pay"
:
"PAY"
,
"posEntryModeCode"
:
"110"
,
"primaryAccountNumber"
:
"622011888888888888"
,
"processingCode"
:
"321000"
,
"responseCode"
:
"00"
,
"sequenceNumber"
:
"000000880977"
,
"settlementDate"
:
"0326"
,
"sourceAccountNumber"
:
"0098889231001"
,
"systemTraceAuditNumber"
:
"880977"
,
"terminalAggregator"
:
{
"cardAcceptorName"
:
"NAEE "
,
"terminalIdentifierNumber"
:
"1 "
,
"terminalName"
:
"TERM "
},
"timeLocalTransaction"
:
"090210"
,
"track2Data"
:
"622011888888888888=9912?"
,
"transmissionDateTime"
:
"0107180458"
}
# PAYMENT
PAY_RESP
=
\
{
"additionalData"
:
"'361198483250691012345678901234564 54P879211 3603110611710004 TUMINO NUANSA MEKARSARI B - 1 / 15 RT 004/006 KA 3538 XCBIRU 001SEPEDA MOTOR R2YAMAHA 54P (CAST WHEEL) AT 20132020090920210909000000000000000000000000000000154000000000000000000000035000000000000000000000000000000000000000000000189000SUKSES 01"
,
"aggregatorCode"
:
"W0216"
,
"amountInformation"
:
{
"billAmount"
:
"206500"
,
"feeAggregator"
:
"0"
,
"feeBJB"
:
"0"
,
"totalAmount"
:
"206500"
},
"amountTransaction"
:
"000000890000"
,
"billInformation"
:
{
"bills"
:
[{
"info"
:
"1000000108767"
},
{
"info"
:
"ALBUS DUMBLEDORE"
},
{
"info"
:
"BLACK MAGIC"
},
{
"info"
:
"BLACK MAGIC 101"
},
{
"info"
:
"890000"
},
{
"info"
:
"0"
},
{
"info"
:
"2019"
},
{
"info"
:
"0"
},
{
"info"
:
" "
},
{
"info"
:
" REG"
},
{
"info"
:
" "
}
]
},
"caCode"
:
"CA1830"
,
"currencyCode"
:
"360"
,
"destinationAccountNumber"
:
"0012199936360 "
,
"featureCode"
:
"009"
,
"localTransactionDate"
:
"0326"
,
"merchantType"
:
"6015"
,
"numberTransactionBank"
:
'1234567890'
,
"numberTransactionP"
:
'0987654321'
,
"pay"
:
"PAY"
,
"posEntryModeCode"
:
"110"
,
"primaryAccountNumber"
:
"622011888888888888"
,
"processingCode"
:
"521000"
,
"responseCode"
:
"00"
,
"sequenceNumber"
:
"000000502959"
,
"settlementDate"
:
"0326"
,
"sourceAccountNumber"
:
"0098889231001"
,
"systemTraceAuditNumber"
:
"502959"
,
"terminalAggregator"
:
{
"cardAcceptorName"
:
"NAEE "
,
"terminalIdentifierNumber"
:
"1 "
,
"terminalName"
:
"TERM "
},
"timeLocalTransaction"
:
"090210"
,
"track2Data"
:
"622011888888888888=9912?"
,
"transmissionDateTime"
:
"0107180458"
}
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