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 8dab2fbb
authored
Jul 31, 2019
by
Solo Group
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
response payment
1 parent
828f31b3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
95 deletions
src/agratek/api/merchant/views/merchan.py
src/agratek/api/merchant/views/odeo.py
src/agratek/api/merchant/views/vendor.py
src/agratek/api/merchant/views/merchan.py
View file @
8dab2fb
...
@@ -226,6 +226,9 @@ def purchase(request, data, **kwargs):
...
@@ -226,6 +226,9 @@ def purchase(request, data, **kwargs):
result
=
build_purchase
(
vendor_produk
,
ar_invoice_det
)
result
=
build_purchase
(
vendor_produk
,
ar_invoice_det
)
total
=
"total"
in
result
and
result
[
"total"
]
or
0
total
=
"total"
in
result
and
result
[
"total"
]
or
0
prod
.
update
(
result
)
prod
.
update
(
result
)
# Perhitungan Total
# Jika harga jual lebih besar dari harga beli jual dipakai harga jual
# jika harga lebih kecil dari harga beli maka harga beli ditambah admin_fee
if
total
:
if
total
:
if
vendor_produk
.
produk
.
harga
<
total
:
if
vendor_produk
.
produk
.
harga
<
total
:
total
+=
vendor_produk
.
produk
.
harga
total
+=
vendor_produk
.
produk
.
harga
...
@@ -233,18 +236,6 @@ def purchase(request, data, **kwargs):
...
@@ -233,18 +236,6 @@ def purchase(request, data, **kwargs):
total
=
vendor_produk
.
produk
.
harga
total
=
vendor_produk
.
produk
.
harga
prod
.
update
(
dict
(
total
=
total
))
prod
.
update
(
dict
(
total
=
total
))
# ar_invoice_det.status = 'status' in result and result["status"] or 'FAILED'
# if result["code"] == 9:
# ar_invoice_det.amt_buy = result["response"].total
# discount = 0
# prod.update(
# dict(
# subtotal=ar_invoice_det.amt_sell,
# discount=discount,
# total=ar_invoice_det.amt_sell + discount
# )
# )
# prod.update(status=result["status"])
r_prod
.
append
(
prod
)
r_prod
.
append
(
prod
)
ar_invoice
.
payment
[
"response"
]
=
r_prod
ar_invoice
.
payment
[
"response"
]
=
r_prod
...
...
src/agratek/api/merchant/views/odeo.py
View file @
8dab2fb
...
@@ -8,6 +8,7 @@ from .vendor import VendorClass
...
@@ -8,6 +8,7 @@ from .vendor import VendorClass
from
..tools
import
log
from
..tools
import
log
import
urllib3
import
urllib3
urllib3
.
disable_warnings
()
urllib3
.
disable_warnings
()
...
@@ -22,7 +23,6 @@ class Vendor(VendorClass):
...
@@ -22,7 +23,6 @@ class Vendor(VendorClass):
key
=
":"
.
join
([
self
.
mid
,
self
.
key
])
.
encode
()
key
=
":"
.
join
([
self
.
mid
,
self
.
key
])
.
encode
()
self
.
auth
=
base64
.
b64encode
(
key
)
.
decode
()
self
.
auth
=
base64
.
b64encode
(
key
)
.
decode
()
def
request_post
(
self
,
params
,
url
=
None
):
def
request_post
(
self
,
params
,
url
=
None
):
headers
=
{
'Authorization'
:
'Bearer {key}'
.
format
(
key
=
self
.
auth
)}
headers
=
{
'Authorization'
:
'Bearer {key}'
.
format
(
key
=
self
.
auth
)}
data
=
json
.
dumps
(
params
)
data
=
json
.
dumps
(
params
)
...
@@ -45,9 +45,9 @@ class Vendor(VendorClass):
...
@@ -45,9 +45,9 @@ class Vendor(VendorClass):
return
dict
(
code
=
9999
,
return
dict
(
code
=
9999
,
message
=
'Parameter tidak lengkap'
)
message
=
'Parameter tidak lengkap'
)
if
self
.
v_produk_kd
[:
3
]
==
'PLN'
and
self
.
v_produk_kd
!=
'PLNPASCA'
:
if
self
.
v_produk_kd
[:
3
]
==
'PLN'
and
self
.
v_produk_kd
!=
'PLNPASCA'
:
params
=
dict
(
params
=
dict
(
number
=
self
.
id_pel
number
=
self
.
id_pel
)
)
self
.
request
=
params
self
.
request
=
params
...
@@ -90,11 +90,24 @@ class Vendor(VendorClass):
...
@@ -90,11 +90,24 @@ class Vendor(VendorClass):
message
=
"Other Error"
)
message
=
"Other Error"
)
self
.
response
=
result
self
.
response
=
result
# self.save_log('inquiry')
self
.
result
=
parsd
self
.
save_log
(
'inquiry'
)
return
parsd
def
gagal_transaksi
(
self
):
self
.
status
=
-
2
parsd
=
dict
(
status
=
"FAILED"
,
code
=-
2
,
message
=
"Gagal Transaksi"
)
self
.
result
=
parsd
self
.
save_log
(
'payment'
)
return
parsd
return
parsd
def
payment
(
self
):
def
payment
(
self
):
params
=
dict
(
data
=
dict
(
params
=
dict
(
data
=
dict
(
denom
=
self
.
v_produk_kd
,
denom
=
self
.
v_produk_kd
,
number
=
self
.
id_pel
number
=
self
.
id_pel
)
)
...
@@ -105,59 +118,54 @@ class Vendor(VendorClass):
...
@@ -105,59 +118,54 @@ class Vendor(VendorClass):
resp
=
self
.
request_post
(
params
,
'/prepaid/purchase'
)
resp
=
self
.
request_post
(
params
,
'/prepaid/purchase'
)
try
:
try
:
result
=
json
.
loads
(
resp
.
text
)
result
=
json
.
loads
(
resp
.
text
)
success
=
True
except
:
except
:
result
=
resp
.
text
result
=
resp
.
text
success
=
False
self
.
response
=
result
self
.
response
=
result
log
.
info
(
"ODEO Payment Response:
%
s"
%
self
.
response
)
log
.
info
(
"ODEO Payment Response:
%
s"
%
self
.
response
)
if
resp
.
ok
:
# odeo mengembalikan result dalam bentuk status
# self.status = 1 # sukses
# 0200 ok
if
success
:
# 0400 bad request
#result["code"] = 0
# 0401 auth error
#if result["status"]=="SUCCESS":
parsd
=
{}
# self.status = 1
if
resp
.
status_code
==
200
:
# 0200
data
=
"data"
in
result
and
result
[
"data"
]
or
None
#elif result["status"]=="PENDING":
# cel rc status
# self.status = -1
if
not
data
:
#elif result["status"]=="GAGAL":
return
self
.
gagal_transaksi
()
# self.status = -2
if
"rc"
in
data
:
data
=
"data"
in
result
and
result
[
"data"
]
or
None
parsd
[
"code"
]
=
int
(
data
[
"rc"
])
if
data
:
self
.
vend_inv_no
=
"order_id"
in
data
and
data
[
"order_id"
]
or
None
if
data
[
"rc"
]
==
"13"
:
self
.
amt_buy
=
"price"
in
data
and
data
[
"price"
]
or
0
parsd
[
"status"
]
=
"FAILED"
parsd
=
self
.
pars_data
(
data
)
self
.
status
=
-
2
elif
data
[
"rc"
]
==
"68"
:
parsd
[
"status"
]
=
"PENDING"
self
.
status
=
-
1
# pending
elif
data
[
"rc"
]
==
"67"
:
parsd
[
"status"
]
=
"DOUBLE"
self
.
status
=
-
2
# Gagal Karena Pernah Transaksi
# Status ini hanya sementara nunggu refund
# Status -2 ini harus dicari solusi mencari vendor lain
else
:
else
:
# parsd = self.pars_data(data)
self
.
status
=
1
# if not parsd:
parsd
[
"code"
]
=
0
self
.
status
=
-
4
parsd
[
"status"
]
=
"SUCCESS"
parsd
=
dict
(
code
=
500
,
self
.
serial_number
=
'serial_number'
in
data
and
data
[
"serial_numner"
]
\
message
=
"Other Error"
,
or
self
.
serial_number
status
=
"FAILED"
)
self
.
vend_inv_no
=
"order_id"
in
data
and
data
[
"order_id"
]
or
None
self
.
amt_buy
=
"price"
in
data
and
data
[
"price"
]
or
0
elif
resp
.
status_code
==
400
:
# BAD REQUEST
parsd
[
"total"
]
=
self
.
amt_buy
self
.
status
=
-
3
self
.
result
=
parsd
parsd
=
dict
(
code
=
resp
.
status_code
,
self
.
save_log
(
'payment'
)
message
=
result
,
return
parsd
status
=
"FAILED"
)
else
:
self
.
status
=
-
4
# Other Error
parsd
=
dict
(
code
=
500
,
message
=
"Other Error"
,
status
=
"FAILED"
)
#if 'ref_no' in parsd:
else
:
# BAD REQUEST
# self.vend_inv_no = parsd["ref_no"]
return
self
.
gagal_transaksi
()
self
.
save_log
(
'payment'
)
#txt = "ODEO PARSING: {d}".format(d=json.dumps(parsd))
#log.info(txt)
return
parsd
def
advice
(
self
):
def
advice
(
self
):
if
not
self
.
v_produk_kd
or
not
self
.
id_pel
or
not
self
.
invoice_det
:
if
not
self
.
v_produk_kd
or
not
self
.
id_pel
or
not
self
.
invoice_det
:
...
@@ -192,10 +200,10 @@ class Vendor(VendorClass):
...
@@ -192,10 +200,10 @@ class Vendor(VendorClass):
data
=
"data"
in
result
and
result
[
"data"
]
or
None
data
=
"data"
in
result
and
result
[
"data"
]
or
None
parsd
=
self
.
pars_data
(
data
)
parsd
=
self
.
pars_data
(
data
)
elif
resp
.
status_code
==
400
:
elif
resp
.
status_code
==
400
:
self
.
status
=
-
3
self
.
status
=
-
3
parsd
=
dict
(
code
=
resp
.
status_code
,
parsd
=
dict
(
code
=
resp
.
status_code
,
message
=
resp
.
text
)
message
=
resp
.
text
)
else
:
else
:
self
.
status
=
-
4
self
.
status
=
-
4
parsd
=
dict
(
code
=
500
,
parsd
=
dict
(
code
=
500
,
...
@@ -207,35 +215,9 @@ class Vendor(VendorClass):
...
@@ -207,35 +215,9 @@ class Vendor(VendorClass):
def
pars_data
(
self
,
data
):
def
pars_data
(
self
,
data
):
result
=
dict
()
result
=
dict
()
# result["trx_id"] = self.partner_log_id
# result["id_pel"] = self.id_pel
# result["cust_trx"] = self.cust_trx
# result["vend_trx"] = self.vend_trx
# result['harga'] = self.amt_buy
if
not
data
:
if
not
data
:
return
result
return
result
if
"rc"
in
data
:
if
data
[
"rc"
]
==
"13"
:
result
[
"status"
]
=
"FAILED"
self
.
status
=
-
2
elif
data
[
"rc"
]
==
"68"
:
result
[
"status"
]
=
"PENDING"
self
.
status
=
0
#pending
elif
data
[
"rc"
]
==
"67"
:
result
[
"status"
]
=
"FAILED"
self
.
status
=
-
2
# Gagal Karena Pernah Transaksi
else
:
self
.
status
=
1
result
[
"code"
]
=
0
result
[
"status"
]
=
"SUCCESS"
self
.
serial_number
=
'serial_number'
in
data
and
data
[
"serial_numner"
]
\
or
self
.
serial_number
if
'price'
in
data
:
result
[
"total"
]
=
data
[
"price"
]
if
"subscriber_id"
in
data
and
data
[
"subscriber_id"
]:
if
"subscriber_id"
in
data
and
data
[
"subscriber_id"
]:
result
[
'id_pel'
]
=
data
[
"subscriber_id"
]
result
[
'id_pel'
]
=
data
[
"subscriber_id"
]
if
"name"
in
data
and
data
[
"name"
]:
if
"name"
in
data
and
data
[
"name"
]:
...
@@ -260,12 +242,12 @@ class Vendor(VendorClass):
...
@@ -260,12 +242,12 @@ class Vendor(VendorClass):
rincian
[
'daya'
]
=
data
[
"power"
]
rincian
[
'daya'
]
=
data
[
"power"
]
inquiries
=
'inquiries'
in
data
and
data
[
'inquiries'
]
\
inquiries
=
'inquiries'
in
data
and
data
[
'inquiries'
]
\
or
'inquiry'
in
data
and
data
[
'inquiry'
]
or
{}
or
'inquiry'
in
data
and
data
[
'inquiry'
]
or
{}
if
not
inquiries
:
if
not
inquiries
:
result
[
"rincian"
]
=
rincian
result
[
"rincian"
]
=
rincian
return
result
return
result
if
self
.
v_produk_kd
==
"PLNPASCA"
or
self
.
v_produk_kd
[:
3
]
==
"PAM"
:
if
self
.
v_produk_kd
==
"PLNPASCA"
or
self
.
v_produk_kd
[:
3
]
==
"PAM"
:
pokok
=
denda
=
admin
=
0
pokok
=
denda
=
admin
=
0
period
=
meter
=
""
period
=
meter
=
""
jml_period
=
0
jml_period
=
0
...
@@ -357,13 +339,13 @@ class Vendor(VendorClass):
...
@@ -357,13 +339,13 @@ class Vendor(VendorClass):
if
"installment"
in
inquiries
:
if
"installment"
in
inquiries
:
if
"periode"
in
rincian
:
if
"periode"
in
rincian
:
rincian
[
'periode'
]
+=
" "
+
inquiries
[
"installment"
]
rincian
[
'periode'
]
+=
" "
+
inquiries
[
"installment"
]
else
:
else
:
rincian
[
'periode'
]
=
inquiries
[
"installment"
]
rincian
[
'periode'
]
=
inquiries
[
"installment"
]
if
"due_date"
in
inquiries
:
if
"due_date"
in
inquiries
:
if
"jth_tempo"
in
rincian
:
if
"jth_tempo"
in
rincian
:
rincian
[
'jth_tempo'
]
+=
" "
+
inquiries
[
"due_date"
]
rincian
[
'jth_tempo'
]
+=
" "
+
inquiries
[
"due_date"
]
else
:
else
:
rincian
[
'jth_tempo'
]
=
inquiries
[
"due_date"
]
rincian
[
'jth_tempo'
]
=
inquiries
[
"due_date"
]
...
@@ -379,7 +361,7 @@ class Vendor(VendorClass):
...
@@ -379,7 +361,7 @@ class Vendor(VendorClass):
if
"participant_counts"
in
inquiries
:
if
"participant_counts"
in
inquiries
:
rincian
[
'anggota'
]
=
inquiries
[
"participant_counts"
]
rincian
[
'anggota'
]
=
inquiries
[
"participant_counts"
]
i
+=
1
i
+=
1
result
[
'jml_data'
]
=
i
result
[
'jml_data'
]
=
i
result
[
'rincian'
]
=
rincian
result
[
'rincian'
]
=
rincian
...
...
src/agratek/api/merchant/views/vendor.py
View file @
8dab2fb
...
@@ -44,6 +44,7 @@ class VendorClass(object):
...
@@ -44,6 +44,7 @@ class VendorClass(object):
self
.
id_pel
=
invoice_det
and
invoice_det
.
id_pel
or
None
self
.
id_pel
=
invoice_det
and
invoice_det
.
id_pel
or
None
self
.
request
=
None
self
.
request
=
None
self
.
response
=
None
self
.
response
=
None
self
.
result
=
None
self
.
vend_inv_no
=
invoice_det
and
invoice_det
.
vend_inv_no
or
None
self
.
vend_inv_no
=
invoice_det
and
invoice_det
.
vend_inv_no
or
None
self
.
status
=
invoice_det
and
invoice_det
.
status
or
0
self
.
status
=
invoice_det
and
invoice_det
.
status
or
0
...
@@ -80,7 +81,8 @@ class VendorClass(object):
...
@@ -80,7 +81,8 @@ class VendorClass(object):
response
=
self
.
response
)
response
=
self
.
response
)
elif
typ
==
'payment'
:
elif
typ
==
'payment'
:
self
.
invoice_det
.
payment
=
dict
(
request
=
self
.
request
,
self
.
invoice_det
.
payment
=
dict
(
request
=
self
.
request
,
response
=
self
.
response
)
response
=
self
.
response
,
result
=
self
.
result
)
elif
typ
==
'advice'
:
elif
typ
==
'advice'
:
self
.
invoice_det
.
advice
=
dict
(
request
=
self
.
request
,
self
.
invoice_det
.
advice
=
dict
(
request
=
self
.
request
,
response
=
self
.
response
)
response
=
self
.
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