Commit 40b10a34 authored by Jérome Perrin's avatar Jérome Perrin

payzen_secure_payment: python3 support

parent 4c4e26bf
...@@ -141,7 +141,7 @@ class PayzenService(XMLObject, PayzenREST): ...@@ -141,7 +141,7 @@ class PayzenService(XMLObject, PayzenREST):
v = str(v) v = str(v)
signature += v + '+' signature += v + '+'
signature += self.getServicePassword() signature += self.getServicePassword()
return hashlib.sha1(signature).hexdigest() return hashlib.sha1(signature.encode('utf-8')).hexdigest()
def _getFieldList(self, payzen_dict): def _getFieldList(self, payzen_dict):
payzen_dict.update( payzen_dict.update(
......
...@@ -112,19 +112,19 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin): ...@@ -112,19 +112,19 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin):
def test_getSignature_dict_simple(self): def test_getSignature_dict_simple(self):
self.assertEqual( self.assertEqual(
self.service._getSignature({'key': 'value'}, ['key']), self.service._getSignature({'key': 'value'}, ['key']),
sha1('value+' + self.service_password) sha1(('value+' + self.service_password).encode())
) )
def test_getSignature_dict_key_sort(self): def test_getSignature_dict_key_sort(self):
self.assertEqual( self.assertEqual(
self.service._getSignature({'key': 'value', 'key1': 'value1'}, ['key', self.service._getSignature({'key': 'value', 'key1': 'value1'}, ['key',
'key1']), 'key1']),
sha1('value+value1+' + self.service_password) sha1(('value+value1+' + self.service_password).encode())
) )
self.assertEqual( self.assertEqual(
self.service._getSignature({'key': 'value', 'key1': 'value1'}, ['key1', self.service._getSignature({'key': 'value', 'key1': 'value1'}, ['key1',
'key']), 'key']),
sha1('value1+value+' + self.service_password) sha1(('value1+value+' + self.service_password).encode())
) )
def test_getSignature_dict_date_as_datetime(self): def test_getSignature_dict_date_as_datetime(self):
...@@ -132,7 +132,7 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin): ...@@ -132,7 +132,7 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin):
d = {'key': now} d = {'key': now}
self.assertEqual( self.assertEqual(
self.service._getSignature(d, ['key']), self.service._getSignature(d, ['key']),
sha1(now.strftime('%Y%m%d') + '+' + self.service_password) sha1((now.strftime('%Y%m%d') + '+' + self.service_password).encode())
) )
# dict was updated # dict was updated
self.assertEqual(d['key'], now) self.assertEqual(d['key'], now)
...@@ -154,8 +154,8 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin): ...@@ -154,8 +154,8 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin):
self.portal.changeSkin(None) self.portal.changeSkin(None)
try: try:
result = self.service.navigate(pt_id, {"key": 'value'}) result = self.service.navigate(pt_id, {"key": 'value'})
signature = sha1('value+INTERACTIVE+ERP5+TEST+REGISTER+SINGLE+0123456+V2+' signature = sha1(('value+INTERACTIVE+ERP5+TEST+REGISTER+SINGLE+0123456+V2+'
+ self.service_password) + self.service_password).encode())
self.assertEqual(result, """key=key value=value self.assertEqual(result, """key=key value=value
key=signature value=%s key=signature value=%s
key=vads_action_mode value=INTERACTIVE key=vads_action_mode value=INTERACTIVE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment