Skip to content
This repository was archived by the owner on Feb 27, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion securesubmit/infrastructure/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,4 @@ class PaymentDataSource(Enum):
APPLE_PAY = 'ApplePay'

def __str__(self):
return str(self.value)
return str(self.value)
1 change: 1 addition & 0 deletions securesubmit/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class HpsServicesConfig(_HpsConfigInterface):
password = None
developer_id = None
site_trace = None
timeout = None

def __init__(self):
self.UAT_URL = 'https://api-uat.heartlandportico.com/paymentserver.v1/PosGatewayService.asmx?wsdl'
Expand Down
9 changes: 6 additions & 3 deletions securesubmit/services/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def do_transaction(self, transaction, client_transaction_id=None):

request_headers = {'Content-type': 'text/xml; charset=UTF-8',
'Content-length': str(len(xml))}
request = http.request('POST', self._url, headers=request_headers, body=xml)

request = http.request('POST', self._url, headers=request_headers, body=xml, timeout=self._config.timeout)

raw_response = request.data
if self._logging:
print 'Response: ' + raw_response
Expand Down Expand Up @@ -511,11 +513,12 @@ def do_request(self, verb, endpoint, data=None, additional_headers=None):
if self._logging:
print 'Request: ' + encoded_data

response = http.request(verb, url, headers=headers, body=encoded_data)
response = http.request(verb, url, headers=headers, body=encoded_data, timeout=self._config.timeout)
else:
if self._logging:
print 'Request: ' + url
response = http.request(verb, url, headers=headers)

response = http.request(verb, url, headers=headers, timeout=self._config.timeout)

if self._logging:
print 'Response: ' + response.data
Expand Down
10 changes: 8 additions & 2 deletions securesubmit/services/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class HpsTokenService(object):

_public_api_key = None
_url = None
_timeout = None

def __init__(self, public_api_key):
def __init__(self, public_api_key, timeout=None):
self._public_api_key = public_api_key
self._timeout = timeout

if public_api_key is None or public_api_key == "":
raise HpsArgumentException("publicAPIKey is None or Empty.")
Expand Down Expand Up @@ -57,7 +59,11 @@ def _request_token(self, input_token):
# headers=headers,
# auth=(self._public_api_key, None))

response = http.request('post', self._url, headers=headers, body=data)
response = None
if self._timeout is None:
response = http.request('post', self._url, headers=headers, body=data)
else:
response = http.request('post', self._url, headers=headers, body=data, timeout=self._timeout)

token = HpsToken()
if len(response.data) > 0:
Expand Down