payme-pkg 3.0.26b0__tar.gz → 3.0.28__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 payme-pkg might be problematic. Click here for more details.

Files changed (38) hide show
  1. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/PKG-INFO +1 -1
  2. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/admin.py +1 -1
  3. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/classes/cards.py +1 -1
  4. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/classes/client.py +11 -9
  5. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/classes/initializer.py +5 -10
  6. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/classes/receipts.py +44 -72
  7. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/exceptions/webhook.py +36 -25
  8. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/types/response/cards.py +13 -3
  9. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/types/response/receipts.py +47 -31
  10. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/types/response/webhook.py +24 -14
  11. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/views.py +3 -1
  12. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme_pkg.egg-info/PKG-INFO +1 -1
  13. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/setup.py +1 -1
  14. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/LICENSE.txt +0 -0
  15. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/README.md +0 -0
  16. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/__init__.py +0 -0
  17. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/apps.py +0 -0
  18. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/classes/__init__.py +0 -0
  19. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/classes/http.py +0 -0
  20. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/const.py +0 -0
  21. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/exceptions/__init__.py +0 -0
  22. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/exceptions/general.py +0 -0
  23. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/migrations/0001_initial.py +0 -0
  24. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/migrations/0002_paymetransactions_fiscal_data.py +0 -0
  25. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/migrations/0003_alter_paymetransactions_fiscal_data.py +0 -0
  26. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/migrations/0004_alter_paymetransactions_account_id.py +0 -0
  27. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/migrations/__init__.py +0 -0
  28. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/models.py +0 -0
  29. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/types/__init__.py +0 -0
  30. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/types/request/__init__.py +0 -0
  31. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/types/response/__init__.py +0 -0
  32. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/urls.py +0 -0
  33. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme/util.py +0 -0
  34. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme_pkg.egg-info/SOURCES.txt +0 -0
  35. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme_pkg.egg-info/dependency_links.txt +0 -0
  36. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme_pkg.egg-info/requires.txt +0 -0
  37. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/payme_pkg.egg-info/top_level.txt +0 -0
  38. {payme_pkg-3.0.26b0 → payme_pkg-3.0.28}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: payme-pkg
3
- Version: 3.0.26b0
3
+ Version: 3.0.28
4
4
  Home-page: https://github.com/Muhammadali-Akbarov/payme-pkg
5
5
  Author: Muhammadali Akbarov
6
6
  Author-email: muhammadali17abc@gmail.com
@@ -8,7 +8,7 @@ class PaymeTransactionsUI(admin.ModelAdmin):
8
8
  """
9
9
  Custom admin interface for PaymeTransactions model.
10
10
  """
11
- list_display = ('id', 'state', 'cancel_reason', 'created_at')
11
+ list_display = ('pk', 'state', 'cancel_reason', 'created_at')
12
12
  list_filter = ('state', 'cancel_reason', 'created_at')
13
13
  search_fields = ('transaction_id', 'account_id')
14
14
  ordering = ('-created_at',)
@@ -19,7 +19,7 @@ class Cards:
19
19
  services. It allows you to create new cards and retrieve verification
20
20
  codes for existing cards.
21
21
  """
22
- def __init__(self, url: str, payme_id: str) -> "Cards":
22
+ def __init__(self, url: str, payme_id: str) -> None:
23
23
  """
24
24
  Initialize the Cards client.
25
25
 
@@ -1,5 +1,4 @@
1
-
2
- from typing import Union
1
+ import typing as t
3
2
 
4
3
  from payme.const import Networks
5
4
  from payme.classes.cards import Cards
@@ -11,14 +10,14 @@ class Payme:
11
10
  """
12
11
  The payme class provides a simple interface
13
12
  """
13
+
14
14
  def __init__(
15
15
  self,
16
16
  payme_id: str,
17
- fallback_id: Union[str, None] = None,
18
- payme_key: Union[str, None] = None,
19
- is_test_mode: bool = False
20
- ):
21
-
17
+ fallback_id: t.Optional[str] = None,
18
+ payme_key: t.Optional[str] = None,
19
+ is_test_mode: bool = False,
20
+ ) -> None:
22
21
  # initialize payme network
23
22
  url = Networks.PROD_NET.value
24
23
 
@@ -26,5 +25,8 @@ class Payme:
26
25
  url = Networks.TEST_NET.value
27
26
 
28
27
  self.cards = Cards(url=url, payme_id=payme_id)
29
- self.initializer = Initializer(payme_id=payme_id, fallback_id=fallback_id, is_test_mode=is_test_mode)
30
- self.receipts = Receipts(url=url, payme_id=payme_id, payme_key=payme_key) # noqa
28
+ self.initializer = Initializer(
29
+ payme_id=payme_id, fallback_id=fallback_id, is_test_mode=is_test_mode
30
+ )
31
+ if payme_key:
32
+ self.receipts = Receipts(url=url, payme_id=payme_id, payme_key=payme_key)
@@ -13,17 +13,14 @@ class Initializer:
13
13
  The Payme ID associated with your account
14
14
  """
15
15
 
16
- def __init__(self, payme_id: str = None, fallback_id: str = None, is_test_mode: bool = False):
16
+ def __init__(
17
+ self, payme_id: str = None, fallback_id: str = None, is_test_mode: bool = False
18
+ ) -> None:
17
19
  self.payme_id = payme_id
18
20
  self.fallback_id = fallback_id
19
21
  self.is_test_mode = is_test_mode
20
22
 
21
- def generate_pay_link(
22
- self,
23
- id: int,
24
- amount: int,
25
- return_url: str
26
- ) -> str:
23
+ def generate_pay_link(self, id: int, amount: int, return_url: str) -> str:
27
24
  """
28
25
  Generate a payment link for a specific order.
29
26
 
@@ -52,9 +49,7 @@ class Initializer:
52
49
  https://developer.help.paycom.uz/initsializatsiya-platezhey/
53
50
  """
54
51
  amount = amount * 100 # Convert amount to the smallest currency unit
55
- params = (
56
- f'm={self.payme_id};ac.{settings.PAYME_ACCOUNT_FIELD}={id};a={amount};c={return_url}'
57
- )
52
+ params = f"m={self.payme_id};ac.{settings.PAYME_ACCOUNT_FIELD}={id};a={amount};c={return_url}"
58
53
  params = base64.b64encode(params.encode("utf-8")).decode("utf-8")
59
54
 
60
55
  if self.is_test_mode is True:
@@ -1,4 +1,5 @@
1
- from typing import Union, Optional
1
+ import typing as t
2
+
2
3
  from urllib.parse import parse_qs
3
4
 
4
5
  from payme.classes.cards import Cards
@@ -22,7 +23,8 @@ class Receipts:
22
23
  """
23
24
  The Receipts class provides methods to interact with the Payme Receipts.
24
25
  """
25
- def __init__(self, payme_id: str, payme_key: str, url: str) -> "Receipts":
26
+
27
+ def __init__(self, payme_id: str, payme_key: str, url: str) -> None:
26
28
  """
27
29
  Initialize the Receipts client.
28
30
 
@@ -34,25 +36,25 @@ class Receipts:
34
36
 
35
37
  headers = {
36
38
  "X-Auth": f"{payme_id}:{payme_key}",
37
- "Content-Type": "application/json"
39
+ "Content-Type": "application/json",
38
40
  }
39
41
  self.http = HttpClient(url, headers)
40
42
 
41
43
  def create(
42
44
  self,
43
45
  account: dict,
44
- amount: Union[float, int],
45
- description: Optional[str] = None,
46
- detail: Optional[dict] = None,
47
- timeout: int = 10
46
+ amount: t.Union[float, int],
47
+ description: t.Optional[str] = None,
48
+ detail: t.Optional[t.Dict] = None,
49
+ timeout: int = 10,
48
50
  ) -> response.CreateResponse:
49
51
  """
50
52
  Create a new receipt.
51
53
 
52
54
  :param account: The account details for the receipt.
53
55
  :param amount: The amount of the receipt.
54
- :param description: Optional description for the receipt.
55
- :param detail: Optional additional details for the receipt.
56
+ :param description: t.Optional description for the receipt.
57
+ :param detail: t.Optional additional details for the receipt.
56
58
  :param timeout: The request timeout duration in seconds (default 10).
57
59
  """
58
60
  method = "receipts.create"
@@ -60,7 +62,7 @@ class Receipts:
60
62
  "amount": amount,
61
63
  "account": account,
62
64
  "description": description,
63
- "detail": detail
65
+ "detail": detail,
64
66
  }
65
67
  return self._post_request(method, params, timeout)
66
68
 
@@ -76,10 +78,7 @@ class Receipts:
76
78
  The request timeout duration in seconds (default is 10).
77
79
  """
78
80
  method = "receipts.pay"
79
- params = {
80
- "id": receipts_id,
81
- "token": token
82
- }
81
+ params = {"id": receipts_id, "token": token}
83
82
  return self._post_request(method, params, timeout)
84
83
 
85
84
  def send(
@@ -93,15 +92,10 @@ class Receipts:
93
92
  :param timeout: The request timeout duration in seconds (default 10).
94
93
  """
95
94
  method = "receipts.send"
96
- params = {
97
- "id": receipts_id,
98
- "phone": phone
99
- }
95
+ params = {"id": receipts_id, "phone": phone}
100
96
  return self._post_request(method, params, timeout)
101
97
 
102
- def cancel(
103
- self, receipts_id: str, timeout: int = 10
104
- ) -> response.CancelResponse:
98
+ def cancel(self, receipts_id: str, timeout: int = 10) -> response.CancelResponse:
105
99
  """
106
100
  Cancel the receipt.
107
101
 
@@ -109,14 +103,10 @@ class Receipts:
109
103
  :param timeout: The request timeout duration in seconds (default 10).
110
104
  """
111
105
  method = "receipts.cancel"
112
- params = {
113
- "id": receipts_id
114
- }
106
+ params = {"id": receipts_id}
115
107
  return self._post_request(method, params, timeout)
116
108
 
117
- def check(
118
- self, receipts_id: str, timeout: int = 10
119
- ) -> response.CheckResponse:
109
+ def check(self, receipts_id: str, timeout: int = 10) -> response.CheckResponse:
120
110
  """
121
111
  Check the status of a cheque.
122
112
 
@@ -124,14 +114,10 @@ class Receipts:
124
114
  :param timeout: The request timeout duration in seconds (default 10).
125
115
  """
126
116
  method = "receipts.check"
127
- params = {
128
- "id": receipts_id
129
- }
117
+ params = {"id": receipts_id}
130
118
  return self._post_request(method, params, timeout)
131
119
 
132
- def get(
133
- self, receipts_id: str, timeout: int = 10
134
- ) -> response.GetResponse:
120
+ def get(self, receipts_id: str, timeout: int = 10) -> response.GetResponse:
135
121
  """
136
122
  Get the details of a specific cheque.
137
123
 
@@ -139,30 +125,23 @@ class Receipts:
139
125
  :param timeout: The request timeout duration in seconds (default 10).
140
126
  """
141
127
  method = "receipts.get"
142
- params = {
143
- "id": receipts_id
144
- }
128
+ params = {"id": receipts_id}
145
129
  return self._post_request(method, params, timeout)
146
130
 
147
131
  def get_all(
148
132
  self, count: int, from_: int, to: int, offset: int, timeout: int = 10
149
133
  ) -> response.GetAllResponse:
150
134
  """
151
- Get all cheques for a specific account.
135
+ Get all cheques for a specific account.
152
136
 
153
- :param count: The number of cheques to retrieve.
154
- :param from_: The start index of the cheques to retrieve.
155
- :param to: The end index of the cheques to retrieve.
156
- :param offset: The offset for pagination.
157
- :param timeout: The request timeout duration in seconds (default 10).
137
+ :param count: The number of cheques to retrieve.
138
+ :param from_: The start index of the cheques to retrieve.
139
+ :param to: The end index of the cheques to retrieve.
140
+ :param offset: The offset for pagination.
141
+ :param timeout: The request timeout duration in seconds (default 10).
158
142
  """
159
143
  method = "receipts.get_all"
160
- params = {
161
- "count": count,
162
- "from": from_,
163
- "to": to,
164
- "offset": offset
165
- }
144
+ params = {"count": count, "from": from_, "to": to, "offset": offset}
166
145
  return self._post_request(method, params, timeout)
167
146
 
168
147
  def set_fiscal_data(
@@ -184,13 +163,13 @@ class Receipts:
184
163
  fiscal_date = check_params["c"][0]
185
164
 
186
165
  params = {
187
- "id": receipt_id, # required
166
+ "id": receipt_id, # required
188
167
  "fiscal_data": {
189
168
  "terminal_id": terminal_id,
190
- "receipt_id": int(fiscal_receipt_id), # required
169
+ "receipt_id": int(fiscal_receipt_id), # required
191
170
  "date": fiscal_date,
192
171
  "fiscal_sign": fiscal_sign,
193
- "qr_code_url": qr_code_url, # required
172
+ "qr_code_url": qr_code_url, # required
194
173
  }
195
174
  }
196
175
  return self._post_request(method, params, timeout)
@@ -217,6 +196,7 @@ class Receipts:
217
196
  covering creation, payment, sending, cancellation, status checks,
218
197
  retrieval of a single receipt, and retrieval of multiple receipts.
219
198
  """
199
+
220
200
  # Helper to assert conditions with messaging
221
201
  def assert_condition(condition, message, test_case):
222
202
  self._assert_and_print(condition, message, test_case=test_case)
@@ -227,14 +207,14 @@ class Receipts:
227
207
  account={"id": 12345},
228
208
  amount=1000,
229
209
  description="Test receipt",
230
- detail={"key": "value"}
210
+ detail={"key": "value"},
231
211
  )
232
212
 
233
213
  # Test 1: Initialization check
234
214
  assert_condition(
235
215
  isinstance(self, Receipts),
236
216
  "Initialized Receipts class successfully.",
237
- test_case="Initialization Test"
217
+ test_case="Initialization Test",
238
218
  )
239
219
 
240
220
  # Test 2: Create and Pay Receipt
@@ -242,21 +222,19 @@ class Receipts:
242
222
  assert_condition(
243
223
  isinstance(create_response, response.CreateResponse),
244
224
  "Created a new receipt successfully.",
245
- test_case="Receipt Creation Test"
225
+ test_case="Receipt Creation Test",
246
226
  )
247
227
 
248
228
  # pylint: disable=W0212
249
229
  assert_condition(
250
230
  isinstance(create_response.result.receipt._id, str),
251
231
  "Created a valid receipt ID.",
252
- test_case="Receipt ID Test"
232
+ test_case="Receipt ID Test",
253
233
  )
254
234
 
255
235
  # Prepare card and verification
256
236
  cards_create_response = self.__cards.create(
257
- number="8600495473316478",
258
- expire="0399",
259
- save=True
237
+ number="8600495473316478", expire="0399", save=True
260
238
  )
261
239
  token = cards_create_response.result.card.token
262
240
  self.__cards.get_verify_code(token=token)
@@ -268,7 +246,7 @@ class Receipts:
268
246
  assert_condition(
269
247
  pay_response.result.receipt.state == 4,
270
248
  "Paid the receipt successfully.",
271
- test_case="Payment Test"
249
+ test_case="Payment Test",
272
250
  )
273
251
 
274
252
  # Test 3: Create and Send Receipt
@@ -278,7 +256,7 @@ class Receipts:
278
256
  assert_condition(
279
257
  send_response.result.success is True,
280
258
  "Sent the receipt successfully.",
281
- test_case="Send Test"
259
+ test_case="Send Test",
282
260
  )
283
261
 
284
262
  # Test 4: Create and Cancel Receipt
@@ -288,7 +266,7 @@ class Receipts:
288
266
  assert_condition(
289
267
  cancel_response.result.receipt.state == 50,
290
268
  "Cancelled the receipt successfully.",
291
- test_case="Cancel Test"
269
+ test_case="Cancel Test",
292
270
  )
293
271
 
294
272
  # Test 5: Check Receipt Status
@@ -296,7 +274,7 @@ class Receipts:
296
274
  assert_condition(
297
275
  check_response.result.state == 50,
298
276
  "Checked the receipt status successfully.",
299
- test_case="Check Test"
277
+ test_case="Check Test",
300
278
  )
301
279
 
302
280
  # Test 6: Get Receipt Details
@@ -304,27 +282,21 @@ class Receipts:
304
282
  assert_condition(
305
283
  get_response.result.receipt._id == receipt_id,
306
284
  "Retrieved the receipt details successfully.",
307
- test_case="Get Test"
285
+ test_case="Get Test",
308
286
  )
309
287
 
310
288
  # Test 7: Retrieve All Receipts
311
289
  get_all_response = self.get_all(
312
- count=1,
313
- from_=1730322122000,
314
- to=1730398982000,
315
- offset=0
290
+ count=1, from_=1730322122000, to=1730398982000, offset=0
316
291
  )
317
292
  assert_condition(
318
293
  isinstance(get_all_response.result, list),
319
294
  "Retrieved all receipts successfully.",
320
- test_case="Get All Test"
295
+ test_case="Get All Test",
321
296
  )
322
297
 
323
298
  # pylint: disable=W0212
324
299
  def _assert_and_print(
325
- self,
326
- condition: bool,
327
- success_message: str,
328
- test_case: Optional[str] = None
300
+ self, condition: bool, success_message: str, test_case: t.Optional[str] = None
329
301
  ):
330
302
  self.__cards._assert_and_print(condition, success_message, test_case)
@@ -1,28 +1,31 @@
1
1
  """
2
2
  Init Payme base exception.
3
3
  """
4
+
4
5
  import logging
6
+ import typing as t
7
+
8
+ from rest_framework import status
5
9
  from rest_framework.exceptions import APIException
6
10
 
7
11
  logger = logging.getLogger(__name__)
8
12
 
13
+ MessageT = t.Optional[t.Union[str, t.Dict[str, str]]]
14
+
9
15
 
10
16
  class BasePaymeException(APIException):
11
17
  """
12
18
  BasePaymeException inherits from APIException.
13
19
  """
14
- status_code = 200
15
- error_code = None
16
- message = None
20
+
21
+ status_code: int = status.HTTP_200_OK
22
+ error_code: t.Optional[int] = None
23
+ message: MessageT = None
17
24
 
18
25
  # pylint: disable=super-init-not-called
19
26
  def __init__(self, message: str = None):
20
27
  detail: dict = {
21
- "error": {
22
- "code": self.error_code,
23
- "message": self.message,
24
- "data": message
25
- }
28
+ "error": {"code": self.error_code, "message": self.message, "data": message}
26
29
  }
27
30
  logger.error(f"Payme error detail: {detail}")
28
31
  self.detail = detail
@@ -34,7 +37,8 @@ class PermissionDenied(BasePaymeException):
34
37
 
35
38
  Raised when the client is not allowed to access the server.
36
39
  """
37
- status_code = 200
40
+
41
+ status_code = status.HTTP_200_OK
38
42
  error_code = -32504
39
43
  message = "Permission denied."
40
44
 
@@ -45,12 +49,13 @@ class InternalServiceError(BasePaymeException):
45
49
 
46
50
  Raised when a transaction fails to perform.
47
51
  """
48
- status_code = 200
52
+
53
+ status_code = status.HTTP_200_OK
49
54
  error_code = -32400
50
55
  message = {
51
56
  "uz": "Tizimda xatolik yuzaga keldi.",
52
57
  "ru": "Внутренняя ошибка сервиса.",
53
- "en": "Internal service error."
58
+ "en": "Internal service error.",
54
59
  }
55
60
 
56
61
 
@@ -60,7 +65,8 @@ class MethodNotFound(BasePaymeException):
60
65
 
61
66
  Raised when the requested method does not exist.
62
67
  """
63
- status_code = 405
68
+
69
+ status_code = status.HTTP_405_METHOD_NOT_ALLOWED
64
70
  error_code = -32601
65
71
  message = "Method not found."
66
72
 
@@ -71,12 +77,13 @@ class AccountDoesNotExist(BasePaymeException):
71
77
 
72
78
  Raised when an account does not exist or has been deleted.
73
79
  """
74
- status_code = 200
80
+
81
+ status_code = status.HTTP_200_OK
75
82
  error_code = -31050
76
83
  message = {
77
84
  "uz": "Hisob topilmadi.",
78
85
  "ru": "Счет не найден.",
79
- "en": "Account does not exist."
86
+ "en": "Account does not exist.",
80
87
  }
81
88
 
82
89
 
@@ -86,12 +93,13 @@ class IncorrectAmount(BasePaymeException):
86
93
 
87
94
  Raised when the provided amount is incorrect.
88
95
  """
89
- status_code = 200
96
+
97
+ status_code = status.HTTP_200_OK
90
98
  error_code = -31001
91
99
  message = {
92
- 'ru': 'Неверная сумма.',
93
- 'uz': "Noto'g'ri summa.",
94
- 'en': 'Incorrect amount.'
100
+ "ru": "Неверная сумма.",
101
+ "uz": "Noto'g'ri summa.",
102
+ "en": "Incorrect amount.",
95
103
  }
96
104
 
97
105
 
@@ -107,12 +115,13 @@ class TransactionAlreadyExists(BasePaymeException):
107
115
  error_code (int): The specific error code for this exception.
108
116
  message (dict): A dictionary containing localized error messages.
109
117
  """
110
- status_code = 200
118
+
119
+ status_code = status.HTTP_200_OK
111
120
  error_code = -31099
112
121
  message = {
113
122
  "uz": "Tranzaksiya allaqachon mavjud.",
114
123
  "ru": "Транзакция уже существует.",
115
- "en": "Transaction already exists."
124
+ "en": "Transaction already exists.",
116
125
  }
117
126
 
118
127
 
@@ -122,12 +131,13 @@ class InvalidFiscalParams(BasePaymeException):
122
131
 
123
132
  Raised when the provided fiscal parameters are invalid.
124
133
  """
125
- status_code = 200
134
+
135
+ status_code = status.HTTP_200_OK
126
136
  error_code = -32602
127
137
  message = {
128
138
  "uz": "Fiskal parameterlarida kamchiliklar bor",
129
139
  "ru": "Неверные фискальные параметры.",
130
- "en": "Invalid fiscal parameters."
140
+ "en": "Invalid fiscal parameters.",
131
141
  }
132
142
 
133
143
 
@@ -137,12 +147,13 @@ class InvalidAccount(BasePaymeException):
137
147
 
138
148
  Raised when the provided account is invalid.
139
149
  """
140
- status_code = 200
150
+
151
+ status_code = status.HTTP_200_OK
141
152
  error_code = -32400
142
153
  message = {
143
154
  "uz": "Hisob nomida kamchilik bor",
144
155
  "ru": "Неверный номер счета.",
145
- "en": "Invalid account."
156
+ "en": "Invalid account.",
146
157
  }
147
158
 
148
159
 
@@ -153,5 +164,5 @@ exception_whitelist = (
153
164
  AccountDoesNotExist,
154
165
  TransactionAlreadyExists,
155
166
  InvalidFiscalParams,
156
- InvalidAccount
167
+ InvalidAccount,
157
168
  )
@@ -1,14 +1,15 @@
1
- from typing import Dict, Optional
1
+ import typing as t
2
2
  from dataclasses import dataclass
3
3
 
4
4
 
5
+ @dataclass
5
6
  class Common:
6
7
  """
7
8
  The common response structure.
8
9
  """
9
10
 
10
11
  @classmethod
11
- def from_dict(cls, data: Dict):
12
+ def from_dict(cls, data: t.Dict):
12
13
  """
13
14
  Prepare fields for nested dataclasses
14
15
  """
@@ -30,13 +31,14 @@ class Card(Common):
30
31
  """
31
32
  The card object represents a credit card.
32
33
  """
34
+
33
35
  number: str
34
36
  expire: str
35
37
  token: str
36
38
  recurrent: bool
37
39
  verify: bool
38
40
  type: str
39
- number_hash: Optional[str] = None
41
+ number_hash: t.Optional[str] = None
40
42
 
41
43
 
42
44
  @dataclass
@@ -44,6 +46,7 @@ class Result(Common):
44
46
  """
45
47
  The result object contains the created card.
46
48
  """
49
+
47
50
  card: Card
48
51
 
49
52
 
@@ -52,6 +55,7 @@ class CardsCreateResponse(Common):
52
55
  """
53
56
  The cards.create response.
54
57
  """
58
+
55
59
  jsonrpc: str
56
60
  result: Result
57
61
 
@@ -61,6 +65,7 @@ class VerifyResult(Common):
61
65
  """
62
66
  The result object for the verification response.
63
67
  """
68
+
64
69
  sent: bool
65
70
  phone: str
66
71
  wait: int
@@ -71,6 +76,7 @@ class GetVerifyResponse(Common):
71
76
  """
72
77
  The verification response structure.
73
78
  """
79
+
74
80
  jsonrpc: str
75
81
  result: VerifyResult
76
82
 
@@ -80,6 +86,7 @@ class VerifyResponse(Common):
80
86
  """
81
87
  The verification response structure.
82
88
  """
89
+
83
90
  jsonrpc: str
84
91
  result: Result
85
92
 
@@ -89,6 +96,7 @@ class RemoveCardResult(Common):
89
96
  """
90
97
  The result object for the removal response.
91
98
  """
99
+
92
100
  success: bool
93
101
 
94
102
 
@@ -97,6 +105,7 @@ class RemoveResponse(Common):
97
105
  """
98
106
  The remove response structure.
99
107
  """
108
+
100
109
  jsonrpc: str
101
110
  result: RemoveCardResult
102
111
 
@@ -106,5 +115,6 @@ class CheckResponse(Common):
106
115
  """
107
116
  The check response structure.
108
117
  """
118
+
109
119
  jsonrpc: str
110
120
  result: Result
@@ -1,16 +1,18 @@
1
+ import typing as t
1
2
  from dataclasses import dataclass
2
- from typing import Dict, Optional, Union
3
3
 
4
4
 
5
+ @dataclass
5
6
  class Common:
6
7
  """
7
8
  The common response structure.
8
9
  """
10
+
9
11
  jsonrpc: str
10
12
  id: int
11
13
 
12
14
  @classmethod
13
- def from_dict(cls, data: Dict):
15
+ def from_dict(cls, data: t.Dict):
14
16
  """
15
17
  Prepare fields for nested dataclasses
16
18
  """
@@ -32,6 +34,7 @@ class Account(Common):
32
34
  """
33
35
  The account object represents a user's banking account.
34
36
  """
37
+
35
38
  _id: str
36
39
  account_number: str
37
40
  account_name: str
@@ -46,10 +49,11 @@ class PaymentMethod(Common):
46
49
  """
47
50
  The payment method object represents a user's payment method.
48
51
  """
52
+
49
53
  name: str
50
54
  title: str
51
55
  value: str
52
- main: Optional[bool] = None
56
+ main: t.Optional[bool] = None
53
57
 
54
58
 
55
59
  @dataclass
@@ -57,9 +61,10 @@ class Detail(Common):
57
61
  """
58
62
  The detail object represents additional details for a receipt.
59
63
  """
60
- discount: Optional[str] = None
61
- shipping: Optional[str] = None
62
- items: Optional[str] = None
64
+
65
+ discount: t.Optional[str] = None
66
+ shipping: t.Optional[str] = None
67
+ items: t.Optional[str] = None
63
68
 
64
69
 
65
70
  # pylint: disable=C0103
@@ -68,6 +73,7 @@ class MerchantEpos(Common):
68
73
  """
69
74
  The merchantEpos object represents a user's ePOS.
70
75
  """
76
+
71
77
  eposId: str
72
78
  eposName: str
73
79
  eposType: str
@@ -79,9 +85,10 @@ class Meta(Common):
79
85
  """
80
86
  The meta object represents additional metadata for a receipt.
81
87
  """
82
- source: any = None
83
- owner: any = None
84
- host: any = None
88
+
89
+ source: t.Any = None
90
+ owner: t.Any = None
91
+ host: t.Any = None
85
92
 
86
93
 
87
94
  @dataclass
@@ -89,17 +96,18 @@ class Merchant:
89
96
  """
90
97
  The merchant object represents a user's merchant.
91
98
  """
99
+
92
100
  _id: str
93
101
  name: str
94
102
  organization: str
95
- address: Optional[str] = None
96
- business_id: Optional[str] = None
97
- epos: Optional[MerchantEpos] = None
98
- restrictions: Optional[str] = None
99
- date: Optional[int] = None
100
- logo: Optional[str] = None
101
- type: Optional[str] = None
102
- terms: Optional[str] = None
103
+ address: t.Optional[str] = None
104
+ business_id: t.Optional[str] = None
105
+ epos: t.Optional[MerchantEpos] = None
106
+ restrictions: t.Optional[str] = None
107
+ date: t.Optional[int] = None
108
+ logo: t.Optional[str] = None
109
+ type: t.Optional[str] = None
110
+ terms: t.Optional[str] = None
103
111
 
104
112
 
105
113
  @dataclass
@@ -107,6 +115,7 @@ class Payer(Common):
107
115
  """
108
116
  The payer object represents a user's payer.
109
117
  """
118
+
110
119
  phone: str
111
120
 
112
121
 
@@ -115,6 +124,7 @@ class Receipt(Common):
115
124
  """
116
125
  The receipt object represents a payment receipt.
117
126
  """
127
+
118
128
  _id: str
119
129
  create_time: int
120
130
  pay_time: int
@@ -123,19 +133,19 @@ class Receipt(Common):
123
133
  type: int
124
134
  external: bool
125
135
  operation: int
126
- error: any = None
127
- description: str = None
128
- detail: Detail = None
129
- currency: int = None
130
- commission: int = None
131
- card: str = None
132
- creator: str = None
133
- payer: Payer = None
134
- amount: Union[float, int] = None
135
- account: list[Account] = None
136
- merchant: Merchant = None
137
- processing_id: str = None
138
- meta: Meta = None
136
+ error: t.Any = None
137
+ description: t.Optional[str] = None
138
+ detail: t.Optional[Detail] = None
139
+ currency: t.Optional[int] = None
140
+ commission: t.Optional[int] = None
141
+ card: t.Optional[str] = None
142
+ creator: t.Optional[str] = None
143
+ payer: t.Optional[Payer] = None
144
+ amount: t.Optional[t.Union[float, int]] = None
145
+ account: t.Optional[t.List[Account]] = None
146
+ merchant: t.Optional[Merchant] = None
147
+ processing_id: t.Optional[str] = None
148
+ meta: t.Optional[Meta] = None
139
149
 
140
150
 
141
151
  @dataclass
@@ -143,6 +153,7 @@ class CreateResult(Common):
143
153
  """
144
154
  The result object for the create response.
145
155
  """
156
+
146
157
  receipt: Receipt
147
158
 
148
159
 
@@ -151,6 +162,7 @@ class CreateResponse(Common):
151
162
  """
152
163
  The create response structure.
153
164
  """
165
+
154
166
  result: CreateResult
155
167
 
156
168
 
@@ -166,6 +178,7 @@ class SendResult(Common):
166
178
  """
167
179
  The result object for the send response.
168
180
  """
181
+
169
182
  success: bool
170
183
 
171
184
 
@@ -174,6 +187,7 @@ class SendResponse(Common):
174
187
  """
175
188
  The send response structure.
176
189
  """
190
+
177
191
  result: SendResult
178
192
 
179
193
 
@@ -189,6 +203,7 @@ class CheckResult(Common):
189
203
  """
190
204
  The result object for the check response.
191
205
  """
206
+
192
207
  state: int
193
208
 
194
209
 
@@ -197,6 +212,7 @@ class CheckResponse(Common):
197
212
  """
198
213
  The check response structure.
199
214
  """
215
+
200
216
  result: CheckResult
201
217
 
202
218
 
@@ -220,4 +236,4 @@ class SetFiscalDataResponse(Common):
220
236
  """
221
237
  The result object for the set_fiscal_data response.
222
238
  """
223
- result: SendResult
239
+ result: SendResult
@@ -1,15 +1,16 @@
1
+ import typing as t
1
2
  from dataclasses import dataclass, field
2
- from typing import List, Optional, Dict
3
3
 
4
4
 
5
5
  class CommonResponse:
6
6
  """
7
7
  The common response structure
8
8
  """
9
+
9
10
  def as_resp(self):
10
- response = {'result': {}}
11
+ response = {"result": {}}
11
12
  for key, value in self.__dict__.items():
12
- response['result'][key] = value
13
+ response["result"][key] = value
13
14
  return response
14
15
 
15
16
 
@@ -18,6 +19,7 @@ class Shipping(CommonResponse):
18
19
  """
19
20
  Shipping information response structure
20
21
  """
22
+
21
23
  title: str
22
24
  price: int
23
25
 
@@ -27,6 +29,7 @@ class Item(CommonResponse):
27
29
  """
28
30
  Item information response structure
29
31
  """
32
+
30
33
  discount: int
31
34
  title: str
32
35
  price: int
@@ -45,7 +48,7 @@ class Item(CommonResponse):
45
48
  "code": self.code,
46
49
  "units": self.units,
47
50
  "vat_percent": self.vat_percent,
48
- "package_code": self.package_code
51
+ "package_code": self.package_code,
49
52
  }
50
53
 
51
54
 
@@ -54,11 +57,12 @@ class CheckPerformTransaction(CommonResponse):
54
57
  """
55
58
  Receipt information response structure for transaction checks.
56
59
  """
60
+
57
61
  allow: bool
58
- additional: Optional[Dict[str, str]] = None
59
- receipt_type: Optional[int] = None
60
- shipping: Optional[Shipping] = None
61
- items: List[Item] = field(default_factory=list)
62
+ additional: t.Optional[t.Dict[str, str]] = None
63
+ receipt_type: t.Optional[int] = None
64
+ shipping: t.Optional[Shipping] = None
65
+ items: t.List[Item] = field(default_factory=list)
62
66
 
63
67
  def add_item(self, item: Item):
64
68
  self.items.append(item)
@@ -90,9 +94,10 @@ class CreateTransaction(CommonResponse):
90
94
  """
91
95
  The create transaction request
92
96
  """
97
+
93
98
  transaction: str
94
99
  state: str
95
- create_time: str
100
+ create_time: int
96
101
 
97
102
 
98
103
  @dataclass
@@ -100,9 +105,10 @@ class PerformTransaction(CommonResponse):
100
105
  """
101
106
  The perform transaction response
102
107
  """
108
+
103
109
  transaction: str
104
110
  state: str
105
- perform_time: str
111
+ perform_time: int
106
112
 
107
113
 
108
114
  @dataclass
@@ -110,6 +116,7 @@ class CancelTransaction(CommonResponse):
110
116
  """
111
117
  The cancel transaction request
112
118
  """
119
+
113
120
  transaction: str
114
121
  state: str
115
122
  cancel_time: str
@@ -120,12 +127,13 @@ class CheckTransaction(CommonResponse):
120
127
  """
121
128
  The check transaction request
122
129
  """
130
+
123
131
  transaction: str
124
132
  state: str
125
133
  reason: str
126
- create_time: str
127
- perform_time: Optional[str] = None
128
- cancel_time: Optional[str] = None
134
+ create_time: int
135
+ perform_time: t.Optional[int] = None
136
+ cancel_time: t.Optional[int] = None
129
137
 
130
138
 
131
139
  @dataclass
@@ -133,7 +141,8 @@ class GetStatement(CommonResponse):
133
141
  """
134
142
  The check perform transactions response
135
143
  """
136
- transactions: List[str]
144
+
145
+ transactions: t.List[t.Dict[str, str | int | t.Dict[str, str | int]]]
137
146
 
138
147
 
139
148
  @dataclass
@@ -141,4 +150,5 @@ class SetFiscalData(CommonResponse):
141
150
  """
142
151
  The set fiscal data request
143
152
  """
153
+
144
154
  success: bool
@@ -34,7 +34,8 @@ def handle_exceptions(func):
34
34
  logger.error(f"Account does not exist: {exc} {args} {kwargs}")
35
35
  raise exceptions.AccountDoesNotExist(str(exc)) from exc
36
36
 
37
- except ValidationError:
37
+ except ValidationError as exc:
38
+ logger.error(f"Invalid account identifier {exc}")
38
39
  raise exceptions.AccountDoesNotExist("Invalid account identifier.")
39
40
 
40
41
  except PaymeTransactions.DoesNotExist as exc:
@@ -299,6 +300,7 @@ class PaymeWebHookAPIView(views.APIView):
299
300
  "create_time": time_to_payme(transaction.created_at),
300
301
  "perform_time": time_to_payme(transaction.performed_at),
301
302
  "cancel_time": time_to_payme(transaction.cancelled_at),
303
+ "time": time_to_payme(transaction.created_at),
302
304
  })
303
305
 
304
306
  return result.as_resp()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: payme-pkg
3
- Version: 3.0.26b0
3
+ Version: 3.0.28
4
4
  Home-page: https://github.com/Muhammadali-Akbarov/payme-pkg
5
5
  Author: Muhammadali Akbarov
6
6
  Author-email: muhammadali17abc@gmail.com
@@ -8,7 +8,7 @@ long_description = (here / "README.md").read_text(encoding="utf-8")
8
8
 
9
9
  setup(
10
10
  name='payme-pkg',
11
- version='3.0.26b',
11
+ version='3.0.28',
12
12
  license='MIT',
13
13
  author="Muhammadali Akbarov",
14
14
  author_email='muhammadali17abc@gmail.com',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes