Commit 29e5c925 by Solo Group

local

1 parent 623171d9
...@@ -2,6 +2,7 @@ kode,path,nama,status,type ...@@ -2,6 +2,7 @@ kode,path,nama,status,type
api-merchant-home,/api/merchant/home,Api Merchant Home,1,0 api-merchant-home,/api/merchant/home,Api Merchant Home,1,0
api-merchant,/api/merchant,Api Merchant,1,1 api-merchant,/api/merchant,Api Merchant,1,1
api-vendor-notify,/api/vendor/{name}/notify,Api Vendor Notify,1,0 api-vendor-notify,/api/vendor/{name}/notify,Api Vendor Notify,1,0
api-merchant/payment,/api/merchant/payment,Api Merchant Payment,1,0
api-merchant-list,/api/merchant/list,Test Api Merchant,1,0 api-merchant-list,/api/merchant/list,Test Api Merchant,1,0
api-merchant-add,/api/merchant/add,Add Api Merchant,1,0 api-merchant-add,/api/merchant/add,Add Api Merchant,1,0
......
from datetime import datetime
import colander
from agratek.api.merchant.views.api_merchant import get_vendor_produk
from datatables import ColumnDT
from deform import widget, Form, ValidationFailure
from opensipkd.base.views import DataTables
from pyramid.httpexceptions import HTTPFound
from pyramid.view import view_config
from . import BaseView # , save_file_upload
from ..models import (DBSession, flush_row, Satuan)
# from ..models import (H2hArInvoice, H2hArInvoiceDet)
from ..models import (Produk, Partner, PartnerLog, PartnerProduk, H2hArInvoice, H2hArInvoiceDet)
from ..tools import (btn_reset,
btn_cancel, btn_delete, btn_save, auth_from_rpc, get_settings, os)
from opensipkd.pasar.models.views import (deferred_produk, deferred_vendor,
deferred_customer)
class Payment(colander.Schema):
"""
timeStamp Y N 14 API Request Date
tXid Y AN 30 Transaction ID
callBackUrl Y AN 255 Payment result forward url (on browser) direplace oleh systen
merchantToken Y AN 255 merchantToken (dibuat oleh system)
"""
time_stamp = colander.SchemaNode(
colander.String(),
oid="time_stamp",
)
tx_id = colander.SchemaNode(
colander.String(), title='Customer',
oid="tx_id",
widget=widget.PasswordWidget(min_length=30, max_length=30)
)
callback_url = colander.SchemaNode(
colander.String(), title='Callback URL',
oid="callback_url",
widget=widget.TextInputWidget()
)
class CcPay(Payment):
"""
cardNo Y N 20 Full card number
cardExpYymm Y N 4 card expiry(YYMM)
cardCvv Y N 4 card CVV
cardHolderNm Y (CIMB) AN 50 Card Holder Name
:return:
"""
card_name = colander.SchemaNode(
colander.String(), title='Card Expired',
oid="card_no",
widget=widget.TextInputWidget(min_length=30, max_length=30)
)
card_no = colander.SchemaNode(
colander.String(), title='Card Number',
oid="card_no",
widget=widget.TextInputWidget(min_length=16, max_length=16)
)
card_exp = colander.SchemaNode(
colander.String(), title='Card Expired',
oid="card_no",
widget=widget.TextInputWidget(min_length=4, max_length=4)
)
card_cvv = colander.SchemaNode(
colander.String(), title='Card Expired',
oid="card_no",
widget=widget.PasswordWidget(min_length=3, max_length=3)
)
class ClickPay(Payment):
"""
clickPayNo Y N 16 ClickPay number
dataField3 Y N 16 Token input 3 for clickpay
clickPayToken Y N 6 Code response from token
:return:
"""
pay_no = colander.SchemaNode(
colander.String(), title='Click Pay No',
oid="pay_no",
widget=widget.TextInputWidget(min_length=16, max_length=16)
)
data_field_3 = colander.SchemaNode(
colander.String(), title='Click Pay No',
oid="data_field_3",
widget=widget.TextInputWidget(min_length=16, max_length=16)
)
token = colander.SchemaNode(
colander.String(), title='Click Pay No',
oid="token",
widget=widget.TextInputWidget(min_length=6, max_length=6)
)
class AddSchema(Payment):
customer_id = colander.SchemaNode(
colander.Integer(), title='Customer',
oid="customer_id", widget=deferred_customer)
produk_id = colander.SchemaNode(
colander.Integer(), title='Produk',
oid="produk_id", widget=deferred_produk)
def WalletPay(Payment):
pass
def payment_validator(form, values):
pass
def get_form(request, class_form, buttons=None, row=None, validator=payment_validator):
schema = class_form(validator=validator)
schema = schema.bind(vendor=Partner.get_vendor_list(),
produk=Produk.get_e_list(),
customer=Partner.get_customer_list())
schema.request = request
if row:
schema.deserialize(row)
if not buttons:
buttons = (btn_save, btn_reset)
return Form(schema, buttons=buttons)
def route_list(request):
return HTTPFound(location=request.route_url('api-customer-list'))
def save(values, row):
# if not row:
# row = H2hArInvoice()
# row.create_uid = values['uid']
# row.created = datetime.now()
# else:
# row.update_uid = values['uid']
# row.updated = datetime.now()
row.from_dict(values)
flush_row(row)
return row
# def save_request(request, values, values_det, row=None):
# if not row:
# row = H2hArInvoice()
# values['uid'] = request.user.id
# values['status'] = 'status' in values and values['status'] and 1 or 0
# else:
# values['update_uid'] = request.user.id
# values['updated'] = datetime.now()
# DBSession.query(H2hArInvoiceDet).filter(H2hArInvoiceDet.ar_invoice_id == row.id).delete()
#
# row = save(values, row)
#
# row_det = H2hArInvoiceDet()
# row_det.id_pel = values['id_pel']
# row_det.ar_invoice_id = row.id
# row_det = save(values_det, row_det)
# request.session.flash('Data %s Berhasil disimpan' % values['kode'])
# # return row
#
#
# form_params_edit = dict(scripts="""
# $(document).ready(function(){
# });
# """)
#
# form_params_view = dict(scripts="""
# $(document).ready(function(){
# });
# """)
#
# def session_failed(request, session_name):
# r = dict(form=request.session[session_name])
# del request.session[session_name]
# return r
#
# def id_not_found(request):
# id = request.matchdict['id']
# request.session.flash('Data %s Tidak Ditemukan' % id, 'error')
# return route_list(request)
#
#
# def query_id(request):
# id = request.matchdict['id']
# return H2hArInvoice.query_id(id)
#
#
class ViewData(BaseView):
@view_config(route_name='api-merchant-payment',
# permission="api-customer-admin",
renderer='templates/form.pt')
def view_payment(self):
request = self.req
# form = get_form(request, AddSchema)
# form_params = dict(scripts=None)
form = get_form(request, Payment)
settings = get_settings()
if request.POST:
controls = request.POST.items()
try:
c = form.validate(controls)
except ValidationFailure as e:
form.set_appstruct(e.cstruct)
return
# dict(form=form, params=form_params_edit)
values = dict(c.items())
registrasi = PartnerPay.query_tx_id(values["tx_id"]).first()
if not registrasi:
request.session.flash("Registrasi Payment Tidak Ditemukan", "error")
return
vendor_produk = PartnerProduk.get_produk(registrasi.vendor_id, registrasi.produk_id).first()
if not vendor_produk:
request.session.flash("Produk Tidak Ditemukan", "error")
return
url = os.path.join(settings["np_url"], "payment")
return HTTPFound(location=url, par)
return dict(form=form, params=form_params_edit)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!