Commit ab930151 by vm.dev

Update from VM Dev

1 parent 65a70ae2
......@@ -159,7 +159,7 @@ class View(BaseView):
# conn = self.get_connection()
method = get_method(data)
# iso_func = getattr(conn.job, method)
iso_req = Transaksi(p, method, inq, pay)
iso_req = Transaksi(p, method, inq, pay, conf)
row = self.before_send_iso(data, inq, pay, iso_req)
iso_req.send()
if type(iso_req.response) != dict:
......
# import colander
# from opensipkd.string.row import Row
# from .exceptions import InternalError
import json
from iso8583_web.scripts.logger import (
log_web_info,
log_web_debug)
......@@ -70,20 +71,29 @@ PAY_REQ = \
}
def send_data(json_data):
settings = get_settings()
pload = {'username': 'olivia', 'password': '123'}
def send_data(json_data, conf):
#settings = get_settings()
#pload = {'username': 'olivia', 'password': '123'}
bjb_sambat_url = "bjb_sambat_url" in settings and settings["bjb_sambat_url"] or \
bjb_sam_url = "bjb_sam_url" in conf and conf["bjb_sam_url"] or \
"http://localhost:7001/bjb/sambat/test"
data = json_data
# todo butuh server buat testing json sementara pake static response
if json_data["processingCode"] == '321000':
return INQ_RESP
bjb_sam_url+="/inquiryPaymentRest"
# return INQ_RESP
elif json_data["processingCode"] == '521000':
return PAY_RESP
bjb_sam_url+="/paymentRest"
# return PAY_RESP
r = requests.post(bjb_sambat_url, data=data)
#data=json.dumps(data)
log_web_info(data)
r = requests.post(bjb_sam_url, json=data)
if r:
log_web_info(r.text)
#log_web_info(r.code)
log_web_info(r.json)
if r.text:
try:
return r.json()
......@@ -94,8 +104,9 @@ def send_data(json_data):
class Transaksi(object):
def __init__(self, p, method, inq, pay):
def __init__(self, p, method, inq, pay, conf):
self.settings = get_settings()
self.conf = conf
self.response = None
if method == "reversal": # data Payment ada (berarti reversal)
self.mti = "0400"
......@@ -121,22 +132,23 @@ class Transaksi(object):
else:
self.mti = "0200"
self.data = INQ_REQ.copy()
self.data["caCode"] = "ca_code" in self.settings and self.settings["ca_code"] or "1234"
#self.data["systemTraceAuditNumber"] = "880977"
self.data["caCode"] = "ca_code" in conf and conf["ca_code"] or "123456"
self.data["processingCode"] = "321000"
self.data["billInformation"]["bills"][0]["info"] = p["invoice_id"]
self.set_local_time()
def set_local_time(self):
time = datetime.now()
self.data["timeLocalTransaction"] = time.strftime("%HHmiss")
self.data["localTransactionDate"] = time.strftime("%MMDD")
self.data["transmissionDateTime"] = time.strftime("%MMDDHHmiss")
self.data["timeLocalTransaction"] = time.strftime("%H%M%S")
self.data["localTransactionDate"] = time.strftime("%m%d")
self.data["transmissionDateTime"] = time.strftime("%m%d%H%M%S")
def get_stan(self):
return self.data["systemTraceAuditNumber"]
def send(self):
self.response = send_data(self.data)
self.response = send_data(self.data, self.conf)
self.mti = self.mti == "0200" and "0210" or "0410"
INVOICE_PROFILE = [
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!