summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-03-26 18:28:14 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-07-25 08:22:22 (GMT)
commit9e1ead2e7c15f14d610a6a888087fcda5e4598b9 (patch)
tree2556615f0d47e0b1370550dbdf0bde2654f2a90a
parentf99d6eeb91b4541dbdd8c772b5424cd05f4f39aa (diff)
downloadeopayment-9e1ead2e7c15f14d610a6a888087fcda5e4598b9.zip
eopayment-9e1ead2e7c15f14d610a6a888087fcda5e4598b9.tar.gz
eopayment-9e1ead2e7c15f14d610a6a888087fcda5e4598b9.tar.bz2
spplus: adapt for python3
-rw-r--r--eopayment/spplus.py10
-rw-r--r--tests/test_spplus.py4
2 files changed, 7 insertions, 7 deletions
diff --git a/eopayment/spplus.py b/eopayment/spplus.py
index e8041e4..e8b1ffc 100644
--- a/eopayment/spplus.py
+++ b/eopayment/spplus.py
@@ -14,14 +14,14 @@ import warnings
import Crypto.Cipher.DES
from .common import (PaymentCommon, URL, PaymentResponse, RECEIVED, ACCEPTED,
- PAID, ERROR, ResponseError)
+ PAID, ERROR, ResponseError, force_byte)
def N_(message): return message
__all__ = ['Payment']
-KEY_DES_KEY = '\x45\x1f\xba\x4f\x4c\x3f\xd4\x97'
-IV = '\x30\x78\x30\x62\x2c\x30\x78\x30'
+KEY_DES_KEY = b'\x45\x1f\xba\x4f\x4c\x3f\xd4\x97'
+IV = b'\x30\x78\x30\x62\x2c\x30\x78\x30'
REFERENCE = 'reference'
ETAT = 'etat'
SPCHECKOK = 'spcheckok'
@@ -56,7 +56,7 @@ TEST_STATE = ('99',)
def decrypt_ntkey(ntkey):
- key = binascii.unhexlify(ntkey.replace(' ',''))
+ key = binascii.unhexlify(ntkey.replace(b' ', b''))
return decrypt_key(key)
def decrypt_key(key):
@@ -70,7 +70,7 @@ def extract_values(query_string):
k, v = kv.split('=', 1)
if k != 'hmac':
result.append(v)
- return ''.join(result)
+ return force_byte(''.join(result))
def sign_ntkey_query(ntkey, query):
key = decrypt_ntkey(ntkey)
diff --git a/tests/test_spplus.py b/tests/test_spplus.py
index 34f48a1..a1a2058 100644
--- a/tests/test_spplus.py
+++ b/tests/test_spplus.py
@@ -2,8 +2,8 @@ from unittest import TestCase
import eopayment.spplus as spplus
class SPPlustTest(TestCase):
- ntkey = '58 6d fc 9c 34 91 9b 86 3f ' \
- 'fd 64 63 c9 13 4a 26 ba 29 74 1e c7 e9 80 79'
+ ntkey = b'58 6d fc 9c 34 91 9b 86 3f ' \
+ b'fd 64 63 c9 13 4a 26 ba 29 74 1e c7 e9 80 79'
tests = [('x=coin', 'c04f8266d6ae3ce37551cce996c751be4a95d10a'),
('x=coin&y=toto', 'ef008e02f8dbf5e70e83da416b0b3a345db203de'),