From a7dcc7a5e50f599f4bb35afa7c82578f9189bc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 18 Feb 2016 16:05:58 +0100 Subject: [PATCH] general: give same signature to all Payment object constructors (#10030) --- eopayment/__init__.py | 4 ++-- eopayment/common.py | 4 ++-- eopayment/sips.py | 4 ++-- eopayment/sips2.py | 3 --- eopayment/systempayv2.py | 5 +---- eopayment/tipi.py | 5 ----- 6 files changed, 7 insertions(+), 18 deletions(-) diff --git a/eopayment/__init__.py b/eopayment/__init__.py index 39441c8..95ec008 100644 --- a/eopayment/__init__.py +++ b/eopayment/__init__.py @@ -75,9 +75,9 @@ class Payment(object): ''' - def __init__(self, kind, options): + def __init__(self, kind, options, logger=None): self.kind = kind - self.backend = get_backend(kind)(options) + self.backend = get_backend(kind)(options, logger=logger) def request(self, amount, **kwargs): '''Request a payment to the payment backend. diff --git a/eopayment/common.py b/eopayment/common.py index 555cda1..e421878 100644 --- a/eopayment/common.py +++ b/eopayment/common.py @@ -83,8 +83,8 @@ class PaymentCommon(object): PATH = '/tmp' BANK_ID = '__bank_id' - def __init__(self, options): - self.logger = logging.getLogger(self.__class__.__module__) + def __init__(self, options, logger=None): + self.logger = logger or logging.getLogger(self.__class__.__module__) self.logger.debug('initializing with options %s', options) for value in self.description['parameters']: key = value['name'] diff --git a/eopayment/sips.py b/eopayment/sips.py index 47b6d20..301d414 100644 --- a/eopayment/sips.py +++ b/eopayment/sips.py @@ -102,10 +102,10 @@ class Payment(PaymentCommon): ], } - def __init__(self, options, logger=LOGGER): + def __init__(self, options, logger=None): + super(Payment, self).__init__(options, logger=logger) self.options = options self.binpath = self.options.pop(BINPATH) - self.logger = logger self.logger.debug('initializing sips payment class with %s' % options) def execute(self, executable, params): diff --git a/eopayment/sips2.py b/eopayment/sips2.py index 71896a2..f2f4620 100644 --- a/eopayment/sips2.py +++ b/eopayment/sips2.py @@ -112,9 +112,6 @@ class Payment(PaymentCommon): ], } - def __init__(self, options, logger=None): - super(Payment, self).__init__(options) - def encode_data(self, data): return u'|'.join(u'%s=%s' % (unicode(key), unicode(value)) for key, value in data.iteritems()) diff --git a/eopayment/systempayv2.py b/eopayment/systempayv2.py index 7a3b1d2..4442668 100644 --- a/eopayment/systempayv2.py +++ b/eopayment/systempayv2.py @@ -256,12 +256,9 @@ class Payment(PaymentCommon): description['parameters'].append(x) def __init__(self, options, logger=None): - self.service_url = options.pop('service_url', self.service_url) - self.secret_test = options.pop('secret_test') - self.secret_production = options.pop('secret_production', None) + super(Payment, self).__init__(options, logger=logger) options = add_vads(options) self.options = options - self.logger = logger or logging.getLogger(__name__) def request(self, amount, name=None, address=None, email=None, phone=None, orderid=None, info1=None, info2=None, info3=None, diff --git a/eopayment/tipi.py b/eopayment/tipi.py index 2534649..0342965 100644 --- a/eopayment/tipi.py +++ b/eopayment/tipi.py @@ -54,11 +54,6 @@ class Payment(PaymentCommon): ], } - def __init__(self, options, logger=LOGGER): - self.service_url = options.pop('service_url', TIPI_URL) - self.numcli = options.pop('numcli', '') - self.logger = logger - def request(self, amount, next_url=None, exer=None, orderid=None, refdet=None, objet=None, email=None, saisie=None, **kwargs): try: