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 739ad77b
authored
Feb 04, 2020
by
yasir
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ubah method post ke ajax post, dan migrasi redirect pages ke 1 halaman
1 parent
f4ce41d3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
209 additions
and
10 deletions
src/agratek/api/merchant/views/pay.py
src/agratek/api/merchant/views/pay_request_resp.py
src/agratek/api/merchant/views/templates/pay.pt
src/agratek/api/merchant/views/pay.py
View file @
739ad77
...
@@ -8,12 +8,12 @@ from opensipkd.pasar.models.produk import H2hArInvoice, H2hArInvoiceDet, Partner
...
@@ -8,12 +8,12 @@ from opensipkd.pasar.models.produk import H2hArInvoice, H2hArInvoiceDet, Partner
from
opensipkd.pasar.models
import
DBSession
,
flush_row
from
opensipkd.pasar.models
import
DBSession
,
flush_row
from
.api_payment
import
set_register_values
,
build_register
from
.api_payment
import
set_register_values
,
build_register
from
.api_merchant
import
get_vendor_produk
from
.api_merchant
import
get_vendor_produk
from
..pay_request_tools
import
methods
,
vacs
,
cvss
,
loans
,
cps
,
ems
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
opensipkd.base
import
get_settings
from
opensipkd.base
import
get_settings
from
..tools
import
json_rpc_header
from
..tools
import
json_rpc_header
import
requests
import
requests
import
json
import
json
from
..pay_request_tools
import
methods
,
vacs
,
cvss
,
loans
,
cps
,
ems
,
get_str_hari
,
get_str_bulan
,
VA_IMG_SRC
class
VaSchema
(
colander
.
Schema
):
class
VaSchema
(
colander
.
Schema
):
...
@@ -93,6 +93,7 @@ def whatisthis(s):
...
@@ -93,6 +93,7 @@ def whatisthis(s):
class
view_pay
(
BaseView
):
class
view_pay
(
BaseView
):
@view_config
(
route_name
=
'pay-form'
,
renderer
=
'templates/pay.pt'
)
#permission = 'pay-form',
@view_config
(
route_name
=
'pay-form'
,
renderer
=
'templates/pay.pt'
)
#permission = 'pay-form',
@view_config
(
route_name
=
'pay-form'
,
renderer
=
'json'
,
request_param
=
'pay=pay'
)
#permission = 'pay-form',
# class view_pay():
# class view_pay():
def
the_form
(
self
):
def
the_form
(
self
):
request
=
self
.
req
request
=
self
.
req
...
@@ -183,13 +184,50 @@ class view_pay(BaseView):
...
@@ -183,13 +184,50 @@ class view_pay(BaseView):
print
(
e
)
print
(
e
)
err_param
=
''
err_param
=
''
# info params:
subject
=
''
content
=
''
amount
=
0
dt_tm_str
=
''
img_src
=
''
meth_str
=
''
# >>>>>>>>>>>>>
if
result_request
:
if
result_request
:
dict_results
=
json
.
loads
(
result_request
.
text
)
dict_results
=
json
.
loads
(
result_request
.
text
)
if
'result'
in
dict_results
:
if
'result'
in
dict_results
:
state
=
int
(
dict_results
[
'result'
][
'code'
])
state
=
int
(
dict_results
[
'result'
][
'code'
])
# vacct_no
if
state
==
0
:
if
state
==
0
:
# updating additional necessary datas to partner_pay after done and succeed register method
# updating additional necessary datas to partner_pay after done and succeed register method
# getting new mapped data
# getting new mapped data
# populating datas for info
subject
=
'No. Virtual Account'
content
=
dict_results
[
'result'
][
'va'
][
'vacct_no'
]
amount
=
dict_results
[
'result'
][
'amount'
]
amount
=
format
(
int
(
amount
),
',d'
)
.
replace
(
','
,
'.'
)
va_dt
=
dict_results
[
'result'
][
'va'
][
'valid_date'
]
va_tm
=
dict_results
[
'result'
][
'va'
][
'valid_time'
]
va_dt
=
datetime
.
strptime
(
va_dt
,
"
%
Y
%
m
%
d"
)
.
date
()
hari_str
=
get_str_hari
(
va_dt
.
day
,
va_dt
.
month
,
va_dt
.
year
)
bulan_str
=
get_str_bulan
(
va_dt
.
month
)
va_tm
=
datetime
.
strptime
(
va_tm
,
"
%
H
%
M
%
S"
)
.
time
()
jam_str
=
str
(
va_tm
.
hour
)
+
str
(
va_tm
.
minute
)
# Jum'at, 27 Desember 2019, Pukul 04:44 WIB
dt_tm_str
=
hari_str
+
', '
+
str
(
va_dt
.
day
)
+
' '
+
bulan_str
+
' '
+
str
(
va_dt
.
year
)
+
', Pukul '
+
str
(
va_tm
)
+
' WIB'
denom_str
=
denom
layanan
=
denom_str
.
split
(
'-'
)[
1
]
img_src
=
VA_IMG_SRC
[
layanan
]
meth
=
mth
meth_str
=
dict
(
methods
)[
meth
]
+
', '
+
dict
(
vacs
)[
denom_str
]
# populating datas for info >>>>>> end >>>>>>>>>.
produks
=
row_pay
.
cart
produks
=
row_pay
.
cart
produks_items
=
[]
produks_items
=
[]
...
@@ -239,7 +277,18 @@ class view_pay(BaseView):
...
@@ -239,7 +277,18 @@ class view_pay(BaseView):
except
Exception
as
e
:
except
Exception
as
e
:
pass
pass
return
HTTPFound
(
route_to
)
print
(
'at last >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
return
dict
(
state
=
state
,
subject
=
subject
,
content
=
content
,
amount
=
amount
,
dt_tm_str
=
dt_tm_str
,
img_src
=
img_src
,
meth_str
=
meth_str
)
# return HTTPFound(route_to)
elif
'batal'
in
post_data
:
elif
'batal'
in
post_data
:
return
HTTPFound
(
location
=
request
.
route_url
(
'api-merchant-home'
))
return
HTTPFound
(
location
=
request
.
route_url
(
'api-merchant-home'
))
...
@@ -295,6 +344,8 @@ class view_pay(BaseView):
...
@@ -295,6 +344,8 @@ class view_pay(BaseView):
return
dict
(
return
dict
(
pay_info
=
False
,
form
=
form
,
form
=
form
,
formVa
=
formVa
,
formVa
=
formVa
,
formCC
=
formCC
,
formCC
=
formCC
,
...
...
src/agratek/api/merchant/views/pay_request_resp.py
View file @
739ad77
...
@@ -48,7 +48,6 @@ def randomString(stringLength):
...
@@ -48,7 +48,6 @@ def randomString(stringLength):
return
''
.
join
(
random
.
choice
(
letters
)
for
i
in
range
(
stringLength
))
return
''
.
join
(
random
.
choice
(
letters
)
for
i
in
range
(
stringLength
))
def
save_partner_pay_request
(
values
,
row
=
None
):
def
save_partner_pay_request
(
values
,
row
=
None
):
print
(
'masuk save_partner_pay_request >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
if
not
row
:
if
not
row
:
print
(
'data baru loh >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
print
(
'data baru loh >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
row
=
PartnerPay
()
row
=
PartnerPay
()
...
@@ -56,6 +55,7 @@ def save_partner_pay_request(values, row=None):
...
@@ -56,6 +55,7 @@ def save_partner_pay_request(values, row=None):
print
(
'kok bisa sudah ada datanya >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
print
(
'kok bisa sudah ada datanya >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
row
.
from_dict
(
values
)
row
.
from_dict
(
values
)
random_token
=
randomString
(
20
)
random_token
=
randomString
(
20
)
row
.
token_pay_req
=
random_token
row
.
token_pay_req
=
random_token
...
@@ -76,12 +76,68 @@ def added_register_values(current_register_values, dat):
...
@@ -76,12 +76,68 @@ def added_register_values(current_register_values, dat):
return
added_dict
return
added_dict
def
get_input_error
(
data
):
print
(
'isi data >>>>>'
)
print
(
data
)
err_dict
=
{}
err_dict
[
'code'
]
=
0
data_read
=
data
[
0
]
print
(
'data_read >>>>>>>>>>>>'
)
print
(
data_read
)
biller_data
=
data_read
[
'biller'
]
cust_data
=
data_read
[
'customer'
]
print
(
'biller_data >>>>>>>>>>>>>>>>>>>>.'
)
print
(
biller_data
)
cust_city
=
cust_data
[
'city'
]
cust_state
=
cust_data
[
'state'
]
bill_name
=
biller_data
[
'name'
]
bill_phone
=
biller_data
[
'phone'
]
bill_email
=
biller_data
[
'email'
]
bill_city
=
biller_data
[
'city'
]
bill_state
=
biller_data
[
'state'
]
amt_total
=
data_read
[
'amount'
]
if
cust_city
==
None
or
cust_city
==
''
:
err_dict
[
'msg'
]
=
'customer_city tidak boleh kosong'
err_dict
[
'code'
]
=
9025
if
cust_state
==
None
or
cust_state
==
''
:
err_dict
[
'msg'
]
=
'customer_state tidak boleh kosong'
err_dict
[
'code'
]
=
9026
if
bill_name
==
None
or
bill_name
==
''
:
err_dict
[
'msg'
]
=
'biller_name tidak boleh kosong'
err_dict
[
'code'
]
=
9016
if
bill_phone
==
None
or
bill_name
==
''
:
err_dict
[
'msg'
]
=
'biller_phone tidak boleh kosong'
err_dict
[
'code'
]
=
9017
if
bill_email
==
None
or
bill_email
==
''
:
err_dict
[
'msg'
]
=
'biller_email tidak boleh kosong'
err_dict
[
'code'
]
=
9018
if
bill_city
==
None
or
bill_city
==
''
:
err_dict
[
'msg'
]
=
'bill_city tidak boleh kosong'
err_dict
[
'code'
]
=
9025
if
bill_state
==
None
or
bill_state
==
''
:
err_dict
[
'msg'
]
=
'bill_state tidak boleh kosong'
err_dict
[
'code'
]
=
9026
return
err_dict
@jsonrpc_method
(
method
=
'pay_request'
,
endpoint
=
'api-merchant'
)
@jsonrpc_method
(
method
=
'pay_request'
,
endpoint
=
'api-merchant'
)
def
pay_request
(
request
,
data
,
**
kwargs
):
def
pay_request
(
request
,
data
,
**
kwargs
):
user
=
auth_from_rpc
(
request
)
user
=
auth_from_rpc
(
request
)
# user = DBSession.query(User).filter(User.id == 1).first()
# user = DBSession.query(User).filter(User.id == 1).first()
i
=
0
i
=
0
print
(
'masuk sini loh >>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
if
not
data
:
if
not
data
:
raise
JsonRpcParameterNotFound
raise
JsonRpcParameterNotFound
...
@@ -93,7 +149,14 @@ def pay_request(request, data, **kwargs):
...
@@ -93,7 +149,14 @@ def pay_request(request, data, **kwargs):
#todo, json request testing
#todo, json request testing
r_data
=
{}
r_data
=
{}
log
.
info
(
"
%
s Payment Attempt Request:
%
s"
%
(
customer
.
kode
,
data
))
log
.
info
(
"
%
s Payment Attempt Requestt:
%
s"
%
(
customer
.
kode
,
data
))
basic_error
=
get_input_error
(
data
)
if
basic_error
[
'code'
]
!=
0
:
r_data
[
'status'
]
=
"FAILED"
r_data
[
'message'
]
=
basic_error
[
'msg'
]
r_data
[
'code'
]
=
basic_error
[
'code'
]
else
:
for
dat
in
data
:
for
dat
in
data
:
if
"invoice_no"
not
in
dat
or
\
if
"invoice_no"
not
in
dat
or
\
'amount'
not
in
dat
or
not
dat
[
'amount'
]:
'amount'
not
in
dat
or
not
dat
[
'amount'
]:
...
...
src/agratek/api/merchant/views/templates/pay.pt
View file @
739ad77
...
@@ -40,15 +40,58 @@ td, th {
...
@@ -40,15 +40,58 @@ td, th {
</div>
</div>
<div
metal:fill-slot=
"scripts"
>
<div
metal:fill-slot=
"scripts"
>
<div
style=
"padding: 0px; padding-top: 5px; padding-bottom: 5px;"
class=
"panel-body col-md-12"
>
<div
style=
"padding: 0px; padding-top: 5px; padding-bottom: 5px;"
class=
"panel-body col-md-12"
>
<div
style=
"padding: 0px; padding-top: 5px; padding-bottom: 5px;"
class=
"col-md-6 col-md-offset-3 col-xs-12 well"
>
<div
id=
"div_info"
style=
"padding: 0px; padding-top: 5px; padding-bottom: 5px;"
class=
"col-md-6 col-md-offset-3 col-xs-12 well"
>
<h5
style=
"padding-left: 6px; padding-right: 6px; width: 100%; text-align: left;"
>
Lakukan pembayaran sebelum tagihan kamu kadaluwarsa.
</h5>
<div
class=
"panel-body well"
style=
"padding: 0px;"
>
<div
class=
"panel-header"
style=
"text-align: center;"
>
<label
style=
"font-weight: normal; margin-bottom: 0px; margin-top: 10px;"
class=
"col-md-12 col-xs-12 col-sm-12"
>
Total pembayaran
</label>
<label
id=
"lb_amount"
style=
"font-size: 1.2em; color: #db4827;"
class=
"col-md-12 col-xs-12 col-sm-12"
>
</label>
</div>
<hr
class=
"col-sm-12 col-md-12 col-xs-12"
>
<label
style=
"font-weight: normal;"
class=
"col-md-12 col-xs-12 col-sm-12"
>
Batas Pembayaran
</label>
<label
id=
"lb_dt_tm_str"
style=
"font-weight: normal;"
class=
"col-md-12 col-xs-12 col-sm-12"
>
</label>
<hr
class=
"col-sm-12 col-md-12 col-xs-12"
>
<label
style=
"font-weight: normal;"
class=
"col-md-12 col-xs-12 col-sm-12"
>
Metode Pembayaran :
</label>
<div
class=
"col-md-12 col-xs-12 col-sm-12"
id=
"img_container"
>
<img
id=
"img_bank"
style=
"height: 60px;"
src=
""
>
</div>
<label
id=
"lb_meth_str"
style=
"font-weight: normal; margin-top: 6px;"
class=
"col-md-12 col-xs-12 col-sm-12"
>
</label>
<hr
class=
"col-sm-12 col-md-12 col-xs-12"
>
<label
id=
"lb_subject"
style=
"font-weight: normal;"
class=
"col-md-12 col-xs-12 col-sm-12"
>
</label>
<label
id=
"lb_content"
style=
"font-weight: bolder;"
class=
"col-md-12 col-xs-12 col-sm-12"
>
</label>
</div>
</div>
<div
id=
"div_gagal"
class=
"col-md-6 col-md-offset-3 col-xs-12"
style=
"padding: 0px;"
>
<div
style=
"height: 300px; text-align: center;"
class=
"col-xs-12 col-md-12 col-sm-12"
>
<label
style=
"color: indianred; padding-top: 140px; display: block; font-weight: bold;"
>
Terjadi Kesalahan Sistem, Gagal melakukan transaksi.
</label>
<label
id=
"lb_state"
style=
"color: indianred; padding-top: 5px; display: block; font-weight: bold;"
>
</label>
</div>
</div>
<div
id=
"div_pay"
style=
"padding: 0px; padding-top: 5px; padding-bottom: 5px;"
class=
"col-md-6 col-md-offset-3 col-xs-12 well"
>
<!-- Proses Template Form -->
<!-- Proses Template Form -->
<form
method=
"post"
<!--
<form method="post"
accept-charset="utf-8"
accept-charset="utf-8"
id="deform"
id="deform"
class="form-horizontal"
class="form-horizontal"
enctype="multipart/form-data"
enctype="multipart/form-data"
style="background-color:white;"
style="background-color:white;"
autocomplete=
"off"
>
autocomplete="off">
-->
...
@@ -279,9 +322,9 @@ td, th {
...
@@ -279,9 +322,9 @@ td, th {
</div>
</div>
<div
id=
"bt_box"
class=
"col-md-12"
style=
"text-align: center;"
>
<div
id=
"bt_box"
class=
"col-md-12"
style=
"text-align: center;"
>
<button
style=
"margin: 0px; width: 100%;"
class=
"btn btn-success"
type=
"
submit
"
name=
"bayar"
id=
"bt_bayar"
>
Bayar
</button>
<button
style=
"margin: 0px; width: 100%;"
class=
"btn btn-success"
type=
"
button
"
name=
"bayar"
id=
"bt_bayar"
>
Bayar
</button>
</div>
</div>
<
/form
>
<
!-- </form> --
>
<!-- End Template Form -->
<!-- End Template Form -->
<!-- </div> -->
<!-- </div> -->
...
@@ -293,6 +336,48 @@ td, th {
...
@@ -293,6 +336,48 @@ td, th {
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
"#bt_bayar"
).
click
(
function
(){
var
pay_method
=
$
(
'#pay_method'
).
val
();
var
va_opt
=
$
(
'#va_opt'
).
val
();
var
posting
=
$
.
post
(
window
.
location
.
toString
()
+
'?pay=pay'
,
{
pay_method
:
pay_method
,
va_opt
:
va_opt
,
bayar
:
'bayar'
}
);
// Put the results in a div
$
(
this
).
attr
(
"disabled"
,
true
);
posting
.
done
(
function
(
data
)
{
// alert('done');
// console.log(data);
if
(
data
.
state
==
0
){
$
(
"#lb_subject"
).
html
(
data
.
subject
);
$
(
"#lb_content"
).
html
(
data
.
content
);
$
(
"#lb_amount"
).
html
(
'Rp. '
+
data
.
amount
);
$
(
"#lb_dt_tm_str"
).
html
(
data
.
dt_tm_str
);
$
(
"#lb_meth_str"
).
html
(
data
.
meth_str
);
$
(
"#img_bank"
).
attr
(
"src"
,
"${request._host}/static/payment/"
+
data
.
img_src
);
$
(
"#div_info"
).
show
();
$
(
"#div_pay"
).
hide
();
$
(
"#div_gagal"
).
hide
();
}
else
{
$
(
"#lb_state"
).
html
(
data
.
state
);
$
(
"#div_info"
).
hide
();
$
(
"#div_pay"
).
hide
();
$
(
"#div_gagal"
).
show
();
}
});
// alert(pay_method);
// alert(va_opt);
});
$
(
"#div_info"
).
hide
();
$
(
"#div_gagal"
).
hide
();
// $("#div_pay").hide();
$
(
"[name=biller_name]"
).
prop
(
"readonly"
,
true
);
$
(
"[name=biller_name]"
).
prop
(
"readonly"
,
true
);
$
(
"[name=amount_tot]"
).
prop
(
"readonly"
,
true
);
$
(
"[name=amount_tot]"
).
prop
(
"readonly"
,
true
);
$
(
"[name=customer_name]"
).
prop
(
"readonly"
,
true
);
$
(
"[name=customer_name]"
).
prop
(
"readonly"
,
true
);
...
...
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