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 eb668ec9
authored
Mar 10, 2020
by
yasir
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perbaikan
1 parent
9c5c9f17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
80 deletions
src/agratek/api/merchant/views/odeo/dummy.py
src/agratek/api/merchant/views/odeo/dummy.py
View file @
eb668ec
...
...
@@ -7,86 +7,31 @@ import hashlib
import
requests
def
kirim_notify
(
order_id
):
# try:
# {
# "order_id": 1,
# "status": "COMPLETED",
# "message": "XXX"
# "signature": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
# }
print
(
'kirim_notify >> '
)
fake_web
=
'http://DESKTOP-0KSLBA0:6555/notify/artpay'
dict_notify
=
{}
dict_notify
[
'order_id'
]
=
order_id
dict_notify
[
'status'
]
=
'COMPLETED'
dict_notify
[
'message'
]
=
'Sukses'
settings
=
get_settings
()
website
=
settings
[
'_host'
]
+
'/api/vendor/odeo/notify'
mid
=
'odeo_mid'
in
settings
and
settings
[
"odeo_mid"
]
or
None
key
=
'odeo_key'
in
settings
and
settings
[
"odeo_key"
]
or
None
signature
=
sha256
(
"{order_id}{mid}{key}{status}"
.
format
(
order_id
=
order_id
,
mid
=
mid
,
key
=
key
,
status
=
'COMPLETED'
))
dict_notify
[
'signature'
]
=
signature
requests
.
post
(
website
,
data
=
json
.
dumps
(
dict_notify
),
timeout
=
30
)
# requests.post(fake_web, data=json.dumps(dict_notify), timeout=30)
# except Exception as e:
# print('error notify >>')
# print(e)
def
sha256
(
hash_string
):
return
hashlib
.
sha256
(
hash_string
.
encode
())
.
hexdigest
()
class
Lolable
(
object
):
EPULSA_CLUB
=
[
'XL'
,
'TSEL'
,
'ISAT'
,
'TRI'
,
'AX'
,
'SF'
]
TELKOM_CLUB
=
[
'TELKOMFLEXI'
,
'TELKOMSPEEDY'
,
'TELKOMPSTN'
,
'TELKOMSELHALO'
,
'INDIHOME'
]
def
__init__
(
self
,
vendor_produk
,
invoice_det
):
print
(
'init lolable >>'
)
def
__init__
(
self
,
vendor_produk
,
inst_class
):
self
.
status_code
=
200
self
.
text
=
{}
self
.
in
voice_det
=
invoice_det
self
.
in
st_class
=
inst_class
self
.
vendor_produk
=
vendor_produk
if
type
(
inst_class
)
.
__name__
==
'PartnerLog'
:
self
.
pl_idpel
=
self
.
inst_class
.
inquiry
[
'request'
][
'number'
]
elif
type
(
inst_class
)
.
__name__
==
'H2hArInvoiceDet'
:
self
.
pl_idpel
=
self
.
inst_class
.
id_pel
# self.website = self.invoice_det.h2h_ar_invoice.customer.website
self
.
invoice_no
=
self
.
invoice_det
.
h2h_ar_invoice
.
cust_inv_no
# sg = "{order_id}{mid}{key}{status}".format(
# order_id=order_id, mid=mid, key=key, status=status)
self
.
vendor_produk
=
vendor_produk
self
.
kategori
=
vendor_produk
.
produk
.
kategori
.
kode
# self.order = H2hArInvoiceDet.query().filter(
# H2hArInvoiceDet.vendor_id == self.vendor_produk.partner_id,
# H2hArInvoiceDet.vend_inv_no == self.invoice_det.cust_inv_no
# ).first()
self
.
order
=
invoice_det
self
.
order
=
inst_class
# {"data": {"denom": "TSEL5", "number": "0812121212"}}
# merch_request_dict >>
# {'data': {'denom': 'TSEL5', 'number': '0812121212'}}
# {
# "status": "SUCCESS",
# "data": {
# "order_id": 1,
# "price": 5675
# },
# "message": ""
# }
# {
# "status": "SUCCESS",
# "data": {
# "rc": "68",
# "order_id": 199992,
# "price": 5362,
# "message": "Trx ke 0812121212 sedang diproses. Harga Rp5,362 REFF#199992"
# },
# "message": ""
# }
def
get_price_epulsa
(
self
,
denom
):
price_str
=
denom
...
...
@@ -114,19 +59,7 @@ class Lolable(object):
dumb_data
=
{}
dumb_data
[
'order_id'
]
=
1
dumb_data
[
'message'
]
=
''
# {
# "status": "SUCCESS",
# "data": {
# "order_id": 1,
# "name": "XXX",
# "number": "XXX",
# "serial_number": "XXX",
# "status": "XXX",
# "price": 20000,
# "message": "XXX (Trx duplicate. This response only appear when you use slash (/) format when checking same trx id)"
# },
# "message": ""
# }
if
self
.
kategori
==
'e-pulsa'
:
dumb_data
[
'price'
]
=
(
self
.
get_price_epulsa
(
denom
)
*
1000
)
else
:
...
...
@@ -184,7 +117,8 @@ class Lolable(object):
dumb_dict
[
'message'
]
=
''
dumb_data
=
{}
dumb_data
[
'subscriber_id'
]
=
self
.
invoice_det
.
id_pel
# dumb_data['subscriber_id'] = self.inst_class.id_pel
dumb_data
[
'subscriber_id'
]
=
self
.
pl_idpel
dumb_data
[
'subscriber_name'
]
=
'Suriyah Sidkisari'
dumb_data
[
'ref_id'
]
=
1
...
...
@@ -196,7 +130,7 @@ class Lolable(object):
dumb_inquiries_data
[
'period'
]
=
str
(
today
.
year
)
+
'-'
+
str
(
today
.
month
)
print
(
'amt_sell >>'
)
print
(
self
.
in
voice_det
.
amt_sell
)
print
(
self
.
in
st_class
.
amt_sell
)
# "tariff": "R1/1300VA",
dumb_inquiries_data
[
'base_price'
]
=
0
dumb_inquiries_data
[
'admin_fee'
]
=
0
...
...
@@ -205,7 +139,7 @@ class Lolable(object):
dumb_inquiries_data
[
'power'
]
=
2200
dumb_inquiries_data
[
'base_price'
]
=
100000
dumb_inquiries_data
[
'fine'
]
=
0
dumb_inquiries_data
[
'admin_fee'
]
=
self
.
in
voice_det
.
produk
.
harga
dumb_inquiries_data
[
'admin_fee'
]
=
self
.
in
st_class
.
produk
.
harga
dumb_inquiries_arr
.
append
(
dumb_inquiries_data
)
...
...
@@ -425,3 +359,34 @@ class Lolable(object):
self
.
text
=
json
.
dumps
(
dumb_dict
)
return
self
def
kirim_notify
(
order_id
):
# try:
# {
# "order_id": 1,
# "status": "COMPLETED",
# "message": "XXX"
# "signature": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
# }
print
(
'kirim_notify >> '
)
fake_web
=
'http://DESKTOP-0KSLBA0:6555/notify/artpay'
dict_notify
=
{}
dict_notify
[
'order_id'
]
=
order_id
dict_notify
[
'status'
]
=
'COMPLETED'
dict_notify
[
'message'
]
=
'Sukses'
settings
=
get_settings
()
website
=
settings
[
'_host'
]
+
'/api/vendor/odeo/notify'
mid
=
'odeo_mid'
in
settings
and
settings
[
"odeo_mid"
]
or
None
key
=
'odeo_key'
in
settings
and
settings
[
"odeo_key"
]
or
None
signature
=
sha256
(
"{order_id}{mid}{key}{status}"
.
format
(
order_id
=
order_id
,
mid
=
mid
,
key
=
key
,
status
=
'COMPLETED'
))
dict_notify
[
'signature'
]
=
signature
requests
.
post
(
website
,
data
=
json
.
dumps
(
dict_notify
),
timeout
=
30
)
# requests.post(fake_web, data=json.dumps(dict_notify), timeout=30)
# except Exception as e:
# print('error notify >>')
# print(e)
def
sha256
(
hash_string
):
return
hashlib
.
sha256
(
hash_string
.
encode
())
.
hexdigest
()
\ No newline at end of file
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