Commit 991950c5 authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify calculation and reformat dates.

Dates in signature have to be in %Y%m%d format.

Note: Signatures still do not match.
parent bb4db5fe
...@@ -42,11 +42,17 @@ else: ...@@ -42,11 +42,17 @@ else:
'refundDevise', 'timestamp'] 'refundDevise', 'timestamp']
signature = '' signature = ''
for k in received_sorted_keys: for k in received_sorted_keys:
v = getattr(data, k, None) try:
if v is not None: v = getattr(data, k)
signature += str(v) + '+' except AttributeError:
pass
else: else:
signature += '+' if k in ['transmissionDate', 'presentationDate', 'cardExpirationDate',
'markDate', 'authDate', 'captureDate']:
# crazyiness again
v = time.strftime('%Y%m%d', time.strptime(str(v), '%Y-%m-%d %H:%M:%S'))
v = str(v)
signature += v + '+'
signature += self.getServicePassword() signature += self.getServicePassword()
signature = hashlib.sha1(signature).hexdigest() signature = hashlib.sha1(signature).hexdigest()
return signature == data.signature return signature == data.signature
......
25 26
\ 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