summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2020-10-11 07:35:50 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2020-10-11 07:35:50 (GMT)
commit3ac360abe836b204051b18c5192e2a880bb3404b (patch)
tree77b4ff65ecdc97dbe3b80686ee23168485eeec19
parentaf7a82ee096ed9664af5bfaa544e9ad2629f831e (diff)
downloadeopayment-3ac360abe836b204051b18c5192e2a880bb3404b.zip
eopayment-3ac360abe836b204051b18c5192e2a880bb3404b.tar.gz
eopayment-3ac360abe836b204051b18c5192e2a880bb3404b.tar.bz2
tipi: use Paris timezone for generating refdet (#46237)
-rw-r--r--eopayment/tipi.py8
-rw-r--r--tests/test_tipi.py4
2 files changed, 8 insertions, 4 deletions
diff --git a/eopayment/tipi.py b/eopayment/tipi.py
index d76afe4..abcbafa 100644
--- a/eopayment/tipi.py
+++ b/eopayment/tipi.py
@@ -14,9 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import datetime
import re
import random
+import pytz
+
from .common import (PaymentCommon, PaymentResponse, URL, PAID, DENIED,
CANCELLED, ERROR, ResponseError)
from six.moves.urllib.parse import urlencode, parse_qs
@@ -25,8 +28,6 @@ from gettext import gettext as _
import logging
import warnings
-from .systempayv2 import isonow
-
__all__ = ['Payment']
TIPI_URL = 'https://www.tipi.budget.gouv.fr/tpa/paiement.web'
@@ -85,7 +86,8 @@ class Payment(PaymentCommon):
REFDET_RE = re.compile('^[a-zA-Z0-9]{6,30}$')
def _generate_refdet(self):
- return '%s%010d' % (isonow(), random.randint(1, 1000000000))
+ return '%s%010d' % (datetime.datetime.now(pytz.timezone('Europe/Paris')).strftime('%Y%m%d%H%M%S'),
+ random.randint(1, 1000000000))
def request(self, amount, next_url=None, exer=None, orderid=None,
refdet=None, objet=None, email=None, saisie=None, **kwargs):
diff --git a/tests/test_tipi.py b/tests/test_tipi.py
index 3f525fa..d1b48a3 100644
--- a/tests/test_tipi.py
+++ b/tests/test_tipi.py
@@ -18,6 +18,8 @@ import datetime
from decimal import Decimal
from six.moves.urllib.parse import urlparse, parse_qs
+import pytz
+
import eopayment
import eopayment.tipi
import pytest
@@ -70,7 +72,7 @@ def test_tipi_no_orderid_no_refdet():
assert parsed_qs['mel'] == ['info@entrouvert.com']
assert parsed_qs['numcli'] == ['12345']
assert parsed_qs['exer'] == ['9999']
- assert parsed_qs['refdet'][0].startswith(datetime.datetime.now().strftime('%Y%m%d'))
+ assert parsed_qs['refdet'][0].startswith(datetime.datetime.now(pytz.timezone('Europe/Paris')).strftime('%Y%m%d'))
def test_tipi_orderid_refdef_compatible():