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 ba563360
authored
Dec 19, 2019
by
yasir
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update
1 parent
ef91a5c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
57 deletions
src/agratek/api/merchant/views/pay_request.py
src/agratek/api/merchant/views/pay_request_resp.py
src/agratek/api/merchant/views/pay_request.py
View file @
ba56336
...
...
@@ -9,6 +9,8 @@ from pyramid.httpexceptions import HTTPFound
from
..models
import
(
Produk
,
DBSession
,
ProdukKategori
)
from
sqlalchemy
import
or_
from
opensipkd.base
import
get_settings
from
..tools
import
json_rpc_header
from
opensipkd.base.models
import
Partner
from
deform.form
import
Button
...
...
@@ -171,7 +173,6 @@ class view_pay(BaseView):
formServer
=
ServerSchema
()
formServer
.
request
=
request
formServer
=
Form
(
formServer
)
print
(
'masuk controller pay_request >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
post_data
=
request
.
POST
...
...
@@ -196,17 +197,26 @@ class view_pay(BaseView):
# REQUEST PAYMENT
print
(
"isi session di pay request >>>>>>>>>>>>>>>>>>>>>>>>."
)
print
(
request
.
session
)
print
(
"isi items >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
)
print
(
items
)
partner_kd
=
request
.
session
[
'partner_kd'
]
customer
=
Partner
.
query
()
.
filter
(
Partner
.
kode
==
partner_kd
)
.
first
()
user
=
customer
.
users
print
(
"isi user >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
)
print
(
user
.
user_name
)
print
(
user
.
api_key
)
headers
=
json_rpc_header
(
user
.
user_name
,
user
.
api_key
)
print
(
"isi header >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
)
# print(header)
settings
=
get_settings
()
hostnya
=
settings
[
'_host'
]
url
=
hostnya
+
"/api/merchant"
headers
=
{
# "userId": "pasarqu",
# "signature": "/IN9xDinJvPzNCuAHgz5l4XHOyh/lC2WPJlKb2q5Xzo=",
# "key": "1570522181",
"Content-Type"
:
"application/json"
}
time_stamp
=
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M
%
S'
)
req_dt
=
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d'
)
req_tm
=
datetime
.
now
()
.
strftime
(
'
%
H
%
M
%
S'
)
...
...
@@ -221,10 +231,10 @@ class view_pay(BaseView):
"currency"
:
"IDR"
,
"amount"
:
items
[
'amount'
],
"invoice_no"
:
items
[
'invoice_no'
],
"description"
:
"Test Transaction Pasarqu"
,
"fee"
:
"0"
,
"vat"
:
"0"
,
"notax_amt"
:
"0"
,
"description"
:
items
[
'description'
]
,
"fee"
:
items
[
'fee'
]
,
"vat"
:
items
[
'vat'
]
,
"notax_amt"
:
items
[
"notax_amt"
]
,
"req_dt"
:
req_dt
,
"req_tm"
:
req_tm
,
"biller"
:
{
...
...
@@ -245,7 +255,7 @@ class view_pay(BaseView):
"city"
:
items
[
'city_cust'
],
"state"
:
items
[
'state_cust'
],
"post_code"
:
items
[
'post_code_cust'
],
"country"
:
"Indonesia"
,
"country"
:
items
[
'country_cust'
]
,
"ip"
:
"127.0.0.1"
,
"session_id"
:
"697D6922C961070967D3BA1BA5699C2C"
,
"agent"
:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
,
...
...
@@ -259,7 +269,7 @@ class view_pay(BaseView):
"city"
:
items
[
'city_deliver'
],
"state"
:
items
[
'state_deliver'
],
"post_code"
:
items
[
'post_code_deliver'
],
"country"
:
"Indonesia"
"country"
:
items
[
'country_deliver'
]
},
"cart"
:
{
"count"
:
len
(
produks
),
...
...
@@ -280,7 +290,7 @@ class view_pay(BaseView):
print
(
'result >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
print
(
dict_results
)
a
=
request
.
route_url
(
route_name
=
'pay-form'
,
pay_token
=
dict_results
[
'result'
][
'token'
])
a
=
request
.
route_url
(
route_name
=
'pay-form'
,
pay_token
=
dict_results
[
'result'
][
'
pay_
token'
])
# print('isi request route >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
# print(a)
# return HTTPFound(location = 'http://localhost:6543/pay/' + dict_results['result']['token'])
...
...
src/agratek/api/merchant/views/pay_request_resp.py
View file @
ba56336
...
...
@@ -2,6 +2,7 @@ import random
import
string
import
colander
import
logging
from
opensipkd.base
import
get_settings
from
opensipkd.pasar.models.produk
import
PartnerPay
from
opensipkd.base.models
import
User
,
DBSession
,
Partner
,
flush_row
from
pyramid_rpc.jsonrpc
import
jsonrpc_method
...
...
@@ -74,12 +75,12 @@ def added_register_values(current_register_values, dat):
@jsonrpc_method
(
method
=
'pay_request'
,
endpoint
=
'api-merchant'
)
def
pay_request
(
request
,
data
,
**
kwargs
):
#
user = auth_from_rpc(request)
user
=
DBSession
.
query
(
User
)
.
filter
(
User
.
id
==
1
)
.
first
()
user
=
auth_from_rpc
(
request
)
#
user = DBSession.query(User).filter(User.id == 1).first()
i
=
0
print
(
'masuk sini loh >>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
#
if not data:
#
raise JsonRpcParameterNotFound
if
not
data
:
raise
JsonRpcParameterNotFound
is_list
=
type
(
data
)
==
list
data
=
is_list
and
data
or
[
data
]
...
...
@@ -99,45 +100,41 @@ def pay_request(request, data, **kwargs):
inv_no
=
dat
[
"invoice_no"
]
row
=
PartnerPay
.
query
()
.
filter_by
(
cust_inv_no
=
inv_no
)
.
first
()
if
row
and
row
.
status
>
0
:
raise
JsonRpcInvoiceFoundError
()
dat
[
'produk'
]
=
dat
[
'cart'
]
values
=
set_register_values
(
dat
,
customer
)
values
=
added_register_values
(
values
,
dat
)
print
(
'isi dat >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
print
(
dat
)
print
(
'isi values >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
)
print
(
values
)
credit_card
=
"credit_card"
in
dat
and
dat
[
"credit_card"
]
or
{}
if
credit_card
:
values
.
update
(
dict
(
instmnt_mon
=
'instmnt_mon'
in
credit_card
and
credit_card
[
'instmnt_mon'
]
or
''
,
instmnt_type
=
'instmnt_type'
in
credit_card
and
credit_card
[
'instmnt_type'
]
or
''
,
recurr_opt
=
'recurr_opt'
in
credit_card
and
credit_card
[
'recurr_opt'
]
or
0
,
))
ccard
=
None
r_data
[
"status"
]
=
"FAILED"
r_data
[
"message"
]
=
"Nomor Invoice Tersebut sudah ada"
r_data
[
'code'
]
=
-
1
else
:
ccard
=
None
va
=
"va"
in
dat
and
dat
[
"va"
]
or
{}
if
va
:
values
.
update
(
dict
(
inv_valid_date
=
'valid_date'
in
va
and
va
[
'valid_date'
]
or
''
,
inv_valid_time
=
'valid_time'
in
va
and
va
[
'valid_time'
]
or
''
,
inv_cust_va
=
'fix_acct_id'
in
va
and
va
[
'fix_acct_id'
]
or
''
,
))
ar_invoice
=
save_partner_pay_request
(
values
,
row
)
# dat.update(ar_invoice.inquiry["result"])
# if "form" in result:
# dat.update(dict(form=result["form"]))
# # request.environ["application"]="text/html"
# # request.response()
# # return request.response
r_data
[
'token'
]
=
ar_invoice
.
token_pay_req
# data = is_list and r_data or r_data[0]
dat
[
'produk'
]
=
dat
[
'cart'
]
values
=
set_register_values
(
dat
,
customer
)
values
=
added_register_values
(
values
,
dat
)
credit_card
=
"credit_card"
in
dat
and
dat
[
"credit_card"
]
or
{}
#belum paham metode untuk credit card seperti gimana.
if
credit_card
:
values
.
update
(
dict
(
instmnt_mon
=
'instmnt_mon'
in
credit_card
and
credit_card
[
'instmnt_mon'
]
or
''
,
instmnt_type
=
'instmnt_type'
in
credit_card
and
credit_card
[
'instmnt_type'
]
or
''
,
recurr_opt
=
'recurr_opt'
in
credit_card
and
credit_card
[
'recurr_opt'
]
or
0
,
))
ccard
=
None
else
:
ccard
=
None
va
=
"va"
in
dat
and
dat
[
"va"
]
or
{}
if
va
:
values
.
update
(
dict
(
inv_valid_date
=
'valid_date'
in
va
and
va
[
'valid_date'
]
or
''
,
inv_valid_time
=
'valid_time'
in
va
and
va
[
'valid_time'
]
or
''
,
inv_cust_va
=
'fix_acct_id'
in
va
and
va
[
'fix_acct_id'
]
or
''
,
))
ar_invoice
=
save_partner_pay_request
(
values
,
row
)
r_data
[
"status"
]
=
"SUCCESS"
r_data
[
"message"
]
=
"Data tersimpan silahkan lanjutkan pembayaran"
r_data
[
'code'
]
=
1
r_data
[
'pay_token'
]
=
ar_invoice
.
token_pay_req
log
.
info
(
"
%
s Payment Request Response:
%
s "
%
(
customer
.
kode
,
r_data
))
return
r_data
...
...
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