diff --git a/eopayment/__init__.py b/eopayment/__init__.py index d30d79d..8d9e020 100644 --- a/eopayment/__init__.py +++ b/eopayment/__init__.py @@ -247,3 +247,9 @@ class Payment(object): @property def has_payment_status(self): return hasattr(self.backend, 'payment_status') + + def get_minimal_amount(self): + return getattr(self.backend, 'minimal_amount', None) + + def get_maximal_amount(self): + return getattr(self.backend, 'maximal_amount', None) diff --git a/eopayment/payfip_ws.py b/eopayment/payfip_ws.py index 1503462..34ad98e 100644 --- a/eopayment/payfip_ws.py +++ b/eopayment/payfip_ws.py @@ -17,6 +17,7 @@ from __future__ import print_function, unicode_literals import copy +import decimal import datetime import functools import os @@ -201,6 +202,9 @@ class Payment(PaymentCommon): min_time_between_transactions = 60 * 20 # 20 minutes + minimal_amount = decimal.Decimal('1.0') + maximal_amount = decimal.Decimal('100000.0') + def __init__(self, *args, **kwargs): super(Payment, self).__init__(*args, **kwargs) self.payfip = PayFiP() diff --git a/eopayment/tipi.py b/eopayment/tipi.py index c734db2..d6a9e2a 100644 --- a/eopayment/tipi.py +++ b/eopayment/tipi.py @@ -15,6 +15,7 @@ # along with this program. If not, see . import datetime +import decimal import re import random @@ -76,6 +77,9 @@ class Payment(PaymentCommon): REFDET_RE = re.compile('^[a-zA-Z0-9]{6,30}$') + minimal_amount = decimal.Decimal('1.0') + maximal_amount = decimal.Decimal('100000.0') + def _generate_refdet(self): return '%s%010d' % (datetime.datetime.now(pytz.timezone('Europe/Paris')).strftime('%Y%m%d%H%M%S'), random.randint(1, 1000000000)) diff --git a/tests/test_base_payment.py b/tests/test_base_payment.py index 5909db5..b1f25fe 100644 --- a/tests/test_base_payment.py +++ b/tests/test_base_payment.py @@ -118,3 +118,13 @@ def test_payment_status(monkeypatch): def test_get_min_time_between_transaction(monkeypatch): _, payment = do_mock_backend(monkeypatch) assert payment.get_min_time_between_transactions() == 0 + + +def test_get_minimal_amount(monkeypatch): + _, payment = do_mock_backend(monkeypatch) + assert payment.get_minimal_amount() is None + + +def test_get_maximal_amount(monkeypatch): + _, payment = do_mock_backend(monkeypatch) + assert payment.get_maximal_amount() is None diff --git a/tests/test_payfip_ws.py b/tests/test_payfip_ws.py index b1ce47f..9f391b1 100644 --- a/tests/test_payfip_ws.py +++ b/tests/test_payfip_ws.py @@ -484,3 +484,11 @@ def test_invalid_transaction_id_invalid_orderid(get_idop, backend): def test_get_min_time_between_transactions(backend): assert backend.get_min_time_between_transactions() == 20 * 60 + + +def test_get_minimal_amount(backend): + assert backend.get_minimal_amount() is not None + + +def test_get_maximal_amount(backend): + assert backend.get_maximal_amount() is not None diff --git a/tests/test_tipi.py b/tests/test_tipi.py index d1b48a3..84cd906 100644 --- a/tests/test_tipi.py +++ b/tests/test_tipi.py @@ -115,3 +115,16 @@ def test_tipi_orderid_not_refdef_compatible(): assert parsed_qs['refdet'][0].startswith(datetime.datetime.now().strftime('%Y%m%d')) assert 'coucou' in parsed_qs['objet'][0] assert 'F12-12-12' in parsed_qs['objet'][0] + + +@pytest.fixture +def payment(): + return eopayment.Payment('tipi', {'numcli': '12345'}) + + +def test_get_minimal_amount(payment): + assert payment.get_minimal_amount() is not None + + +def test_get_maximal_amount(payment): + assert payment.get_maximal_amount() is not None