paymentsgate 1.4.6__py3-none-any.whl → 1.4.8__py3-none-any.whl
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.
- paymentsgate/client.py +34 -10
- paymentsgate/models.py +17 -11
- {paymentsgate-1.4.6.dist-info → paymentsgate-1.4.8.dist-info}/METADATA +1 -1
- {paymentsgate-1.4.6.dist-info → paymentsgate-1.4.8.dist-info}/RECORD +6 -6
- {paymentsgate-1.4.6.dist-info → paymentsgate-1.4.8.dist-info}/LICENSE +0 -0
- {paymentsgate-1.4.6.dist-info → paymentsgate-1.4.8.dist-info}/WHEEL +0 -0
paymentsgate/client.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
|
|
2
|
+
import logging
|
|
3
|
+
from dataclasses import dataclass, is_dataclass, field, asdict
|
|
3
4
|
import json
|
|
4
5
|
from urllib.parse import urlencode
|
|
5
6
|
|
|
@@ -18,7 +19,8 @@ from paymentsgate.models import (
|
|
|
18
19
|
PayInModel,
|
|
19
20
|
PayInResponseModel,
|
|
20
21
|
PayOutModel,
|
|
21
|
-
PayOutResponseModel
|
|
22
|
+
PayOutResponseModel,
|
|
23
|
+
InvoiceModel
|
|
22
24
|
)
|
|
23
25
|
from paymentsgate.enums import ApiPaths
|
|
24
26
|
from paymentsgate.transport import (
|
|
@@ -44,10 +46,12 @@ class ApiClient:
|
|
|
44
46
|
REQUEST_DEBUG: bool = False
|
|
45
47
|
RESPONSE_DEBUG: bool = False
|
|
46
48
|
|
|
47
|
-
def __init__(self, config: Credentials, baseUrl: str):
|
|
49
|
+
def __init__(self, config: Credentials, baseUrl: str, debug: bool=False):
|
|
48
50
|
self.config = config
|
|
49
51
|
self.cache = DefaultCache()
|
|
50
|
-
self.baseUrl = baseUrl
|
|
52
|
+
self.baseUrl = baseUrl
|
|
53
|
+
if debug:
|
|
54
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
51
55
|
|
|
52
56
|
def PayIn(self, request: PayInModel) -> PayInResponseModel:
|
|
53
57
|
# Prepare request
|
|
@@ -100,11 +104,30 @@ class ApiClient:
|
|
|
100
104
|
# Handle response
|
|
101
105
|
response = self._send_request(request)
|
|
102
106
|
self.logger(request, response)
|
|
103
|
-
if
|
|
104
|
-
return response.cast(GetQuoteResponseModel, APIResponseError)
|
|
105
|
-
else:
|
|
107
|
+
if not response.success:
|
|
106
108
|
raise APIResponseError(response)
|
|
107
109
|
|
|
110
|
+
return response.cast(GetQuoteResponseModel, APIResponseError)
|
|
111
|
+
|
|
112
|
+
def Status(self, query: str) -> InvoiceModel:
|
|
113
|
+
# Prepare request
|
|
114
|
+
request = Request(
|
|
115
|
+
method="get",
|
|
116
|
+
path=ApiPaths.invoices_info,
|
|
117
|
+
content_type='application/json',
|
|
118
|
+
noAuth=False,
|
|
119
|
+
signature=False,
|
|
120
|
+
body=request
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# Handle response
|
|
124
|
+
response = self._send_request(request)
|
|
125
|
+
self.logger(request, response)
|
|
126
|
+
if not response.success:
|
|
127
|
+
raise APIResponseError(response)
|
|
128
|
+
|
|
129
|
+
return response.cast(InvoiceModel, APIResponseError)
|
|
130
|
+
|
|
108
131
|
@property
|
|
109
132
|
def token(self) -> AccessToken | None:
|
|
110
133
|
# First check if valid token is cached
|
|
@@ -152,7 +175,7 @@ class ApiClient:
|
|
|
152
175
|
"""
|
|
153
176
|
Send a specified Request to the GoPay REST API and process the response
|
|
154
177
|
"""
|
|
155
|
-
|
|
178
|
+
body = asdict(request.body) if is_dataclass(request.body) else request.body
|
|
156
179
|
# Add Bearer authentication to headers if needed
|
|
157
180
|
headers = request.headers or {}
|
|
158
181
|
if not request.noAuth:
|
|
@@ -161,9 +184,10 @@ class ApiClient:
|
|
|
161
184
|
headers["Authorization"] = f"Bearer {auth.token}"
|
|
162
185
|
|
|
163
186
|
if (request.method == 'get'):
|
|
187
|
+
params = urlencode(body)
|
|
164
188
|
r = requests.request(
|
|
165
189
|
method=request.method,
|
|
166
|
-
url=f"{self.baseUrl}{request.path}?{
|
|
190
|
+
url=f"{self.baseUrl}{request.path}?{params}",
|
|
167
191
|
headers=headers,
|
|
168
192
|
timeout=self.timeout
|
|
169
193
|
)
|
|
@@ -172,7 +196,7 @@ class ApiClient:
|
|
|
172
196
|
method=request.method,
|
|
173
197
|
url=f"{self.baseUrl}{request.path}",
|
|
174
198
|
headers=headers,
|
|
175
|
-
json=
|
|
199
|
+
json=body,
|
|
176
200
|
timeout=self.timeout
|
|
177
201
|
)
|
|
178
202
|
|
paymentsgate/models.py
CHANGED
|
@@ -22,11 +22,11 @@ from pydantic import BaseModel, ConfigDict
|
|
|
22
22
|
class Credentials:
|
|
23
23
|
def __init__(
|
|
24
24
|
self,
|
|
25
|
-
account_id
|
|
26
|
-
merchant_id
|
|
27
|
-
project_id
|
|
28
|
-
private_key
|
|
29
|
-
public_key
|
|
25
|
+
account_id: str,
|
|
26
|
+
merchant_id: str,
|
|
27
|
+
project_id: str,
|
|
28
|
+
private_key: str,
|
|
29
|
+
public_key: str
|
|
30
30
|
):
|
|
31
31
|
self.account_id = account_id
|
|
32
32
|
self.merchant_id = merchant_id
|
|
@@ -34,14 +34,14 @@ class Credentials:
|
|
|
34
34
|
self.private_key = private_key
|
|
35
35
|
self.public_key = public_key
|
|
36
36
|
|
|
37
|
+
@classmethod
|
|
37
38
|
def fromFile(cls, filename):
|
|
38
39
|
data = json.load(open(filename))
|
|
39
|
-
cls
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return cls
|
|
40
|
+
return cls(data.get('account_id'),
|
|
41
|
+
data.get('merchant_id'),
|
|
42
|
+
data.get('project_id'),
|
|
43
|
+
data.get('private_key'),
|
|
44
|
+
data.get('public_key'))
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
@dataclass
|
|
@@ -148,6 +148,7 @@ class GetQuoteResponseModel:
|
|
|
148
148
|
fees: Optional[float] = None
|
|
149
149
|
fees_percent: Optional[float] = None
|
|
150
150
|
quotes: Optional[List[QuoteEntity]] = None
|
|
151
|
+
expiredAt: Optional[datetime.datetime] = None
|
|
151
152
|
|
|
152
153
|
#deprecated
|
|
153
154
|
currency_from: Optional[CurrencyModel] = None
|
|
@@ -199,9 +200,11 @@ class InvoiceAmountModel:
|
|
|
199
200
|
class InvoiceMetadataModel:
|
|
200
201
|
invoiceId: Optional[str]
|
|
201
202
|
clientId: Optional[str]
|
|
203
|
+
fiatAmount: Optional[float]
|
|
202
204
|
|
|
203
205
|
@dataclass
|
|
204
206
|
class InvoiceModel:
|
|
207
|
+
_id: str
|
|
205
208
|
orderId: str
|
|
206
209
|
projectId: str
|
|
207
210
|
currencyFrom: CurrencyModel
|
|
@@ -211,6 +214,8 @@ class InvoiceModel:
|
|
|
211
214
|
status: InvoiceStatusModel
|
|
212
215
|
amounts: InvoiceAmountModel
|
|
213
216
|
metadata: InvoiceMetadataModel
|
|
217
|
+
receiptUrls: List[str]
|
|
218
|
+
isExpired: bool
|
|
214
219
|
createdAt: datetime
|
|
215
220
|
updatedAt: datetime
|
|
216
221
|
expiredAt: datetime
|
|
@@ -225,3 +230,4 @@ class AssetsAccountModel:
|
|
|
225
230
|
@dataclass
|
|
226
231
|
class AssetsResponseModel:
|
|
227
232
|
assets: List[AssetsAccountModel]
|
|
233
|
+
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
paymentsgate/__init__.py,sha256=53DrE7IRD2NFQshE2EGYQ28jLr-ro45iFei28ZMOezI,336
|
|
2
2
|
paymentsgate/cache.py,sha256=w3xB3iaYPxVEZbeWxpWM1PQT-JctspoI5qC9bv6Xmts,1002
|
|
3
|
-
paymentsgate/client.py,sha256=
|
|
3
|
+
paymentsgate/client.py,sha256=OM-kNkSKARc4_Nub9Vy0HEswQfaaYVvK7P3bbxh0Lag,7577
|
|
4
4
|
paymentsgate/enums.py,sha256=wvDeVQvSO5WPPSWd1XKOh-8vgI1gsK2wyfMi7P8vay0,3311
|
|
5
5
|
paymentsgate/exceptions.py,sha256=fQniUSQp8XkWXPCITHDUbVNcDwSPA8rJpwbbhJ8wfNQ,1306
|
|
6
6
|
paymentsgate/logger.py,sha256=QY6upavgb2y9dRQG05NwF_OTxP7bPspZR5QdpCjJULI,221
|
|
7
|
-
paymentsgate/models.py,sha256=
|
|
7
|
+
paymentsgate/models.py,sha256=LEwaoy2rkdA-2BLJoV85aKBlDMDu4NETZ0thCrBIV1g,5017
|
|
8
8
|
paymentsgate/tokens.py,sha256=qdvCQJ9jYIRKSxlmm5gip-nMAQWH8_EHys9zwel4oaU,916
|
|
9
9
|
paymentsgate/transport.py,sha256=pOmvDZh06uIGIUWTFi0vgf8pAgQT1f96ArcJNycU2Ks,785
|
|
10
|
-
paymentsgate-1.4.
|
|
11
|
-
paymentsgate-1.4.
|
|
12
|
-
paymentsgate-1.4.
|
|
13
|
-
paymentsgate-1.4.
|
|
10
|
+
paymentsgate-1.4.8.dist-info/LICENSE,sha256=4xWMZLmqNJ6602DZLEg0A9v03uT4xMq_-XSIxvXvfYM,1075
|
|
11
|
+
paymentsgate-1.4.8.dist-info/WHEEL,sha256=bbU3AyvhQ312rVm7zzRQjs6axI1UYWC3nmFA2E6FFSI,88
|
|
12
|
+
paymentsgate-1.4.8.dist-info/METADATA,sha256=iQOvqOiCD_fnXJhEGnS3lOJId4rZJkAM1S9Tqh7qkWA,4020
|
|
13
|
+
paymentsgate-1.4.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|