solidgate-sdk 0.3.2__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: solidgate-sdk
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: Python API SDK for SolidGate payment gateway
5
5
  Home-page: https://api-docs.solidgate.com/
6
6
  Author: SolidGate
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="solidgate-sdk",
8
- version="0.3.2",
8
+ version="0.4.0",
9
9
  author="SolidGate",
10
10
  author_email="info@solidgate.com",
11
11
  description="Python API SDK for SolidGate payment gateway",
@@ -2,13 +2,14 @@ import base64
2
2
  import hashlib
3
3
  import hmac
4
4
  import json
5
+ import time
5
6
  from datetime import datetime
6
7
  from typing import Generator
7
8
 
8
9
  import requests
9
10
 
10
11
  from solidgate.encryption import AESCipher
11
- from solidgate.model import MerchantData
12
+ from solidgate.model import FormInitDTO, FormUpdateDTO, FormResignDTO
12
13
 
13
14
 
14
15
  class ApiClient:
@@ -20,6 +21,12 @@ class ApiClient:
20
21
 
21
22
  RECONCILIATION_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
22
23
 
24
+ DEFAULT_RETRY_DELAY = 5
25
+ MAX_ATTEMPTS = 5
26
+ RETRYABLE_STATUS_CODES = (429, 503)
27
+
28
+ USER_AGENT = 'Python-SDK-0.4.0'
29
+
23
30
  def __init__(self, merchant_id: str,
24
31
  private_key: str,
25
32
  base_solid_gate_api_uri: str = BASE_SOLID_GATE_API_URI,
@@ -120,9 +127,14 @@ class ApiClient:
120
127
  body = self.__convert_request_attributes_to_str(attributes)
121
128
  headers = {'Content-Type': 'application/json',
122
129
  'Accept': 'application/json',
130
+ 'User-Agent': self.USER_AGENT,
123
131
  'Merchant': self.__merchant_id,
124
132
  'Signature': self.__generate_signature(body)}
125
- return requests.post(path, headers=headers, json=attributes)
133
+ for attempt in range(1, self.MAX_ATTEMPTS + 1):
134
+ response = requests.post(path, headers=headers, json=attributes)
135
+ if response.status_code not in self.RETRYABLE_STATUS_CODES or attempt == self.MAX_ATTEMPTS:
136
+ return response
137
+ time.sleep(self.DEFAULT_RETRY_DELAY)
126
138
 
127
139
  @staticmethod
128
140
  def __convert_request_attributes_to_str(attributes: dict) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: solidgate-sdk
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: Python API SDK for SolidGate payment gateway
5
5
  Home-page: https://api-docs.solidgate.com/
6
6
  Author: SolidGate
File without changes
File without changes
File without changes