summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-03-26 18:31:07 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-07-25 08:22:22 (GMT)
commit7b2f106348a80cfde883946012248de685cdefdb (patch)
tree44387141303cd4f66e448659357f6bffb7516645
parent9e1ead2e7c15f14d610a6a888087fcda5e4598b9 (diff)
downloadeopayment-7b2f106348a80cfde883946012248de685cdefdb.zip
eopayment-7b2f106348a80cfde883946012248de685cdefdb.tar.gz
eopayment-7b2f106348a80cfde883946012248de685cdefdb.tar.bz2
systempayv2: update for python3
-rw-r--r--eopayment/systempayv2.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/eopayment/systempayv2.py b/eopayment/systempayv2.py
index 47ae443..d2de01c 100644
--- a/eopayment/systempayv2.py
+++ b/eopayment/systempayv2.py
@@ -276,8 +276,8 @@ class Payment(PaymentCommon):
info2, info3, next_url, kwargs)
# amount unit is cents
amount = '%.0f' % (100 * amount)
- kwargs.update(add_vads({'amount': unicode(amount)}))
- if amount < 0:
+ kwargs.update(add_vads({'amount': force_text(amount)}))
+ if int(amount) < 0:
raise ValueError('amount must be an integer >= 0')
normal_return_url = self.normal_return_url
if next_url:
@@ -285,30 +285,30 @@ class Payment(PaymentCommon):
"set normal_return_url in options", DeprecationWarning)
normal_return_url = next_url
if normal_return_url:
- kwargs[VADS_URL_RETURN] = unicode(normal_return_url)
+ kwargs[VADS_URL_RETURN] = force_text(normal_return_url)
if name is not None:
- kwargs['vads_cust_name'] = unicode(name)
+ kwargs['vads_cust_name'] = force_text(name)
if first_name is not None:
- kwargs[VADS_CUST_FIRST_NAME] = unicode(first_name)
+ kwargs[VADS_CUST_FIRST_NAME] = force_text(first_name)
if last_name is not None:
- kwargs[VADS_CUST_LAST_NAME] = unicode(last_name)
+ kwargs[VADS_CUST_LAST_NAME] = force_text(last_name)
if address is not None:
- kwargs['vads_cust_address'] = unicode(address)
+ kwargs['vads_cust_address'] = force_text(address)
if email is not None:
- kwargs['vads_cust_email'] = unicode(email)
+ kwargs['vads_cust_email'] = force_text(email)
if phone is not None:
- kwargs['vads_cust_phone'] = unicode(phone)
+ kwargs['vads_cust_phone'] = force_text(phone)
if info1 is not None:
- kwargs['vads_order_info'] = unicode(info1)
+ kwargs['vads_order_info'] = force_text(info1)
if info2 is not None:
- kwargs['vads_order_info2'] = unicode(info2)
+ kwargs['vads_order_info2'] = force_text(info2)
if info3 is not None:
- kwargs['vads_order_info3'] = unicode(info3)
+ kwargs['vads_order_info3'] = force_text(info3)
if orderid is not None:
# check orderid format first
name = 'vads_order_id'
- orderid = unicode(orderid)
+ orderid = force_text(orderid)
ptype = 'an-'
p = Parameter(name, ptype, 13, max_length=32)
if not p.check_value(orderid):
@@ -318,14 +318,14 @@ class Payment(PaymentCommon):
transaction_id = self.transaction_id(6, string.digits, 'systempay',
self.options[VADS_SITE_ID])
- kwargs[VADS_TRANS_ID] = unicode(transaction_id)
+ kwargs[VADS_TRANS_ID] = force_text(transaction_id)
fields = kwargs
for parameter in PARAMETERS:
name = parameter.name
# import default parameters from configuration
if name not in fields \
and name in self.options:
- fields[name] = unicode(self.options[name])
+ fields[name] = force_text(self.options[name])
# import default parameters from module
if name not in fields and parameter.default is not None:
if callable(parameter.default):
@@ -333,7 +333,7 @@ class Payment(PaymentCommon):
else:
fields[name] = parameter.default
check_vads(fields)
- fields[SIGNATURE] = unicode(self.signature(fields))
+ fields[SIGNATURE] = force_text(self.signature(fields))
self.logger.debug('%s request contains fields: %s', __name__, fields)
transaction_id = '%s_%s' % (fields[VADS_TRANS_DATE], transaction_id)
self.logger.debug('%s transaction id: %s', __name__, transaction_id)
@@ -417,8 +417,8 @@ class Payment(PaymentCommon):
self.logger.debug('ordered keys %s' % 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, force_byte(secret))
+ signed_data = b'+'.join(ordered_fields)
+ signed_data = b'%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)