paymentsgate 1.5.7__tar.gz → 1.5.9__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.

Potentially problematic release.


This version of paymentsgate might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: paymentsgate
3
- Version: 1.5.7
3
+ Version: 1.5.9
4
4
  Summary: PaymentsGate's Python SDK for REST API
5
5
  Home-page: https://github.com/paymentsgate/python-secure-api
6
6
  License: MIT
@@ -145,14 +145,15 @@ class ApiAsyncClient(BaseClient):
145
145
  raise APIResponseError(response)
146
146
  return response.cast(InvoiceModel, APIResponseError)
147
147
 
148
- async def List(self, page: int | int = 0) -> InvoiceListModelWithMeta:
148
+ async def List(self, page: int = 0) -> InvoiceListModelWithMeta:
149
149
  # Prepare request
150
150
  request = Request(
151
151
  method="get",
152
- path=ApiPaths.invoices_list.replace('$1', page | 10),
152
+ path=ApiPaths.invoices_list,
153
153
  content_type='application/json',
154
154
  noAuth=False,
155
155
  signature=False,
156
+ body={"page": page},
156
157
  )
157
158
 
158
159
  # Handle response
@@ -161,7 +162,6 @@ class ApiAsyncClient(BaseClient):
161
162
  raise APIResponseError(response)
162
163
  return response.cast(InvoiceListModelWithMeta, APIResponseError)
163
164
 
164
-
165
165
  async def get_token(self) -> AccessToken | None:
166
166
  # First check if valid token is cached
167
167
  token = self.cache.get_token("AccessToken")
@@ -351,6 +351,7 @@ class ApiClient(BaseClient):
351
351
  noAuth=False,
352
352
  signature=False,
353
353
  body=params.model_dump(exclude_none=True),
354
+ # body=GetQuoteTlv(**params).model_dump(exclude_none=True),
354
355
  )
355
356
 
356
357
  # Handle response
@@ -377,6 +378,23 @@ class ApiClient(BaseClient):
377
378
 
378
379
  return response.cast(InvoiceModel, APIResponseError)
379
380
 
381
+ def List(self, page: int = 0) -> InvoiceListModelWithMeta:
382
+ # Prepare request
383
+ request = Request(
384
+ method="get",
385
+ path=ApiPaths.invoices_list,
386
+ content_type='application/json',
387
+ noAuth=False,
388
+ signature=False,
389
+ body={"page": page},
390
+ )
391
+
392
+ # Handle response
393
+ response = self._send_request(request)
394
+ if not response.success:
395
+ raise APIResponseError(response)
396
+ return response.cast(InvoiceListModelWithMeta, APIResponseError)
397
+
380
398
  def get_token(self) -> AccessToken | None:
381
399
  # First check if valid token is cached
382
400
  token = self.cache.get_token('access')
@@ -431,7 +449,10 @@ class ApiClient(BaseClient):
431
449
  headers["Authorization"] = f"Bearer {auth.token}"
432
450
 
433
451
  if (request.method == 'get'):
434
- params = urlencode(body)
452
+ if (request.body == None):
453
+ request.body = ''
454
+
455
+ params = urlencode(request.body)
435
456
  r = httpx.request(
436
457
  method=request.method,
437
458
  url=f"{self.baseUrl}{request.path}?{params}",
@@ -443,7 +464,7 @@ class ApiClient(BaseClient):
443
464
  method=request.method,
444
465
  url=f"{self.baseUrl}{request.path}",
445
466
  headers=headers,
446
- json=body,
467
+ json=request.body,
447
468
  timeout=self.timeout
448
469
  )
449
470
 
@@ -16,7 +16,7 @@ class ApiPaths(StrEnum):
16
16
  invoices_payout_tlv = "/deals/tlv"
17
17
  invoices_info = "/deals/:id"
18
18
  invoices_credentials = "/deals/:id/credentials"
19
- invoices_list = "/deals/list?page=$1"
19
+ invoices_list = "/deals/list"
20
20
  assets_list = "/wallet"
21
21
  assets_deposit = "/wallet/deposit"
22
22
  banks_list = "/banks/find"
@@ -211,27 +211,28 @@ class InvoiceAmountModel(BaseResponseModel):
211
211
 
212
212
 
213
213
  class InvoiceMetadataModel(BaseResponseModel):
214
- invoiceId: Optional[str]
215
- clientId: Optional[str]
216
- fiatAmount: Optional[float]
214
+ invoiceId: Optional[str] | None = None
215
+ clientId: Optional[str] | None = None
216
+ fiatAmount: Optional[float] | None = None
217
217
 
218
218
 
219
219
  class InvoiceModel(BaseResponseModel):
220
220
  id: str | None = Field(..., alias='_id')
221
- orderId: str
222
- projectId: str
223
- currencyFrom: CurrencyModel
224
- currencyTo: CurrencyModel
225
- direction: InvoiceDirection
226
- amount: float
227
- status: InvoiceStatusModel
228
- amounts: InvoiceAmountModel
229
- metadata: InvoiceMetadataModel
230
- receiptUrls: List[str]
231
- isExpired: bool
221
+ orderId: str | None = None
222
+ projectId: str | None = None
223
+ currencyFrom: CurrencyModel | None = None
224
+ currencyTo: CurrencyModel | None = None
225
+ direction: InvoiceDirection | None = None
226
+ amount: float | None = None
227
+ status: InvoiceStatusModel | None = None
228
+ amounts: InvoiceAmountModel | None = None
229
+ metadata: InvoiceMetadataModel | None = None
230
+ receiptUrls: List[str] | None = None
231
+ isExpired: bool | None = None
232
232
  createdAt: datetime.datetime | None = None
