Skip to content

Commit

Permalink
Merge pull request #1 from simpledte/master
Browse files Browse the repository at this point in the history
Merge fixes from SimpleDTE
  • Loading branch information
fixmycode authored Mar 23, 2020
2 parents 7f76863 + d2529d2 commit 281f7de
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pykhipu/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())

Expand Down
1 change: 1 addition & 0 deletions pykhipu/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ServiceError(BaseError):

class ValidationError(BaseError):
def __init__(self, status, message, errors=[]):
super().__init__(status, message)
self._errors = errors

@classmethod
Expand Down
6 changes: 5 additions & 1 deletion pykhipu/payments.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pykhipu/responses.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import requests
import dateutil.parser
from .items import BankItem
from .errors import ValidationError, AuthorizationError, ServiceError


Expand All @@ -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)
Expand Down

0 comments on commit 281f7de

Please sign in to comment.