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 47bda1d4
authored
Aug 05, 2019
by
Solo Group
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
VSI
1 parent
d4d5fc90
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
54 deletions
src/agratek/api/merchant/views/odeo/__init__.py
src/agratek/api/merchant/views/vendor.py
src/agratek/api/merchant/views/vsi/pulsa.py
src/agratek/api/merchant/views/odeo/__init__.py
View file @
47bda1d
...
...
@@ -117,22 +117,6 @@ class Vendor(VendorClass):
# status="PENDING"))
# return self.set_response(data=parsd, typ="payment")
def
get_price
(
self
):
product_id
=
self
.
invoice_det
.
produk
.
id
if
hasattr
(
self
.
invoice_det
,
"customer_id"
):
partner_id
=
self
.
invoice_det
.
customer_id
else
:
partner_id
=
self
.
invoice_det
.
h2h_ar_invoice
.
customer_id
harga
=
self
.
vendor_produk
.
produk
.
harga
self
.
discount
=
PartnerProduk
.
get_discount
(
partner_id
,
product_id
)
self
.
amt_sell
=
harga
-
self
.
discount
return
dict
(
subtotal
=
int
(
harga
),
discount
=
int
(
self
.
discount
),
total
=
int
(
self
.
amt_sell
)
)
def
payment
(
self
):
params
=
dict
(
data
=
dict
(
...
...
src/agratek/api/merchant/views/vendor.py
View file @
47bda1d
...
...
@@ -102,6 +102,22 @@ class VendorClass(object):
)
return
self
.
set_response
(
data
,
typ
=
typ
)
def
get_price
(
self
):
product_id
=
self
.
invoice_det
.
produk
.
id
if
hasattr
(
self
.
invoice_det
,
"customer_id"
):
partner_id
=
self
.
invoice_det
.
customer_id
else
:
partner_id
=
self
.
invoice_det
.
h2h_ar_invoice
.
customer_id
harga
=
self
.
vendor_produk
.
produk
.
harga
self
.
discount
=
PartnerProduk
.
get_discount
(
partner_id
,
product_id
)
self
.
amt_sell
=
harga
-
self
.
discount
return
dict
(
subtotal
=
int
(
harga
),
discount
=
int
(
self
.
discount
),
total
=
int
(
self
.
amt_sell
)
)
def
save_log
(
self
,
typ
):
# if not self.partner_log:
# row = self.partner_log or PartnerLog()
...
...
src/agratek/api/merchant/views/vsi/pulsa.py
View file @
47bda1d
...
...
@@ -24,7 +24,7 @@ class Vendor(VendorClass):
:return:
"""
code
=
"rc"
in
data
and
int
(
data
[
"rc"
])
or
0
self
.
status
=
vsi_status
[
str
(
code
)][
"status"
]
self
.
status
=
code
and
vsi_status
[
str
(
code
)][
"status"
]
or
1
status
=
self
.
status
==
-
3
and
"FAILED"
or
"PENDING"
if
status
==
"PENDING"
:
code
=
68
...
...
@@ -55,58 +55,58 @@ class Vendor(VendorClass):
)
return
result
def
inquiry
(
self
):
params
=
self
.
get_params
(
cmd
=
'INQ'
,
modul
=
'ISI'
)
params
[
"tujuan"
]
=
self
.
id_pel
params
[
"voucherid"
]
=
self
.
vendor_produk
.
kode
self
.
request
=
params
self
.
save_log
(
'inquiry'
)
log
.
info
(
"Request:
%
s
%
s"
%
(
self
.
url
,
self
.
request
))
try
:
result
=
requests
.
get
(
self
.
url
,
params
=
params
,
timeout
=
15
)
if
result
.
ok
:
data
=
dict
(
xmltodict
.
parse
(
result
.
text
)[
"root"
])
else
:
data
=
dict
(
code
=
result
.
status_code
,
message
=
result
.
text
)
self
.
response
=
data
log
.
info
(
"Response:
%
s"
%
(
data
))
except
requests
.
exceptions
.
RequestException
as
e
:
data
=
dict
(
code
=
e
.
errno
,
message
=
e
.
strerror
)
self
.
result
=
self
.
pars_data
(
data
)
log
.
info
(
"Result:
%
s"
%
(
self
.
result
))
self
.
save_log
(
'inquiry'
)
return
self
.
result
#
def inquiry(self):
#
params = self.get_params(cmd='INQ', modul='ISI')
#
params["tujuan"] = self.id_pel
#
params["voucherid"] = self.vendor_produk.kode
#
self.request = params
#
self.save_log('inquiry')
#
log.info("Request: %s %s" % (self.url, self.request))
#
try:
#
result = requests.get(self.url, params=params, timeout=15)
#
if result.ok:
#
data = dict(xmltodict.parse(result.text)["root"])
#
else:
#
data = dict(code=result.status_code,
#
message=result.text)
#
self.response = data
#
log.info("Response: %s" % (data))
#
#
except requests.exceptions.RequestException as e:
#
data = dict(code=e.errno,
#
message=e.strerror)
#
#
self.result = self.pars_data(data)
#
log.info("Result: %s" % (self.result))
#
self.save_log('inquiry')
#
return self.result
#
def
payment
(
self
):
params
=
self
.
get_params
(
cmd
=
'PAY'
,
modul
=
'ISI'
)
params
[
"tujuan"
]
=
self
.
id_pel
params
[
"voucherid"
]
=
self
.
vendor_produk
.
kode
self
.
request
=
params
log
.
info
(
"Payment Request:
%
s"
%
(
params
))
data
=
self
.
get_price
()
try
:
result
=
requests
.
get
(
self
.
url
,
params
=
params
,
timeout
=
15
)
if
result
.
ok
:
data
=
dict
(
xmltodict
.
parse
(
result
.
text
)[
"root"
])
self
.
response
=
dict
(
xmltodict
.
parse
(
result
.
text
)[
"root"
])
log
.
info
(
"Payment Response:
%
s"
%
(
self
.
response
))
else
:
data
=
dict
(
code
=
result
.
status_code
,
message
=
result
.
text
)
self
.
response
=
data
log
.
info
(
"Payment Response:
%
s"
%
(
data
)
)
self
.
status
=
0
self
.
response
=
dict
(
code
=
result
.
status_code
,
message
=
result
.
text
)
log
.
info
(
"Payment Response:
%
s"
%
(
self
.
response
))
return
self
.
set_pending
(
data
,
message
=
result
.
text
)
except
requests
.
exceptions
.
RequestException
as
e
:
data
=
dict
(
code
=
e
.
errno
,
message
=
e
.
strerror
)
self
.
status
=
0
return
self
.
set_pending
(
data
,
message
=
e
.
strerror
)
self
.
amt_buy
=
"harga"
in
data
and
data
[
"harga"
]
or
self
.
amt_buy
self
.
vend_inv_no
=
"ref_num"
in
data
and
data
[
"ref_num"
]
or
self
.
vend_inv_no
self
.
result
=
self
.
pars_data
(
data
)
log
.
info
(
"Payment Result:
%
s"
%
(
self
.
result
))
self
.
save_log
(
'payment'
)
return
data
data
=
self
.
pars_data
(
self
.
response
)
return
self
.
set_success
(
data
)
def
advice
(
self
):
params
=
self
.
get_params
(
cmd
=
'ADV'
,
modul
=
'ISI'
)
...
...
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