From e6cd4829fc4c7be6de8f3ce422769ef4d03f4035 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Thu, 20 Oct 2016 16:57:28 +0200 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(-) diff --git a/eopayment/ogone.py b/eopayment/ogone.py index 0872a34..9cdd991 100644 --- a/eopayment/ogone.py +++ b/eopayment/ogone.py @@ -6,7 +6,7 @@ from decimal import Decimal, ROUND_HALF_UP from common import (PaymentCommon, PaymentResponse, FORM, CANCELLED, PAID, ERROR, Form, DENIED, ACCEPTED, ORDERID_TRANSACTION_SEPARATOR, - ResponseError) + ResponseError, force_byte) def N_(message): return message ENVIRONMENT_TEST = 'TEST' @@ -461,6 +461,7 @@ class Payment(PaymentCommon): values = ['%s=%s' % (a, b) for a, b in values if a in keep] tosign = key.join(values) tosign += key + tosign = force_byte(tosign) hashing = getattr(hashlib, algo) return hashing(tosign).hexdigest().upper() diff --git a/tests/test_ogone.py b/tests/test_ogone.py index 5108223..f875823 100644 --- a/tests/test_ogone.py +++ b/tests/test_ogone.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from unittest import TestCase import urllib @@ -5,7 +7,7 @@ import eopayment import eopayment.ogone as ogone from eopayment import ResponseError -PSPID = '2352566' +PSPID = u'2352566' BACKEND_PARAMS = { 'environment': ogone.ENVIRONMENT_TEST, @@ -19,7 +21,7 @@ class OgoneTests(TestCase): def test_request(self): ogone_backend = eopayment.Payment('ogone', BACKEND_PARAMS) amount = '42.42' - order_id = 'myorder' + order_id = u'my ordér' reference, kind, what = ogone_backend.request(amount=amount, orderid=order_id, email='foo@example.com') self.assertEqual(len(reference), 30) @@ -30,7 +32,7 @@ class OgoneTests(TestCase): self.assertEqual(root.attrib['method'], 'POST') self.assertEqual(root.attrib['action'], ogone.ENVIRONMENT_TEST_URL) values = { - 'CURRENCY': 'EUR', + 'CURRENCY': u'EUR', 'ORDERID': reference, 'PSPID': PSPID, 'EMAIL': 'foo@example.com', -- 2.9.3