Commit 8eb6a40a by aa.gusti

add acc_no to payment request

1 parent a0d578ad
......@@ -5,34 +5,34 @@ from sqlalchemy import create_engine
from sqlalchemy.orm import (
sessionmaker,
scoped_session,
)
)
from zope.sqlalchemy import register
from pyramid.view import (
view_config,
notfound_view_config,
)
)
from pyramid.response import Response
from deform import (
Form,
Button,
ValidationFailure,
)
)
import colander
from opensipkd.string import (
FixLength,
FullDateTimeVar,
)
)
from opensipkd.iso8583.bjb.pbb.structure import INVOICE_PROFILE
from iso8583_web.scripts.tools import iso_to_dict
from iso8583_web.read_conf import web_path_conf
from iso8583_web.scripts.logger import (
log_web_info,
log_web_error,
)
)
from .. import (
WebJob as BaseWebJob,
View as BaseView,
)
)
from .exceptions import (
InvoiceIdError,
NeedPostError,
......@@ -45,18 +45,17 @@ from .exceptions import (
AmountError,
BillRefNotFound,
PaymentNotFound,
)
)
from .structure import (
DataRequest,
InquiryResponse,
PaymentResponse,
)
)
from .renderer import Renderer
from .models import (
Rpc,
Log,
)
)
ROUTE = 'linkaja'
RENDERER = 'csv'
......@@ -83,7 +82,7 @@ class WebJob(BaseWebJob):
def form_validator(form, value):
if value['trx_type'] not in METHOD:
raise TrxTypeError()
def get_form():
schema = DataRequest(validator=form_validator)
......@@ -104,6 +103,9 @@ def get_inquiry(data):
DBSession = get_db_session()
bill_ref = int(data['bill_ref'])
q = DBSession.query(Rpc).filter_by(id=bill_ref)
# todo: Perlu ditambahkan data["acc_no"] sebagai filter untuk meningkatkan
# validasi data sehingga kesalahan akibat dari client mengubah acc_no
# dapat ditingkatkan.
return q.first()
......@@ -111,7 +113,7 @@ def get_payment(data):
DBSession = get_db_session()
bill_ref = int(data['bill_ref'])
q = DBSession.query(Rpc).filter_by(
inquiry_id=bill_ref, trx_type='022')
inquiry_id=bill_ref, trx_type='022')
q = q.order_by(Rpc.id.desc())
return q.first()
......@@ -150,7 +152,7 @@ class csv_method(object):
config.add_view(view=ob, renderer=RENDERER, **kw)
info = venusian.attach(
wrapped, callback, category='pyramid', depth=depth + 1)
wrapped, callback, category='pyramid', depth=depth + 1)
if info.scope == 'class':
# ensure that attr is set if decorating a class method
kw.setdefault('attr', wrapped.__name__)
......@@ -211,7 +213,7 @@ class View(BaseView):
if data.get('amount'):
row.amount = int(data['amount'])
if not is_inquiry(data):
row.inquiry_id = inq and inq.id or pay.inquiry_id
row.inquiry_id = inq and inq.id or pay.inquiry_id
row.ntb = data['trx_id']
with transaction.manager:
DBSession.add(row)
......@@ -237,7 +239,7 @@ class View(BaseView):
web_data['Biller Name'] = row.biller_name = \
profile['Nama'].strip()
web_data['Bill Amount'] = iso_data[4].lstrip('0')
if iso_data.get(47):
if iso_data.get(47):
web_data['Transaction ID'] = row.ntp = iso_data[47] # NTP
err = None
elif iso_data[39] in ['33', '55']:
......@@ -253,7 +255,7 @@ class View(BaseView):
err = BaseError()
if err:
web_data.from_err(err)
row.resp_msg = web_data['Notification Message']
row.resp_msg = web_data['Notification Message']
self.log_send(web_data.values)
row.resp_code = web_data['Response Code']
row.resp_msg = web_data['Notification Message']
......@@ -272,28 +274,28 @@ class View(BaseView):
inq = get_inquiry(data)
if not inq:
raise BillRefNotFound()
#ditambahkan karena harus sesuai dengan inq
# ditambahkan karena harus sesuai dengan inq
DBSession = get_db_session()
iso_log = DBSession.query(Log).\
filter(Log.rpc_id==inq.id,
Log.bit_062 != None).first()
iso_log = DBSession.query(Log). \
filter(Log.rpc_id == inq.id,
Log.bit_062 != None).first()
if not iso_log:
raise BillRefNotFound()
p['bits']={"62": iso_log.bit_062,
"37": "".join(['000000', iso_log.bit_011])}
p['bits'] = {"62": iso_log.bit_062,
"37": "".join(['000000', iso_log.bit_011])}
else:
pay = get_payment(data)
if not pay:
raise BillRefNotFound()
p['stan'] = pay.stan
# ditambahkan disini untuk ngisi user dan cabang
if 'bits' not in p:
p['bits'] = {}
p['bits']['107']='LINKAJA'
p['bits']['49']='AGRATEK-LINKAJA'
p['bits']['107'] = 'LINKAJA'
p['bits']['49'] = 'AGRATEK-LINKAJA'
conn = self.get_connection()
method = get_method(data)
iso_func = getattr(conn.job, method)
......@@ -336,7 +338,7 @@ class View(BaseView):
def view_not_found(self):
msg = 'Path {} tidak ada'.format(self.request.path)
self.log_receive(msg, True)
return self.request.exception
return self.request.exception
def log_prefix(request):
......@@ -344,15 +346,15 @@ def log_prefix(request):
name = web_conf['name']
return '{} {} {}'.format(
request.client_addr, name, id(request))
@view_config(context=BaseError)
def view_exception(exc, request):
r = InquiryResponse()
r = InquiryResponse()
r['Response Code'] = exc.code
r['Notification Message'] = exc.message
prefix = log_prefix(request)
msg = '{} {} {}'.format(prefix, 'Send', r)
msg = '{} {} {}'.format(prefix, 'Send', r)
log_web_error(msg)
response = Response(str(r))
response.status_int = 200
......
......@@ -14,21 +14,14 @@ from opensipkd.string import (
from .structure import INVOICE_PROFILE
from .structure import Transaksi
from .. import View as BaseView
# View as BaseView,
from ..linkaja import (
WebJob,
# View as BaseView,
is_inquiry, get_db_session, is_reversal, is_payment, get_method,
get_form, date_from_str, csv_method, get_template_response, get_inquiry, get_payment)
WebJob, is_inquiry, get_db_session, is_reversal, is_payment, get_method,
get_form, date_from_str, csv_method, get_template_response, get_inquiry,
get_payment)
from ..linkaja.exceptions import (
InvoiceIdError,
NeedPostError,
InternalError,
HostError,
AlreadyPaidError,
BaseError,
AmountError,
BillRefNotFound,
PaymentNotFound,
InvoiceIdError, NeedPostError, InternalError, HostError, AlreadyPaidError,
BaseError, AmountError, BillRefNotFound, PaymentNotFound,
)
from ..linkaja.models import (Rpc, LogSam)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!