Commit 1c41c941 by Tatang

notif

1 parent 219c39ba
...@@ -215,6 +215,7 @@ def form_result(request, values): ...@@ -215,6 +215,7 @@ def form_result(request, values):
form.render(values) form.render(values)
return dict(form=form, params=dict(scripts="")) return dict(form=form, params=dict(scripts=""))
class ViewData(BaseView): class ViewData(BaseView):
@view_config(route_name='api-merchant-payment', @view_config(route_name='api-merchant-payment',
renderer='templates/form-clean.pt') renderer='templates/form-clean.pt')
...@@ -269,10 +270,11 @@ class ViewData(BaseView): ...@@ -269,10 +270,11 @@ class ViewData(BaseView):
message="Parameter Expected") message="Parameter Expected")
return form_result(request, values) return form_result(request, values)
@view_config(route_name='api-vendor-callback', renderer="templates/form-clean.pt") @view_config(route_name='api-vendor-callback', renderer="templates/form-clean.pt")
def api_vendor_callback(request): def api_vendor_callback(request):
data = request.POST and dict(request.POST.items()) or dict(request.GET.items()) data = request.POST and dict(request.POST.items()) or dict(request.GET.items())
print(data) # print(data)
vendor_nm = request.matchdict['name'] vendor_nm = request.matchdict['name']
modul = '.callback' modul = '.callback'
pckgs = 'agratek.api.merchant.views.{}'.format(vendor_nm) pckgs = 'agratek.api.merchant.views.{}'.format(vendor_nm)
...@@ -280,11 +282,11 @@ def api_vendor_callback(request): ...@@ -280,11 +282,11 @@ def api_vendor_callback(request):
typ = 'proses' typ = 'proses'
log.info("Pckgs: {} Modul:{} typ {}".format(pckgs, modul, typ)) log.info("Pckgs: {} Modul:{} typ {}".format(pckgs, modul, typ))
cls = hasattr(moduls, typ) and getattr(moduls, typ) or None cls = hasattr(moduls, typ) and getattr(moduls, typ) or None
print(dir(cls)) # print(dir(cls))
if cls: if cls:
result = cls(data) result = cls(data)
if result: if result:
return dict(form=result["form"]) return dict(form=result["form"])
qs =get_qs(data) qs = get_qs(data)
return HTTPFound(location=request.route_url("api-merchant-register-callback", _query=qs)) return HTTPFound(location=request.route_url("api-merchant-register-callback", _query=qs))
return dict(form="<h1>ERROR</h1>")
\ No newline at end of file \ No newline at end of file
# return dict(form="<h1>ERROR</h1>")
...@@ -520,6 +520,7 @@ class Vendor(VendorClass): # VendorClass ...@@ -520,6 +520,7 @@ class Vendor(VendorClass): # VendorClass
signature = sha256("{mid}{vend_inv_no}{amount}{key}" \ signature = sha256("{mid}{vend_inv_no}{amount}{key}" \
.format(mid=self.mid, key=self.key, amount=str(amount), .format(mid=self.mid, key=self.key, amount=str(amount),
vend_inv_no=vend_inv_no)) vend_inv_no=vend_inv_no))
# print('>>>>', signature)
if merchant_token != signature: if merchant_token != signature:
return return
...@@ -534,35 +535,57 @@ class Vendor(VendorClass): # VendorClass ...@@ -534,35 +535,57 @@ class Vendor(VendorClass): # VendorClass
flush_row(self.invoice_det) flush_row(self.invoice_det)
self.response = data self.response = data
self.result = get_result(self.response, self.pay_method) self.result = get_result(self.response, self.pay_method)
self.save_log("notify") self.save_log("notify")
return self.result return self.result
def get_result(response, pay_method): def get_result(response, pay_method):
status = "status" in response and response['status'] and int(response["status"]) + 1 or 1
try:
code = int(response["resultCd"])
except:
code = 0
try:
message = response["resultMsg"]
except:
message = ''
result = dict( result = dict(
code=int(response["resultCd"]), code=code,
message=response["resultMsg"], message=message,
# cancel_amt=response["cancelAmt"], # cancel_amt="cancelAmt" in response and int(response["cancelAmt"]) or 0,
# deposit_date=response["depositDt"], # deposit_date="depositDt" in response and response["depositDt"] or "",
# deposit_time=response["depositTm"], # deposit_time="depositTm" in response and response["depositTm"] or "",
# tx_id=response[''], # <=
invoice_no="referenceNo" in response and response["referenceNo"] or "",
amount="amt" in response and int(response["amt"]) or 0,
match_cl="matchCl" in response and int(response["matchCl"]) or 0,
status=status,
trans_date="transDt" in response and response["transDt"] or "",
trans_time="transTm" in response and response["transTm"] or "",
currency="currency" in response and response["currency"] or "",
description="goodsNm" in response and response["goodsNm"] or "",
customer_nm="billingNm" in response and response["billingNm"] or "",
) )
if pay_method == "01": if pay_method == "01":
result.update(dict( result.update(dict(
cc=dict( credit_card=dict(
auth_no=response["authNo"], auth_no=response["authNo"],
issue_bank=response["issuBankCd"], issue_bank=response["issuBankCd"],
issue_bank_nm='issuBankNm' in response and response["issuBankNm"] or "", issue_bank_nm='issuBankNm' in response and response["issuBankNm"] or "",
acqu_bank=response["acquBankCd"], acqu_bank=response["acquBankCd"],
acqu_bank_nm='acquBankNm' in response and response["acquBankNm"] or "", acqu_bank_nm='acquBankNm' in response and response["acquBankNm"] or "",
acqu_status='acquStatus' in response and response["acquStatus"] or "", acqu_status='acquStatus' in response and response["acquStatus"] or "",
card_no=response["cardNo"], card_no='cardNo' in response and response["cardNo"] or "",
card_exp=response["cardExpYymm"], card_exp='cardExpYymm' in response and response["cardExpYymm"] or "",
instmnt_mon=response["instmntMon"], instmnt_mon='instmntMon' in response and response["instmntMon"] or "",
instmnt_tpe=response["instmntType"], instmnt_tpe='instmntType' in response and response["instmntType"] or "",
preauth_token=response["preauthToken"], preauth_token='preauthToken' in response and response["preauthToken"] or "",
recurring_token=response["recurringToken"], recurring_token='recurringToken' in response and response["recurringToken"] or "",
cc_trans_type=response["ccTransType"], cc_trans_type='ccTransType' in response and response["ccTransType"] or "",
vat="vat" in response and int(response["vat"]) or 0, vat="vat" in response and int(response["vat"]) or 0,
fee="fee" in response and int(response["fee"]) or 0, fee="fee" in response and int(response["fee"]) or 0,
no_tax_amt="notaxAmt" in response and int(response["notaxAmt"]) or 0, no_tax_amt="notaxAmt" in response and int(response["notaxAmt"]) or 0,
...@@ -605,7 +628,9 @@ def get_result(response, pay_method): ...@@ -605,7 +628,9 @@ def get_result(response, pay_method):
va=dict( va=dict(
vaacct_no=response["vacctNo"], vaacct_no=response["vacctNo"],
valid_date=response["vacctValidDt"], valid_date=response["vacctValidDt"],
valid_time=response["vacctValidTm"] valid_time=response["vacctValidTm"],
deposit_date="depositDt" in response and response["depositDt"] or "",
deposit_time="depositTm" in response and response["depositTm"] or "",
) )
)) ))
else: else:
...@@ -625,16 +650,18 @@ def get_result(response, pay_method): ...@@ -625,16 +650,18 @@ def get_result(response, pay_method):
valid_date="payValidDt" in response and response["payValidDt"] or "", valid_date="payValidDt" in response and response["payValidDt"] or "",
valid_time="payValidTm" in response and response["payValidTm"] or "", valid_time="payValidTm" in response and response["payValidTm"] or "",
m_ref_no="mRefNo" in response and response["mRefNo"] or "", m_ref_no="mRefNo" in response and response["mRefNo"] or "",
receipt_code="receiptCode" in response and response["receiptCode"] or "" receipt_code="receiptCode" in response and response["receiptCode"] or "",
deposit_date="depositDt" in response and response["depositDt"] or "",
deposit_time="depositTm" in response and response["depositTm"] or "",
) )
if pay_method == "03": if pay_method == "03":
result.update({"cvs": other}) result.update({"cvs": other})
elif pay_method == "04": elif pay_method == "04":
result.update({"cp": other}) result.update({"cp": other})
elif pay_method == "05": elif pay_method == "05":
result.update({"wl": other}) result.update({"wallet": other})
else: else:
result.update({"pl": other}) result.update({"loan": other})
return result return result
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!