Commit b92819aa authored by Jérome Perrin's avatar Jérome Perrin

payzen_secure_payment: python3 support

parent 40be71c2
......@@ -141,7 +141,7 @@ class PayzenService(XMLObject, PayzenREST):
v = str(v)
signature += v + '+'
signature += self.getServicePassword()
return hashlib.sha1(signature).hexdigest()
return hashlib.sha1(signature.encode('utf-8')).hexdigest()
def _getFieldList(self, payzen_dict):
payzen_dict.update(
......
......@@ -112,19 +112,19 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin):
def test_getSignature_dict_simple(self):
self.assertEqual(
self.service._getSignature({'key': 'value'}, ['key']),
sha1('value+' + self.service_password)
sha1(('value+' + self.service_password).encode())
)
def test_getSignature_dict_key_sort(self):
self.assertEqual(
self.service._getSignature({'key': 'value', 'key1': 'value1'}, ['key',
'key1']),
sha1('value+value1+' + self.service_password)
sha1(('value+value1+' + self.service_password).encode())
)
self.assertEqual(
self.service._getSignature({'key': 'value', 'key1': 'value1'}, ['key1',
'key']),
sha1('value1+value+' + self.service_password)
sha1(('value1+value+' + self.service_password).encode())
)
def test_getSignature_dict_date_as_datetime(self):
......@@ -132,7 +132,7 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin):
d = {'key': now}
self.assertEqual(
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
self.assertEqual(d['key'], now)
......@@ -154,8 +154,8 @@ class TestERP5PayzenSecurePayment(TestERP5PayzenSecurePaymentMixin):
self.portal.changeSkin(None)
try:
result = self.service.navigate(pt_id, {"key": 'value'})
signature = sha1('value+INTERACTIVE+ERP5+TEST+REGISTER+SINGLE+0123456+V2+'
+ self.service_password)
signature = sha1(('value+INTERACTIVE+ERP5+TEST+REGISTER+SINGLE+0123456+V2+'
+ self.service_password).encode())
self.assertEqual(result, """key=key value=value
key=signature value=%s
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