misc: add payment_status method to Payment (#47670)

This commit is contained in:
Benjamin Dauvergne 2020-10-14 11:31:20 +02:00
parent f1fbcc6982
commit 5b5f4c165b
3 changed files with 16 additions and 1 deletions

View File

@ -232,3 +232,8 @@ class Payment(object):
@property
def has_free_transaction_id(self):
return self.backend.has_free_transaction_id
def payment_status(self, transaction_id, **kwargs):
if not self.backend.payment_status:
raise NotImplementedError('payment_status is not implemented on this backend')
return self.backend.payment_status(transaction_id=transaction_id, **kwargs)

View File

@ -185,6 +185,8 @@ class PaymentCommon(object):
amount = amount.to_integral_value(ROUND_DOWN)
return str(amount)
payment_status = None
class Form(object):
def __init__(self, url, method, fields, encoding='utf-8',

View File

@ -20,10 +20,11 @@ import mock
import pytest
import eopayment
from eopayment.common import PaymentCommon
def do_mock_backend(monkeypatch):
class MockBackend(object):
class MockBackend(PaymentCommon):
request = mock.Mock()
description = {
@ -107,3 +108,10 @@ def test_get_parameters(monkeypatch):
transaction_parameters = payment.get_parameters(scope='transaction')
assert len(transaction_parameters) == 1
assert transaction_parameters[0]['name'] == 'manual_validation'
def test_payment_status(monkeypatch):
_, payment = do_mock_backend(monkeypatch)
with pytest.raises(NotImplementedError):
payment.payment_status('whatever')