Commit 4f72dce1 by Owo Sugiana

linkaja: validasi prefix Invoice ID PBB

1 parent 66a42da5
0.3.4 2020-10-03 0.3.4 2020-10-06
---------------- ----------------
- Validasi prefix Invoice ID PBB LinkAja
- Saat payment linkaja mengambil invoice ID berdasarkan Bill Ref - Saat payment linkaja mengambil invoice ID berdasarkan Bill Ref
0.3.3 2020-09-14 0.3.3 2020-09-14
......
...@@ -94,4 +94,5 @@ module = opensipkd.iso8583.bjb.pbb.test ...@@ -94,4 +94,5 @@ module = opensipkd.iso8583.bjb.pbb.test
[module_opensipkd.iso8583.bjb.pbb.test] [module_opensipkd.iso8583.bjb.pbb.test]
request_bits = request_bits =
18:6025 18:6025
32:110
33:00110 33:00110
from pyramid.response import Response
from pyramid.view import view_config from pyramid.view import view_config
from deform import ValidationFailure from deform import ValidationFailure
from sqlalchemy import create_engine from sqlalchemy import create_engine
...@@ -52,19 +51,6 @@ def log_receive(self, msg, error=False): ...@@ -52,19 +51,6 @@ def log_receive(self, msg, error=False):
log_web_info(msg) log_web_info(msg)
@view_config(context=BaseError)
def view_exception(exc, request):
r = InquiryResponse()
r['Response Code'] = exc.code
r['Notification Message'] = exc.message
prefix = log_prefix(request)
msg = f'{prefix} Send {r}'
log_web_error(msg)
response = Response(str(r))
response.status_int = 200
return response
def pyramid_init(pyramid_config, h2h_conf, route_name): def pyramid_init(pyramid_config, h2h_conf, route_name):
pyramid_config.add_renderer(RENDERER, 'pyramid_linkaja.renderer.Renderer') pyramid_config.add_renderer(RENDERER, 'pyramid_linkaja.renderer.Renderer')
path = h2h_conf['route_path'] path = h2h_conf['route_path']
......
import transaction import transaction
from pyramid.view import view_config
from pyramid.response import Response
from ISO8583.ISOErrors import BitNotSet from ISO8583.ISOErrors import BitNotSet
from opensipkd.string import FixLength from opensipkd.string import FixLength
from opensipkd.iso8583.bjb.pbb.structure import INVOICE_PROFILE from opensipkd.iso8583.bjb.pbb.structure import INVOICE_PROFILE
from opensipkd.iso8583.bjb.pbb.agratek.models import Log from opensipkd.iso8583.bjb.pbb.agratek.models import Log
from iso8583_web.scripts.tools import iso_to_dict
from pyramid_linkaja.exceptions import ( from pyramid_linkaja.exceptions import (
InvoiceIdError, InvoiceIdError,
TrxTypeError, TrxTypeError,
...@@ -13,6 +14,7 @@ from pyramid_linkaja.exceptions import ( ...@@ -13,6 +14,7 @@ from pyramid_linkaja.exceptions import (
BillRefNotFound, BillRefNotFound,
PaymentNotFound, PaymentNotFound,
LinkError, LinkError,
BaseError,
) )
from pyramid_linkaja.responses import ( from pyramid_linkaja.responses import (
InquiryResponse, InquiryResponse,
...@@ -24,6 +26,9 @@ from pyramid_linkaja.responses import ( ...@@ -24,6 +26,9 @@ from pyramid_linkaja.responses import (
is_reversal, is_reversal,
) )
from pyramid_linkaja.decorator import csv_method from pyramid_linkaja.decorator import csv_method
from iso8583_web.scripts.logger import log_web_error
from iso8583_web.scripts.tools import iso_to_dict
from .. import log_prefix
from . import View as BaseView from . import View as BaseView
from . import pyramid_init as base_pyramid_init from . import pyramid_init as base_pyramid_init
...@@ -59,6 +64,19 @@ def get_ok_notify(data): ...@@ -59,6 +64,19 @@ def get_ok_notify(data):
return '' return ''
@view_config(context=BaseError)
def view_exception(exc, request):
r = InquiryResponse()
r['Response Code'] = exc.code
r['Notification Message'] = exc.message
prefix = log_prefix(request)
msg = f'{prefix} Send {r}'
log_web_error(msg)
response = Response(str(r))
response.status_int = 200
return response
class View(BaseView): class View(BaseView):
def get_db_session(self): # Override def get_db_session(self): # Override
return get_db_session() return get_db_session()
...@@ -154,7 +172,13 @@ class View(BaseView): ...@@ -154,7 +172,13 @@ class View(BaseView):
s += inq.msg s += inq.msg
return s return s
def validate_data(self, data):
prefix_found = get_ok_notify(data)
if not prefix_found:
raise InvoiceIdError()
def get_response(self, data): # Override def get_response(self, data): # Override
self.validate_data(data)
p, inq, pay = self.prepare_response(data) p, inq, pay = self.prepare_response(data)
conn = self.get_connection() conn = self.get_connection()
method = get_method(data) method = get_method(data)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!