Projet

Général

Profil

0001-ogone-handle-properly-unicode-params-13592.patch

Serghei Mihai (congés, retour 15/05), 20 octobre 2016 17:03

Télécharger (2,31 ko)

Voir les différences:

Subject: [PATCH 1/2] ogone: handle properly unicode params (#13592)

 eopayment/ogone.py  | 3 ++-
 tests/test_ogone.py | 8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
eopayment/ogone.py
6 6

  
7 7
from common import (PaymentCommon, PaymentResponse, FORM, CANCELLED, PAID,
8 8
        ERROR, Form, DENIED, ACCEPTED, ORDERID_TRANSACTION_SEPARATOR,
9
        ResponseError)
9
        ResponseError, force_byte)
10 10
def N_(message): return message
11 11

  
12 12
ENVIRONMENT_TEST = 'TEST'
......
461 461
        values = ['%s=%s' % (a, b) for a, b in values if a in keep]
462 462
        tosign = key.join(values)
463 463
        tosign += key
464
        tosign = force_byte(tosign)
464 465
        hashing = getattr(hashlib, algo)
465 466
        return hashing(tosign).hexdigest().upper()
466 467

  
tests/test_ogone.py
1
# -*- coding: utf-8 -*-
2

  
1 3
from unittest import TestCase
2 4
import urllib
3 5

  
......
5 7
import eopayment.ogone as ogone
6 8
from eopayment import ResponseError
7 9

  
8
PSPID = '2352566'
10
PSPID = u'2352566'
9 11

  
10 12
BACKEND_PARAMS = {
11 13
    'environment': ogone.ENVIRONMENT_TEST,
......
19 21
    def test_request(self):
20 22
        ogone_backend = eopayment.Payment('ogone', BACKEND_PARAMS)
21 23
        amount = '42.42'
22
        order_id = 'myorder'
24
        order_id = u'my ordér'
23 25
        reference, kind, what = ogone_backend.request(amount=amount,
24 26
                                        orderid=order_id, email='foo@example.com')
25 27
        self.assertEqual(len(reference), 30)
......
30 32
        self.assertEqual(root.attrib['method'], 'POST')
31 33
        self.assertEqual(root.attrib['action'], ogone.ENVIRONMENT_TEST_URL)
32 34
        values = {
33
            'CURRENCY': 'EUR',
35
            'CURRENCY': u'EUR',
34 36
            'ORDERID': reference,
35 37
            'PSPID': PSPID,
36 38
            'EMAIL': 'foo@example.com',
37
-