Projet

Général

Profil

0001-paybox-add-support-for-payment-authorization-only-27.patch

Serghei Mihai, 11 octobre 2018 19:24

Télécharger (2,47 ko)

Voir les différences:

Subject: [PATCH] paybox: add support for payment authorization only (#27269)

 eopayment/paybox.py  |  8 ++++++++
 tests/test_paybox.py | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+)
eopayment/paybox.py
229 229
                'validation': lambda x: isinstance(x, basestring) and
230 230
                x.isdigit() and (1 <= len(x) <= 2)
231 231
            },
232
            {
233
                'name': 'capture_mode',
234
                'caption': _('Capture Mode'),
235
                'default': False,
236
                'required': False,
237
            },
232 238
        ]
233 239
    }
234 240

  
......
263 269
            automatic_return_url = self.callback
264 270
        if self.capture_day:
265 271
            d['PBX_DIFF'] = self.capture_day.zfill(2)
272
        if self.capture_mode:
273
            d['PBX_AUTOSEULE'] = 'O'
266 274
        if automatic_return_url:
267 275
            d['PBX_REPONDRE_A'] = force_text(automatic_return_url)
268 276
        d = d.items()
tests/test_paybox.py
104 104
            self.assertIn('PBX_DIFF', form_params)
105 105
            self.assertEqual(form_params['PBX_DIFF'], '07')
106 106

  
107
    def test_request_with_authorization_only(self):
108
        params = BACKEND_PARAMS.copy()
109
        time = '2018-08-21T10:26:32+02:00'
110
        email = 'user@entrouvert.com'
111
        order_id = '20180821'
112
        transaction = '1234'
113
        amount = '42.99'
114

  
115
        params['capture_mode'] = True
116
        backend = eopayment.Payment('paybox', params)
117
        transaction_id, kind, what = backend.request(
118
            Decimal(amount), email=email, orderid=order_id,
119
            transaction_id=transaction, time=time)
120
        root = ET.fromstring(str(what))
121

  
122
        form_params = dict(((node.attrib['name'], node.attrib['value']) for node in root if node.attrib['type'] == 'hidden'))
123
        self.assertIn('PBX_AUTOSEULE', form_params)
124
        self.assertEqual(form_params['PBX_AUTOSEULE'], 'O')
125

  
107 126
    def test_response(self):
108 127
        backend = eopayment.Payment('paybox', BACKEND_PARAMS)
109 128
        order_id = '20160216'
110
-