Project

General

Profile

0001-implement-payzen-backend-by-inheriing-systempayv2-fi.patch

Benjamin Dauvergne, 03 November 2015 11:34 PM

Download (3.82 KB)

View differences:

Subject: [PATCH] implement payzen backend by inheriing systempayv2 (fixes
 #8854)

 eopayment/__init__.py    |  3 ++-
 eopayment/payzen.py      | 12 ++++++++++++
 eopayment/systempayv2.py | 14 +++++++-------
 3 files changed, 21 insertions(+), 8 deletions(-)
 create mode 100644 eopayment/payzen.py
eopayment/__init__.py
15 15
DUMMY = 'dummy'
16 16
OGONE = 'ogone'
17 17
PAYBOX = 'paybox'
18
PAYZEN = 'payzen'
18 19

  
19 20

  
20 21
def get_backend(kind):
......
22 23
    module = __import__(kind, globals(), locals(), [])
23 24
    return module.Payment
24 25

  
25
__BACKENDS = [ DUMMY, SIPS, SYSTEMPAY, SPPLUS, OGONE, PAYBOX ]
26
__BACKENDS = [ DUMMY, SIPS, SYSTEMPAY, SPPLUS, OGONE, PAYBOX, PAYZEN ]
26 27

  
27 28
def get_backends():
28 29
    '''Return a dictionnary mapping existing eopayment backends name to their
eopayment/payzen.py
1
from copy import deepcopy
2

  
3
from . import systempayv2
4

  
5
__all__ = ['Payment']
6

  
7
class Payment(systempayv2.Payment):
8
    service_url = 'https://secure.payzen.eu/vads-payment/'
9

  
10
    description = deepcopy(systempayv2.Payment.description)
11
    description['caption'] = 'PayZen'
12
    description['parameters'][0]['name'] = service_url
eopayment/systempayv2.py
12 12

  
13 13
__all__ = ['Payment']
14 14

  
15
SERVICE_URL = "https://paiement.systempay.fr/vads-payment/"
16
LOGGER = logging.getLogger(__name__)
17 15
VADS_TRANS_DATE = 'vads_trans_date'
18 16
VADS_AUTH_NUMBER = 'vads_auth_number'
19 17
VADS_AUTH_RESULT = 'vads_auth_result'
......
211 209
            'vads_return_mode': 'NONE'})
212 210

  
213 211
    '''
212
    service_url = "https://paiement.systempay.fr/vads-payment/"
213

  
214 214
    description = {
215 215
        'caption': 'SystemPay, système de paiment du groupe BPCE',
216 216
        'parameters': [
217 217
            {'name': 'service_url',
218
                'default': SERVICE_URL,
218
                'default': service_url,
219 219
                'caption': _(u'URL du service de paiment'),
220 220
                'help_text': _(u'ne pas modifier si vous ne savez pas'),
221 221
                'validation': lambda x: x.startswith('http'),
......
243 243
             'max_length': parameter.max_length}
244 244
        description['parameters'].append(x)
245 245

  
246
    def __init__(self, options, logger=LOGGER):
247
        self.service_url = options.pop('service_url', SERVICE_URL)
246
    def __init__(self, options, logger=None):
247
        self.service_url = options.pop('service_url', self.service_url)
248 248
        self.secret_test = options.pop('secret_test')
249 249
        self.secret_production = options.pop('secret_production', None)
250 250
        options = add_vads(options)
251 251
        self.options = options
252
        self.logger = logger
252
        self.logger = logger or logging.getLogger(__name__)
253 253

  
254 254
    def request(self, amount, name=None, address=None, email=None, phone=None,
255 255
                info1=None, info2=None, info3=None, next_url=None, **kwargs):
......
304 304
        transaction_id = '%s_%s' % (fields[VADS_TRANS_DATE], transaction_id)
305 305
        self.logger.debug('%s transaction id: %s', __name__, transaction_id)
306 306
        form = Form(
307
                url=SERVICE_URL,
307
                url=self.service_url,
308 308
                method='POST',
309 309
                fields=[{'type': 'hidden',
310 310
                        'name': name,
311
-