summaryrefslogtreecommitdiff
path: root/addons/payment_sips
diff options
context:
space:
mode:
Diffstat (limited to 'addons/payment_sips')
-rw-r--r--addons/payment_sips/models/payment.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/addons/payment_sips/models/payment.py b/addons/payment_sips/models/payment.py
index 4c49c2a4f33..bc44b5c68b0 100644
--- a/addons/payment_sips/models/payment.py
+++ b/addons/payment_sips/models/payment.py
@@ -2,8 +2,11 @@
# Copyright 2015 Eezee-It
+import datetime
+from dateutil import parser
import json
import logging
+import pytz
import re
import time
from hashlib import sha256
@@ -182,10 +185,22 @@ class TxSips(models.Model):
def _sips_form_validate(self, data):
data = self._sips_data_to_object(data.get('Data'))
status = data.get('responseCode')
+ date = data.get('transactionDateTime')
+ if date:
+ try:
+ # dateutil.parser 2.5.3 and up should handle dates formatted as
+ # '2020-04-08T05:54:18+02:00', which strptime does not
+ # (+02:00 does not work as %z expects +0200 before Python 3.7)
+ # See odoo/odoo#49160
+ date = parser.parse(date).astimezone(pytz.utc).replace(tzinfo=None)
+ except:
+ # will fallback on now in the write to avoid failing to
+ # register the payment because a provider formats their
+ # dates badly or because some local library is not behaving
+ date = False
data = {
'acquirer_reference': data.get('transactionReference'),
- 'date': data.get('transactionDateTime',
- fields.Datetime.now())
+ 'date': date or fields.Datetime.now(),
}
res = False
if status in self._sips_valid_tx_status: