@@ -44,7 +44,7 @@ def __init__(self, public_key, private_key, host='https://www.liqpay.com/api/'):
4444 def _make_signature (self , * args ):
4545 joined_fields = '' .join (x for x in args )
4646 joined_fields = joined_fields .encode ('utf-8' )
47- return base64 .b64encode (hashlib .sha1 (joined_fields ).digest ())
47+ return base64 .b64encode (hashlib .sha1 (joined_fields ).digest ()). decode ( "ascii" )
4848
4949 def _prepare_params (self , params ):
5050 params = {} if params is None else deepcopy (params )
@@ -83,11 +83,14 @@ def cnb_form(self, params):
8383 currency = currency if currency != 'RUR' else 'RUB' ,
8484 sandbox = int (bool (params .get ('sandbox' )))
8585 )
86- params_templ = {'data' : base64 .b64encode (json .dumps (params ))}
86+
87+ encoded_data = base64 .b64encode (json .dumps (params ).encode ("utf-8" )).decode ("ascii" )
88+ params_templ = {'data' : encoded_data }
89+
8790 params_templ ['signature' ] = self ._make_signature (self ._private_key , params_templ ['data' ], self ._private_key )
8891 form_action_url = urljoin (self ._host , '3/checkout/' )
8992 format_input = lambda k , v : self .INPUT_TEMPLATE .format (name = k , value = v )
90- inputs = [format_input (k , v ) for k , v in params_templ .iteritems ()]
93+ inputs = [format_input (k , v ) for k , v in params_templ .items ()]
9194 return self .FORM_TEMPLATE .format (
9295 action = form_action_url ,
9396 language = language ,
0 commit comments