summaryrefslogtreecommitdiffstats
path: root/eopayment/systempayv2.py
diff options
context:
space:
mode:
authorSerghei Mihai <smihai@entrouvert.com>2016-10-12 08:59:58 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2016-10-13 13:13:27 (GMT)
commit09f2ec7e3de738c8cc489196c63a64fecabc7777 (patch)
tree9e1272eb1b4c82f9c0bfd4104588fcda8950943e /eopayment/systempayv2.py
parent8320be27ddd8fed8f19f9925b1bef36924ce3218 (diff)
downloadeopayment-09f2ec7e3de738c8cc489196c63a64fecabc7777.zip
eopayment-09f2ec7e3de738c8cc489196c63a64fecabc7777.tar.gz
eopayment-09f2ec7e3de738c8cc489196c63a64fecabc7777.tar.bz2
systempayv2: handle properly unicode params (#13562)
Diffstat (limited to 'eopayment/systempayv2.py')
-rw-r--r--eopayment/systempayv2.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/eopayment/systempayv2.py b/eopayment/systempayv2.py
index 63f062d..daa30bb 100644
--- a/eopayment/systempayv2.py
+++ b/eopayment/systempayv2.py
@@ -9,7 +9,7 @@ import warnings
from gettext import gettext as _
from common import (PaymentCommon, PaymentResponse, PAID, ERROR, FORM, Form,
- ResponseError, force_text)
+ ResponseError, force_text, force_byte)
from cb import CB_RESPONSE_CODES
__all__ = ['Payment']
@@ -56,15 +56,15 @@ class Parameter:
self.help_text = help_text
def check_value(self, value):
- if self.length and len(str(value)) != self.length:
+ if self.length and len(value) != self.length:
return False
- if self.max_length and len(str(value)) > self.max_length:
+ if self.max_length and len(value) > self.max_length:
return False
- if self.choices and str(value) not in self.choices:
+ if self.choices and value not in self.choices:
return False
if value == '':
return True
- value = str(value).replace('.', '')
+ value = value.replace('.', '')
if self.ptype == 'n':
return value.isdigit()
elif self.ptype == 'an':
@@ -415,11 +415,11 @@ class Payment(PaymentCommon):
ordered_keys = sorted(
[key for key in fields.keys() if key.startswith('vads_')])
self.logger.debug('ordered keys %s' % ordered_keys)
- ordered_fields = [str(fields[key]) for key in ordered_keys]
+ ordered_fields = [force_byte(fields[key]) for key in ordered_keys]
secret = getattr(self, 'secret_%s' % fields['vads_ctx_mode'].lower())
signed_data = '+'.join(ordered_fields)
- signed_data = '%s+%s' % (signed_data, secret)
- self.logger.debug(u'generating signature on «%s»' % signed_data)
+ signed_data = '%s+%s' % (signed_data, force_byte(secret))
+ self.logger.debug(u'generating signature on «%s»', signed_data)
sign = hashlib.sha1(signed_data).hexdigest()
- self.logger.debug(u'signature «%s»' % sign)
+ self.logger.debug(u'signature «%s»', sign)
return sign