233
233
  updatedAt: datetime.datetime | None = None
234
234
  expiredAt: datetime.datetime | None = None
235
+ model_config = ConfigDict(extra="ignore")
235
236
 
236
237
 
237
238
  class AssetsAccountModel(BaseResponseModel):
@@ -307,5 +308,6 @@ class ListMetadata(BaseResponseModel):
307
308
  total: int
308
309
 
309
310
  class InvoiceListModelWithMeta(BaseResponseModel):
310
- metadata: ListMetadata
311
- rows: List[InvoiceModel]
311
+ meta: ListMetadata
312
+ rows: List[InvoiceModel]
313
+ model_config = ConfigDict(extra="ignore")
@@ -14,7 +14,7 @@ name = "paymentsgate"
14
14
  packages = [{include = "paymentsgate"}]
15
15
  readme = "README.md"
16
16
  repository = "https://github.com/paymentsgate/python-secure-api"
17
- version = "1.5.7"
17
+ version = "1.5.9"
18
18
 
19
19
  [tool.poetry.dependencies]
20
20
  pydantic = "^2.8.2"
@@ -17,7 +17,7 @@ install_requires = \
17
17
 
18
18
  setup_kwargs = {
19
19
  'name': 'paymentsgate',
20
- 'version': '1.5.7',
20
+ 'version': '1.5.9',
21
21
  'description': "PaymentsGate's Python SDK for REST API",
22
22
  'long_description': '\n# Paymentsgate Python SDK for Payments REST API\n\n\n## Requirements\n\n- Python >= 3.8.1\n- dependencies:\n - [`requests`](https://github.com/kennethreitz/requests)\n - [`pydantic`](https://docs.pydantic.dev/latest/)\n - [`jwt`](https://pyjwt.readthedocs.io/en/stable/)\n \n## Installation\n\nThe simplest way to install SDK is to use [PIP](https://docs.python.org/3/installing/):\n\n```bash\npip install paymentsgate\n```\n\n## Basic usage\n\n```python\nfrom paymentsgate import ApiClient, Credentials, Currencies\n\n\n# minimal configuration\nconfig = Credentials().fromFile(\'/path/to/credentials.json\');\n\n# create ApiClient\nclient = ApiClient(config, baseUrl=\'https://api.example.com\');\n\n# request quote\nres = cli.Quote(\n {\n "amount": 10.10,\n "currency_from": Currencies.EUR,\n "currency_to": Currencies.AZN,\n }\n)\nprint(res);\n```\n\nThe `credentials.json` file is used to connect to the client and contains all necessary data to use the API. This file can be obtained in your personal cabinet, in the service accounts section. Follow the instructions in the documentation to issue new keys. If you already have keys, but you don\'t feel comfortable storing them in a file, you can use client initialization via variables. In this case, the key data can be stored in external storage instead of on the file system:\n\n```python\nfrom paymentsgate import ApiClient, Credentials\n\nconfig = Credentials(\n account_id="00000000-4000-4000-0000-00000000000a" \n public_key="LS0tLS1CRUdJTiBSU0EgUFJJVkFUNSUlFb3dJQk..."\n)\n\nclient = ApiClient(config, baseUrl=\'https://api.example.com\');\n\n...\n```\n*It is important to note that the data format for key transfer is base46.\n\n## Examples\n\n### create PayIn\n\n```python\nres = cli.PayIn(\n {\n "amount": 10.10,\n "currency": Currencies.AZN,\n "invoiceId": "INVOICE-112123124",\n "clientId": "",\n "successUrl": "https://example.com/success",\n "failUrl": "https://example.com/fail",\n "type": InvoiceTypes.m10\n }\n)\nprint(res);\n```\n\n### create PayOut\n\n```python\nres = cli.PayOut(\n {\n "amount": 5.12,\n "currencyTo": Currencies.EUR,\n "invoiceId": "INVOICE-112123124",\n "clientId": "CLIENT-003010023004",\n "baseCurrency": CurrencyTypes.fiat,\n "feesStrategy": FeesStrategy.add,\n "recipient": {\n "account_number": "4000000000000012",\n "account_owner": "CARD HOLDER",\n "type": CredentialsTypes.card\n }\n }\n)\nprint(res);\n```\n\n### Error handling\n\n```python\ntry:\n res = cli.PayOut(\n {\n "amount": 5.12,\n "currencyTo": Currencies.EUR,\n "invoiceId": "INVOICE-112123124",\n "clientId": "CLIENT-003010023004",\n "baseCurrency": CurrencyTypes.fiat,\n "feesStrategy": FeesStrategy.add,\n "recipient": {\n "account_number": "4000000000000012",\n "account_owner": "CARD HOLDER",\n "type": CredentialsTypes.card\n }\n }\n )\n print(res);\nexcept APIAuthenticationError as err:\n print(f"Authentication fail: {err.message}")\nexcept APIResponseError as err:\n print(f"Exception: {err.error}; Message: {err.message}")\n```',
23
23
  'author': 'PaymentsGate',
File without changes
File without changes