Commit 862a9905 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Alain Takoudjou

Force UTC usage.

PayZen interface expectes all dates in UTC, but suds library is not configurable.
So force UTC usage while importing and using suds, so no date mangling will happen.

Conflicts:
	bt5/erp5_payzen_secure_payment/bt/revision
parent 9c644414
...@@ -6,14 +6,42 @@ from Products.ERP5Type.Document import newTempDocument ...@@ -6,14 +6,42 @@ from Products.ERP5Type.Document import newTempDocument
import hashlib import hashlib
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
import datetime import datetime
import os
import time
from Products.DCWorkflow.DCWorkflow import ValidationFailed from Products.DCWorkflow.DCWorkflow import ValidationFailed
present = False
tz = None
if 'TZ' in os.environ:
present = True
tz = os.environ['TZ']
os.environ['TZ'] = 'UTC'
time.tzset()
try: try:
import suds import suds
except ImportError: except ImportError:
class PayzenSOAP: class PayzenSOAP:
pass pass
else: else:
def setUTCTimeZone(fn):
def wrapped(*args, **kwargs):
present = False
tz = None
if 'TZ' in os.environ:
present = True
tz = os.environ['TZ']
os.environ['TZ'] = 'UTC'
time.tzset()
try:
return fn(*args, **kwargs)
finally:
if present:
os.environ['TZ'] = tz
else:
del(os.environ['TZ'])
time.tzset()
return wrapped
class PayzenSOAP: class PayzenSOAP:
"""SOAP communication """SOAP communication
...@@ -49,6 +77,7 @@ else: ...@@ -49,6 +77,7 @@ else:
signature = self._getSignature(data, received_sorted_keys) signature = self._getSignature(data, received_sorted_keys)
return signature == data.signature return signature == data.signature
@setUTCTimeZone
def soap_getInfo(self, transmissionDate, transactionId): def soap_getInfo(self, transmissionDate, transactionId):
"""Returns getInfo as dict, booelan, string, string """Returns getInfo as dict, booelan, string, string
...@@ -107,6 +136,7 @@ else: ...@@ -107,6 +136,7 @@ else:
return [data_kw, signature, last_sent, last_received] return [data_kw, signature, last_sent, last_received]
@setUTCTimeZone
def soap_duplicate(self, transmissionDate, transactionId, presentationDate, def soap_duplicate(self, transmissionDate, transactionId, presentationDate,
newTransactionId, amount, devise, orderId='', orderInfo='', orderInfo2='', newTransactionId, amount, devise, orderId='', orderInfo='', orderInfo2='',
orderInfo3='', validationMode=0, comment=''): orderInfo3='', validationMode=0, comment=''):
...@@ -168,6 +198,7 @@ else: ...@@ -168,6 +198,7 @@ else:
return [data_kw, signature, last_sent, last_received] return [data_kw, signature, last_sent, last_received]
@setUTCTimeZone
def soap_cancel(self, transmissionDate, transactionId, comment=''): def soap_cancel(self, transmissionDate, transactionId, comment=''):
# prepare with passed parameters # prepare with passed parameters
kw = dict(transmissionDate=transmissionDate, transactionId=transactionId, kw = dict(transmissionDate=transmissionDate, transactionId=transactionId,
...@@ -221,6 +252,12 @@ else: ...@@ -221,6 +252,12 @@ else:
signature = False signature = False
return [data_kw, signature, last_sent, last_received] return [data_kw, signature, last_sent, last_received]
finally:
if present:
os.environ['TZ'] = tz
else:
del(os.environ['TZ'])
time.tzset()
class PayzenService(XMLObject, PayzenSOAP): class PayzenService(XMLObject, PayzenSOAP):
meta_type = 'Payzen Service' meta_type = 'Payzen Service'
......
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