Skip to content

Commit 294370b

Browse files
woochicaAleffio
authored andcommitted
Make Adyen.util module Python 3 compatible (#26)
* Make adding maps Python 3 compatible by chaining * Set encoding before hashing
1 parent 81bad6c commit 294370b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Adyen/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import re
55
from functools import wraps
6+
from itertools import chain
67
from collections import OrderedDict
78
import base64
89
import hmac
@@ -25,7 +26,7 @@ def escapeVal(val):
2526
#for k,v in ordered_request.items():
2627
# signing_string.append(':'.join(k,escapeVal(v)))
2728

28-
signing_string = ':'.join(map(escapeVal, map(str,ordered_request.keys()) + map(str,ordered_request.values())))
29+
signing_string = ':'.join(map(escapeVal, chain(map(str,ordered_request.keys()), map(str,ordered_request.values()))))
2930

3031
return signing_string
3132

@@ -47,8 +48,7 @@ def escapeVal(val):
4748

4849
ordered_request = OrderedDict(sorted(dict_object.items(), key=lambda t: t[0]))
4950

50-
signing_string = ':'.join(map(escapeVal, map(str,ordered_request.keys()) + map(str,ordered_request.values())))
51+
signing_string = ':'.join(map(escapeVal, chain(map(str,ordered_request.keys()), map(str,ordered_request.values()))))
5152

52-
53-
hm = hmac.new(hmac_key, signing_string, hashlib.sha256)
53+
hm = hmac.new(hmac_key, signing_string.encode('utf-8'), hashlib.sha256)
5454
return base64.b64encode(hm.digest())

0 commit comments

Comments
 (0)