From 3e21efe9a429666a7772dfff43316b25bae92796 Mon Sep 17 00:00:00 2001 From: Cristian D Date: Wed, 18 Mar 2020 23:26:11 -0300 Subject: [PATCH 1/3] --Fix Python 3 compatibility --- pykhipu/client.py | 2 +- pykhipu/errors.py | 1 + pykhipu/payments.py | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pykhipu/client.py b/pykhipu/client.py index 487c2be..b65b581 100644 --- a/pykhipu/client.py +++ b/pykhipu/client.py @@ -2,7 +2,7 @@ import requests import hmac from hashlib import sha256 -from urllib import urlencode, quote +from urllib.parse import urlencode, quote from .payments import Payments from .banks import Banks from .receivers import Receivers diff --git a/pykhipu/errors.py b/pykhipu/errors.py index 4e09d71..6d4dff4 100644 --- a/pykhipu/errors.py +++ b/pykhipu/errors.py @@ -42,6 +42,7 @@ class ServiceError(BaseError): class ValidationError(BaseError): def __init__(self, status, message, errors=[]): + super().__init__(status, message) self._errors = errors @classmethod diff --git a/pykhipu/payments.py b/pykhipu/payments.py index 3207319..4e8304d 100644 --- a/pykhipu/payments.py +++ b/pykhipu/payments.py @@ -1,6 +1,10 @@ # -*- coding: utf-8 -*- from datetime import datetime -from .responses import PaymentsResponse, PaymentsCreateResponse +from .responses import ( + PaymentsResponse, + PaymentsCreateResponse, + SuccessResponse, +) class Payments(object): From 2ddaeceb20af7983ff6c4281fb126a9f159a4be7 Mon Sep 17 00:00:00 2001 From: Cristian D Date: Wed, 18 Mar 2020 23:28:18 -0300 Subject: [PATCH 2/3] --Fix responses BankItem import --- pykhipu/responses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pykhipu/responses.py b/pykhipu/responses.py index 2b6afac..142fcc4 100644 --- a/pykhipu/responses.py +++ b/pykhipu/responses.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import requests import dateutil.parser +from .items import BankItem from .errors import ValidationError, AuthorizationError, ServiceError @@ -16,7 +17,6 @@ def from_response(cls, response): raise ValidationError.from_data(data) if response.status_code == requests.codes.forbidden: err = AuthorizationError.from_data(data) - print err raise err if response.status_code == requests.codes.service_unavailable: raise ServiceError.from_data(data) From d2529d21b13b8971f52e334a56faf7173d1371da Mon Sep 17 00:00:00 2001 From: Cristian D Date: Wed, 18 Mar 2020 23:44:49 -0300 Subject: [PATCH 3/3] --Fix encode to hmac client __make_request --- pykhipu/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pykhipu/client.py b/pykhipu/client.py index b65b581..96a5cb7 100644 --- a/pykhipu/client.py +++ b/pykhipu/client.py @@ -60,7 +60,7 @@ def quote_items(tuples): sorted_items = sorted(data.items(), key = lambda item: item[0]) to_sign = '&'.join([to_sign,] + quote_items(sorted_items)) - hasher = hmac.new(self.secret, to_sign, digestmod=sha256) + hasher = hmac.new(self.secret.encode(), to_sign.encode('UTF-8'), digestmod=sha256) signature = "{id}:{hash}".format(id=self.receiver_id, hash=hasher.hexdigest())