Skip to content

Commit

Permalink
fix how requests are posted
Browse files Browse the repository at this point in the history
  • Loading branch information
madprogrammer committed Oct 23, 2018
1 parent dc8213f commit 4e68f1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions sberbank/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,25 @@ def convert(entry):
def deactivate_binding(self, binding_id):
self.execute_request({'bindingId': binding_id}, "rest/unBindCard")

def execute_request(self, data, method, payment=None, headers=None):
headers = {} if not headers else headers
def execute_request(self, data, method, payment=None):
rest = method.startswith("rest/")

all_headers = {
"Content-Type": "application/json",
headers = {
"Accept": "application/json"
}
all_headers.update(headers)

data.update({
"userName": self.merchant.get('username'),
'password': self.merchant.get('password')
})
if rest:
data.update({
"userName": self.merchant.get('username'),
'password': self.merchant.get('password')
})
else:
headers.update({"Content-Type": "application/json"})
data = json.dumps(data)

try:
response = requests.post(
'{}/{}.do'.format(self.__default_gateway_address, method), data, headers=all_headers)
'{}/{}.do'.format(self.__default_gateway_address, method), data=data, headers=headers)
except (requests.ConnectTimeout,
requests.ConnectionError,
requests.HTTPError):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import setuptools

setuptools.setup(name='django-sberbank',
version='0.2.13',
version='0.2.14',
description='Django app for Sberbank payments',
url='http://github.com/madprogrammer/django-sberbank',
author='Sergey Anufrienko',
Expand Down

0 comments on commit 4e68f1f

Please sign in to comment.