Projet

Général

Profil

0002-misc-declare-an-optional-method-on-Payment-payment_s.patch

Benjamin Dauvergne, 03 novembre 2020 11:22

Télécharger (1,38 ko)

Voir les différences:

Subject: [PATCH 2/3] misc: declare an optional method on Payment,
 payment_status(**kwargs)

Set as None to ease checks by client code of the availability of this method.
 eopayment/__init__.py | 5 +++++
 eopayment/common.py   | 2 ++
 2 files changed, 7 insertions(+)
eopayment/__init__.py
232 232
    @property
233 233
    def has_free_transaction_id(self):
234 234
        return self.backend.has_free_transaction_id
235

  
236
    def payment_status(self, transaction_id, **kwargs):
237
        if not self.backend.payment_status:
238
            raise NotImplementedError('payment_status is not implemented on this backend')
239
        return self.backend.payment_status(transaction_id=transaction_id, **kwargs)
eopayment/common.py
185 185
            amount = amount.to_integral_value(ROUND_DOWN)
186 186
        return str(amount)
187 187

  
188
    payment_status = None
189

  
188 190

  
189 191
class Form(object):
190 192
    def __init__(self, url, method, fields, encoding='utf-8',
191
-