Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Kunto
/
backoffice
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 c92a5233
authored
Jul 22, 2019
by
Solo Group
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
vsi_pln_post
1 parent
bc16a58f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
27 deletions
src/agratek/api/merchant/views/vendor.py
src/agratek/api/merchant/views/vsi.py
src/agratek/api/merchant/views/vsi_pln_post.py
src/agratek/api/merchant/views/vsi_pulsa.py
src/agratek/api/merchant/views/vendor.py
View file @
c92a523
...
...
@@ -43,6 +43,10 @@ def produk():
def
build_request
(
typ
,
values
):
produk_id
=
values
[
'produk_id'
]
vendor_id
=
values
[
'vendor_id'
]
bill_no
=
values
[
'destination'
]
customer_id
=
'customer_id'
in
values
and
values
[
'customer_id'
]
or
None
cust_trx_id
=
'cust_trx_id'
in
values
and
values
[
'cust_trx_id'
]
or
None
vendor_product
=
PartnerProduk
.
query
()
\
.
join
(
Produk
,
PartnerProduk
.
produk_id
==
Produk
.
id
)
\
.
filter
(
PartnerProduk
.
partner_id
==
vendor_id
,
...
...
@@ -51,8 +55,9 @@ def build_request(typ, values):
return
dict
(
error
=
'Data Tidak Ditemukan'
)
modules
=
import_module
(
'.'
+
vendor_product
.
modules
,
'agratek.api.merchant.views'
)
cls_module
=
modules
.
Vendor
(
PartnerProduk
.
kode
,
values
[
'destination'
],
values
[
'trx_id'
],
vendor_id
)
cls_module
=
modules
.
Vendor
(
vendor_id
,
produk_id
,
bill_no
,
customer_id
,
cust_trx_id
)
if
typ
==
'inquiry'
:
return
cls_module
.
inquiry
()
...
...
@@ -272,26 +277,49 @@ class ViewHome(BaseView):
return
dict
(
form
=
form
,
params
=
form_params_edit
)
class
VendorClass
(
object
):
def
__init__
(
self
,
cid
,
vendor_id
):
def
__init__
(
self
,
vendor_id
,
produk_id
,
bill_no
,
customer_id
=
None
,
cust_trx_id
=
None
,
):
"""
:param cid:
merupakan customer id seperti MSN dan atu id pelanggaan
"""
self
.
settings
=
get_settings
()
self
.
cid
=
cid
self
.
vendor_id
=
vendor_id
self
.
trx_id
=
None
self
.
produk_id
=
produk_id
self
.
bill_no
=
bill_no
self
.
customer_id
=
customer_id
self
.
cust_trx_id
=
cust_trx_id
self
.
response
=
None
self
.
request
=
None
def
save_log
(
self
,
typ
):
row
=
PartnerLog
()
row
.
partner_id
=
self
.
vendor_id
row
.
trx_type
=
typ
row
.
ref_id
=
self
.
trx_id
row
.
log
=
dict
(
request
=
self
.
request
,
self
.
partner_log_id
=
None
row
=
PartnerProduk
.
query
()
\
.
filter_by
(
partner_id
=
self
.
vendor_id
,
produk_id
=
self
.
produk_id
)
.
first
()
self
.
v_produk_kd
=
row
and
row
.
kode
or
None
def
save_log
(
self
,
typ
,
row
=
None
):
if
not
row
:
row
=
PartnerLog
()
row
.
vendor_id
=
self
.
vendor_id
row
.
produk_id
=
self
.
produk_id
row
.
bill_no
=
self
.
bill_no
row
.
customer_id
=
self
.
customer_id
row
.
cust_trx_id
=
self
.
cust_trx_id
if
typ
==
'inquiry'
:
row
.
inquiry
=
dict
(
request
=
self
.
request
,
response
=
self
.
response
)
elif
typ
==
'payment'
:
row
.
inquiry
=
dict
(
request
=
self
.
request
,
response
=
self
.
response
)
elif
typ
==
'advice'
:
row
.
advice
=
dict
(
request
=
self
.
request
,
response
=
self
.
response
)
elif
typ
==
'info'
:
row
.
info
=
dict
(
request
=
self
.
request
,
response
=
self
.
response
)
flush_row
(
row
)
self
.
partner_log_id
=
row
.
id
def
get_product
(
self
):
pass
...
...
@@ -383,5 +411,29 @@ def vendor_test(request):
elif
command
==
"ADV"
:
pass
elif
modul
==
"pln"
:
tujuan
=
params
[
'idpel'
]
voucherid
=
params
[
'voucherid'
]
if
command
==
"INQ"
:
result
=
dict
(
root
=
dict
(
status
=
"SUCCESS"
,
rc
=
"0000"
,
rcm
=
"0000"
,
text
=
"[0] Cek Tagihan Sukses ke: 628523123789 "
,
refnum
=
"DB3DC0A2539419F8C50000000000000"
,
destnum
=
tujuan
,
nominal
=
5000
))
elif
command
==
"PAY"
:
result
=
dict
(
root
=
dict
(
status
=
"SUCCESS"
,
rc
=
"0000"
,
rcm
=
"0000"
,
text
=
"[0] Cek Tagihan Sukses ke: 628523123789 "
,
refnum
=
"DB3DC0A2539419F8C50000000000000"
,
destnum
=
tujuan
,
nominal
=
5000
))
elif
command
==
"ADV"
:
pass
xml
=
xmltodict
.
unparse
(
result
)
return
xml
src/agratek/api/merchant/views/vsi.py
View file @
c92a523
...
...
@@ -13,7 +13,8 @@ from .vendor import VendorClass
class
Vendor
(
VendorClass
):
def
__init__
(
self
,
produk_kd
,
cid
,
trx_id
,
vendor_id
):
def
__init__
(
self
,
vendor_id
,
produk_id
,
bill_no
,
customer_id
=
None
,
cust_trx_id
=
None
):
"""
:param produk_kd:
merupakan kode produk versi vendor
...
...
@@ -23,13 +24,12 @@ class Vendor(VendorClass):
:param cid:
merupakan customer id seperti MSN dan atu id pelanggaan
"""
VendorClass
.
__init__
(
self
,
cid
,
vendor_id
)
VendorClass
.
__init__
(
self
,
vendor_id
,
produk_id
,
bill_no
,
customer_id
,
cust_trx_id
)
settings
=
self
.
settings
self
.
mid
=
'vsi_mid'
in
settings
and
settings
[
'vsi_mid'
]
or
None
self
.
key
=
'vsi_key'
in
settings
and
settings
[
'vsi_key'
]
or
None
self
.
url
=
'vsi_url'
in
settings
and
settings
[
'vsi_url'
]
or
None
self
.
trx_id
=
trx_id
self
.
produk_kd
=
produk_kd
def
get_hc
(
self
,
tanggal
):
hash_string
=
""
.
join
([
self
.
mid
,
tanggal
,
self
.
key
])
...
...
@@ -45,7 +45,7 @@ class Vendor(VendorClass):
modul
=
modul
,
command
=
cmd
,
resp
=
'XML'
,
trxid
=
self
.
trx
_id
,
trxid
=
self
.
partner_log
_id
,
)
if
msn
:
params
[
'msn'
]
=
msn
...
...
src/agratek/api/merchant/views/vsi_pln_post.py
View file @
c92a523
...
...
@@ -13,8 +13,8 @@ from .vsi import Vendor as VendorClass
class
Vendor
(
VendorClass
):
def
__init__
(
self
,
product_kd
,
trx_id
=
None
,
cid
=
None
):
VendorClass
.
__init__
(
self
,
product_kd
,
cid
)
#
def __init__(self, product_kd, trx_id=None, cid=None):
#
VendorClass.__init__(self, product_kd, cid)
def
inquiry
(
self
):
"""
:return:
...
...
@@ -27,7 +27,6 @@ class Vendor(VendorClass):
idpel = {IDPELANGGAN}
resp = XML
trxid = {IDTRANSAKSI}
:sukses response
<?xml version="1.0"?>
<root>
...
...
@@ -75,11 +74,20 @@ class Vendor(VendorClass):
panjang maksimum 50 character.
6. resp merupakan format respon yang diinginkan (XML), secara
default jika dikosongkan maka responnya merupakan format plaintext.
"""
params
=
self
.
get_params
(
cmd
=
'INQ'
,
modul
=
'pln'
,
idpel
=
self
.
cid
)
params
=
self
.
get_params
(
cmd
=
'INQ'
,
modul
=
'pln'
)
params
[
"idpel"
]
=
self
.
bill_no
params
[
"voucherid"
]
=
self
.
v_produk_kd
self
.
request
=
params
row
=
self
.
save_log
(
'inquiry'
)
params
[
'trxid'
]
=
self
.
partner_log_id
result
=
requests
.
get
(
self
.
url
,
params
=
params
)
data
=
xmltodict
(
result
)
if
result
.
ok
:
data
=
xmltodict
.
parse
(
result
.
text
)[
"root"
]
else
:
data
=
dict
(
error
=
result
.
status_code
)
self
.
response
=
data
self
.
save_log
(
'inquiry'
,
row
)
return
data
def
payment
(
self
):
...
...
@@ -133,8 +141,17 @@ class Vendor(VendorClass):
<rcm>[88] TAGIHAN SUDAH TERBAYAR</rcm>
</root>
"""
params
=
self
.
get_params
(
cmd
=
'PAY'
,
modul
=
'pln'
,
idpel
=
self
.
cid
)
params
=
self
.
get_params
(
cmd
=
'PAY'
,
modul
=
'pln'
)
params
[
"idpel"
]
=
self
.
bill_no
params
[
"voucherid"
]
=
self
.
v_produk_kd
self
.
request
=
params
row
=
self
.
save_log
(
'payment'
)
params
[
'trxid'
]
=
self
.
partner_log_id
result
=
requests
.
get
(
self
.
url
,
params
=
params
)
data
=
xmltodict
(
result
)
if
result
.
ok
:
data
=
xmltodict
.
parse
(
result
.
text
)[
"root"
]
else
:
data
=
dict
(
error
=
result
.
status_code
)
self
.
response
=
data
self
.
save_log
(
'payment'
,
row
)
return
data
src/agratek/api/merchant/views/vsi_pulsa.py
View file @
c92a523
...
...
@@ -271,12 +271,15 @@ class Vendor(VendorClass):
params
=
self
.
get_params
(
cmd
=
'INQ'
,
modul
=
'ISI'
)
params
[
"tujuan"
]
=
self
.
cid
params
[
"voucherid"
]
=
self
.
produk_kd
self
.
request
=
params
row
=
self
.
save_log
(
'inquiry'
)
result
=
requests
.
get
(
self
.
url
,
params
=
params
)
if
result
.
ok
:
data
=
xmltodict
.
parse
(
result
.
text
)[
"root"
]
else
:
data
=
dict
(
error
=
result
.
status_code
)
self
.
save_log
(
'inquiry'
)
self
.
response
=
data
self
.
save_log
(
'inquiry'
,
row
)
return
data
def
payment
(
self
):
...
...
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