Commit 3d1410b6 authored by Łukasz Nowak's avatar Łukasz Nowak

Be more defensive.

Really never raise (trust no one). Always return excepted values in order
to not trick caller.
parent eca31be5
...@@ -69,10 +69,13 @@ else: ...@@ -69,10 +69,13 @@ else:
return signature == data.signature return signature == data.signature
def soap_getInfo(self, transmissionDate, transactionId): def soap_getInfo(self, transmissionDate, transactionId):
"""Returns getInfo """Returns getInfo as dict, booelan, string, string
transmissionDate is "raw" date in format YYYYMMDD, without any marks transmissionDate is "raw" date in format YYYYMMDD, without any marks
transactionId is id of transaction for this date""" transactionId is id of transaction for this date
As soon as communication happeneded does not raise.
"""
client = suds.client.Client(self.wsdl_link.getUrlString()) client = suds.client.Client(self.wsdl_link.getUrlString())
sorted_keys = ('shopId', 'transmissionDate', 'transactionId', sorted_keys = ('shopId', 'transmissionDate', 'transactionId',
'sequenceNb', 'ctxMode') 'sequenceNb', 'ctxMode')
...@@ -98,19 +101,40 @@ else: ...@@ -98,19 +101,40 @@ else:
# Note: Code shall not raise since now, as communication begin and caller # Note: Code shall not raise since now, as communication begin and caller
# will have to log sent/received messages. # will have to log sent/received messages.
data = client.service.getInfo(**kw) data = client.service.getInfo(**kw)
data_kw = dict(data)
for k in data_kw.keys():
v = data_kw[k]
if not isinstance(v, str):
data_kw[k] = str(v)
try: try:
signature = self._check_transcationInfoSignature(data) data_kw = dict(data)
for k in data_kw.keys():
v = data_kw[k]
if not isinstance(v, str):
data_kw[k] = str(v)
except Exception:
data_kw = {}
signature = False
LOG('PayzenService', WARNING,
'Issue during processing data_kw:', error=True)
else:
try:
signature = self._check_transcationInfoSignature(data)
except Exception:
LOG('PayzenService', WARNING, 'Issue during signature calculation:',
error=True)
signature = False
try:
last_sent = str(client.last_sent())
except Exception: except Exception:
LOG('PayzenService', WARNING, 'Issue during signature calculation:', LOG('PayzenService', WARNING,
error=True) 'Issue during converting last_sent to string:', error=True)
signature = False signature = False
return [data_kw, signature, str(client.last_sent()),
str(client.last_received())] try:
last_received = str(client.last_received())
except Exception:
LOG('PayzenService', WARNING,
'Issue during converting last_received to string:', error=True)
signature = False
return [data_kw, signature, last_sent, last_received]
class PayzenService(XMLObject, PayzenSOAP): class PayzenService(XMLObject, PayzenSOAP):
meta_type = 'Payzen Service' meta_type = 'Payzen Service'
......
34 35
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment