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
import hashlib
from zLOG import LOG, WARNING
import datetime
import os
import time
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:
import suds
except ImportError:
class PayzenSOAP:
pass
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:
"""SOAP communication
......@@ -49,6 +77,7 @@ else:
signature = self._getSignature(data, received_sorted_keys)
return signature == data.signature
@setUTCTimeZone
def soap_getInfo(self, transmissionDate, transactionId):
"""Returns getInfo as dict, booelan, string, string
......@@ -107,6 +136,7 @@ else:
return [data_kw, signature, last_sent, last_received]
@setUTCTimeZone
def soap_duplicate(self, transmissionDate, transactionId, presentationDate,
newTransactionId, amount, devise, orderId='', orderInfo='', orderInfo2='',
orderInfo3='', validationMode=0, comment=''):
......@@ -168,6 +198,7 @@ else:
return [data_kw, signature, last_sent, last_received]
@setUTCTimeZone
def soap_cancel(self, transmissionDate, transactionId, comment=''):
# prepare with passed parameters
kw = dict(transmissionDate=transmissionDate, transactionId=transactionId,
......@@ -221,6 +252,12 @@ else:
signature = False
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):
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