payme-pkg 3.0.24__tar.gz → 3.0.25b0__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.
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/PKG-INFO +1 -1
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/classes/cards.py +1 -1
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/classes/client.py +11 -9
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/classes/initializer.py +5 -10
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/classes/receipts.py +40 -69
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/exceptions/webhook.py +36 -25
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/types/response/cards.py +13 -3
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/types/response/receipts.py +48 -31
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/types/response/webhook.py +24 -14
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme_pkg.egg-info/PKG-INFO +1 -1
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/setup.py +1 -1
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/LICENSE.txt +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/README.md +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/__init__.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/admin.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/apps.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/classes/__init__.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/classes/http.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/const.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/exceptions/__init__.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/exceptions/general.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/migrations/0001_initial.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/migrations/0002_paymetransactions_fiscal_data.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/migrations/0003_alter_paymetransactions_fiscal_data.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/migrations/__init__.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/models.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/types/__init__.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/types/request/__init__.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/types/response/__init__.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/urls.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/util.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/views.py +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme_pkg.egg-info/SOURCES.txt +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme_pkg.egg-info/dependency_links.txt +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme_pkg.egg-info/requires.txt +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme_pkg.egg-info/top_level.txt +0 -0
- {payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/setup.cfg +0 -0
|
@@ -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) ->
|
|
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:
|
|
18
|
-
payme_key:
|
|
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(
|
|
30
|
-
|
|
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__(
|
|
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,4 @@
|
|
|
1
|
-
|
|
1
|
+
import typing as t
|
|
2
2
|
|
|
3
3
|
from payme.classes.cards import Cards
|
|
4
4
|
from payme.classes.http import HttpClient
|
|
@@ -20,7 +20,8 @@ class Receipts:
|
|
|
20
20
|
"""
|
|
21
21
|
The Receipts class provides methods to interact with the Payme Receipts.
|
|
22
22
|
"""
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
def __init__(self, payme_id: str, payme_key: str, url: str) -> None:
|
|
24
25
|
"""
|
|
25
26
|
Initialize the Receipts client.
|
|
26
27
|
|
|
@@ -32,25 +33,25 @@ class Receipts:
|
|
|
32
33
|
|
|
33
34
|
headers = {
|
|
34
35
|
"X-Auth": f"{payme_id}:{payme_key}",
|
|
35
|
-
"Content-Type": "application/json"
|
|
36
|
+
"Content-Type": "application/json",
|
|
36
37
|
}
|
|
37
38
|
self.http = HttpClient(url, headers)
|
|
38
39
|
|
|
39
40
|
def create(
|
|
40
41
|
self,
|
|
41
42
|
account: dict,
|
|
42
|
-
amount: Union[float, int],
|
|
43
|
-
description: Optional[str] = None,
|
|
44
|
-
detail: Optional[
|
|
45
|
-
timeout: int = 10
|
|
43
|
+
amount: t.Union[float, int],
|
|
44
|
+
description: t.Optional[str] = None,
|
|
45
|
+
detail: t.Optional[t.Dict] = None,
|
|
46
|
+
timeout: int = 10,
|
|
46
47
|
) -> response.CreateResponse:
|
|
47
48
|
"""
|
|
48
49
|
Create a new receipt.
|
|
49
50
|
|
|
50
51
|
:param account: The account details for the receipt.
|
|
51
52
|
:param amount: The amount of the receipt.
|
|
52
|
-
:param description: Optional description for the receipt.
|
|
53
|
-
:param detail: Optional additional details for the receipt.
|
|
53
|
+
:param description: t.Optional description for the receipt.
|
|
54
|
+
:param detail: t.Optional additional details for the receipt.
|
|
54
55
|
:param timeout: The request timeout duration in seconds (default 10).
|
|
55
56
|
"""
|
|
56
57
|
method = "receipts.create"
|
|
@@ -58,7 +59,7 @@ class Receipts:
|
|
|
58
59
|
"amount": amount,
|
|
59
60
|
"account": account,
|
|
60
61
|
"description": description,
|
|
61
|
-
"detail": detail
|
|
62
|
+
"detail": detail,
|
|
62
63
|
}
|
|
63
64
|
return self._post_request(method, params, timeout)
|
|
64
65
|
|
|
@@ -74,10 +75,7 @@ class Receipts:
|
|
|
74
75
|
The request timeout duration in seconds (default is 10).
|
|
75
76
|
"""
|
|
76
77
|
method = "receipts.pay"
|
|
77
|
-
params = {
|
|
78
|
-
"id": receipts_id,
|
|
79
|
-
"token": token
|
|
80
|
-
}
|
|
78
|
+
params = {"id": receipts_id, "token": token}
|
|
81
79
|
return self._post_request(method, params, timeout)
|
|
82
80
|
|
|
83
81
|
def send(
|
|
@@ -91,15 +89,10 @@ class Receipts:
|
|
|
91
89
|
:param timeout: The request timeout duration in seconds (default 10).
|
|
92
90
|
"""
|
|
93
91
|
method = "receipts.send"
|
|
94
|
-
params = {
|
|
95
|
-
"id": receipts_id,
|
|
96
|
-
"phone": phone
|
|
97
|
-
}
|
|
92
|
+
params = {"id": receipts_id, "phone": phone}
|
|
98
93
|
return self._post_request(method, params, timeout)
|
|
99
94
|
|
|
100
|
-
def cancel(
|
|
101
|
-
self, receipts_id: str, timeout: int = 10
|
|
102
|
-
) -> response.CancelResponse:
|
|
95
|
+
def cancel(self, receipts_id: str, timeout: int = 10) -> response.CancelResponse:
|
|
103
96
|
"""
|
|
104
97
|
Cancel the receipt.
|
|
105
98
|
|
|
@@ -107,14 +100,10 @@ class Receipts:
|
|
|
107
100
|
:param timeout: The request timeout duration in seconds (default 10).
|
|
108
101
|
"""
|
|
109
102
|
method = "receipts.cancel"
|
|
110
|
-
params = {
|
|
111
|
-
"id": receipts_id
|
|
112
|
-
}
|
|
103
|
+
params = {"id": receipts_id}
|
|
113
104
|
return self._post_request(method, params, timeout)
|
|
114
105
|
|
|
115
|
-
def check(
|
|
116
|
-
self, receipts_id: str, timeout: int = 10
|
|
117
|
-
) -> response.CheckResponse:
|
|
106
|
+
def check(self, receipts_id: str, timeout: int = 10) -> response.CheckResponse:
|
|
118
107
|
"""
|
|
119
108
|
Check the status of a cheque.
|
|
120
109
|
|
|
@@ -122,14 +111,10 @@ class Receipts:
|
|
|
122
111
|
:param timeout: The request timeout duration in seconds (default 10).
|
|
123
112
|
"""
|
|
124
113
|
method = "receipts.check"
|
|
125
|
-
params = {
|
|
126
|
-
"id": receipts_id
|
|
127
|
-
}
|
|
114
|
+
params = {"id": receipts_id}
|
|
128
115
|
return self._post_request(method, params, timeout)
|
|
129
116
|
|
|
130
|
-
def get(
|
|
131
|
-
self, receipts_id: str, timeout: int = 10
|
|
132
|
-
) -> response.GetResponse:
|
|
117
|
+
def get(self, receipts_id: str, timeout: int = 10) -> response.GetResponse:
|
|
133
118
|
"""
|
|
134
119
|
Get the details of a specific cheque.
|
|
135
120
|
|
|
@@ -137,30 +122,23 @@ class Receipts:
|
|
|
137
122
|
:param timeout: The request timeout duration in seconds (default 10).
|
|
138
123
|
"""
|
|
139
124
|
method = "receipts.get"
|
|
140
|
-
params = {
|
|
141
|
-
"id": receipts_id
|
|
142
|
-
}
|
|
125
|
+
params = {"id": receipts_id}
|
|
143
126
|
return self._post_request(method, params, timeout)
|
|
144
127
|
|
|
145
128
|
def get_all(
|
|
146
129
|
self, count: int, from_: int, to: int, offset: int, timeout: int = 10
|
|
147
130
|
) -> response.GetAllResponse:
|
|
148
131
|
"""
|
|
149
|
-
|
|
132
|
+
Get all cheques for a specific account.
|
|
150
133
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
134
|
+
:param count: The number of cheques to retrieve.
|
|
135
|
+
:param from_: The start index of the cheques to retrieve.
|
|
136
|
+
:param to: The end index of the cheques to retrieve.
|
|
137
|
+
:param offset: The offset for pagination.
|
|
138
|
+
:param timeout: The request timeout duration in seconds (default 10).
|
|
156
139
|
"""
|
|
157
140
|
method = "receipts.get_all"
|
|
158
|
-
params = {
|
|
159
|
-
"count": count,
|
|
160
|
-
"from": from_,
|
|
161
|
-
"to": to,
|
|
162
|
-
"offset": offset
|
|
163
|
-
}
|
|
141
|
+
params = {"count": count, "from": from_, "to": to, "offset": offset}
|
|
164
142
|
return self._post_request(method, params, timeout)
|
|
165
143
|
|
|
166
144
|
def _post_request(
|
|
@@ -185,6 +163,7 @@ class Receipts:
|
|
|
185
163
|
covering creation, payment, sending, cancellation, status checks,
|
|
186
164
|
retrieval of a single receipt, and retrieval of multiple receipts.
|
|
187
165
|
"""
|
|
166
|
+
|
|
188
167
|
# Helper to assert conditions with messaging
|
|
189
168
|
def assert_condition(condition, message, test_case):
|
|
190
169
|
self._assert_and_print(condition, message, test_case=test_case)
|
|
@@ -195,14 +174,14 @@ class Receipts:
|
|
|
195
174
|
account={"id": 12345},
|
|
196
175
|
amount=1000,
|
|
197
176
|
description="Test receipt",
|
|
198
|
-
detail={"key": "value"}
|
|
177
|
+
detail={"key": "value"},
|
|
199
178
|
)
|
|
200
179
|
|
|
201
180
|
# Test 1: Initialization check
|
|
202
181
|
assert_condition(
|
|
203
182
|
isinstance(self, Receipts),
|
|
204
183
|
"Initialized Receipts class successfully.",
|
|
205
|
-
test_case="Initialization Test"
|
|
184
|
+
test_case="Initialization Test",
|
|
206
185
|
)
|
|
207
186
|
|
|
208
187
|
# Test 2: Create and Pay Receipt
|
|
@@ -210,21 +189,19 @@ class Receipts:
|
|
|
210
189
|
assert_condition(
|
|
211
190
|
isinstance(create_response, response.CreateResponse),
|
|
212
191
|
"Created a new receipt successfully.",
|
|
213
|
-
test_case="Receipt Creation Test"
|
|
192
|
+
test_case="Receipt Creation Test",
|
|
214
193
|
)
|
|
215
194
|
|
|
216
195
|
# pylint: disable=W0212
|
|
217
196
|
assert_condition(
|
|
218
197
|
isinstance(create_response.result.receipt._id, str),
|
|
219
198
|
"Created a valid receipt ID.",
|
|
220
|
-
test_case="Receipt ID Test"
|
|
199
|
+
test_case="Receipt ID Test",
|
|
221
200
|
)
|
|
222
201
|
|
|
223
202
|
# Prepare card and verification
|
|
224
203
|
cards_create_response = self.__cards.create(
|
|
225
|
-
number="8600495473316478",
|
|
226
|
-
expire="0399",
|
|
227
|
-
save=True
|
|
204
|
+
number="8600495473316478", expire="0399", save=True
|
|
228
205
|
)
|
|
229
206
|
token = cards_create_response.result.card.token
|
|
230
207
|
self.__cards.get_verify_code(token=token)
|
|
@@ -236,7 +213,7 @@ class Receipts:
|
|
|
236
213
|
assert_condition(
|
|
237
214
|
pay_response.result.receipt.state == 4,
|
|
238
215
|
"Paid the receipt successfully.",
|
|
239
|
-
test_case="Payment Test"
|
|
216
|
+
test_case="Payment Test",
|
|
240
217
|
)
|
|
241
218
|
|
|
242
219
|
# Test 3: Create and Send Receipt
|
|
@@ -246,7 +223,7 @@ class Receipts:
|
|
|
246
223
|
assert_condition(
|
|
247
224
|
send_response.result.success is True,
|
|
248
225
|
"Sent the receipt successfully.",
|
|
249
|
-
test_case="Send Test"
|
|
226
|
+
test_case="Send Test",
|
|
250
227
|
)
|
|
251
228
|
|
|
252
229
|
# Test 4: Create and Cancel Receipt
|
|
@@ -256,7 +233,7 @@ class Receipts:
|
|
|
256
233
|
assert_condition(
|
|
257
234
|
cancel_response.result.receipt.state == 50,
|
|
258
235
|
"Cancelled the receipt successfully.",
|
|
259
|
-
test_case="Cancel Test"
|
|
236
|
+
test_case="Cancel Test",
|
|
260
237
|
)
|
|
261
238
|
|
|
262
239
|
# Test 5: Check Receipt Status
|
|
@@ -264,7 +241,7 @@ class Receipts:
|
|
|
264
241
|
assert_condition(
|
|
265
242
|
check_response.result.state == 50,
|
|
266
243
|
"Checked the receipt status successfully.",
|
|
267
|
-
test_case="Check Test"
|
|
244
|
+
test_case="Check Test",
|
|
268
245
|
)
|
|
269
246
|
|
|
270
247
|
# Test 6: Get Receipt Details
|
|
@@ -272,27 +249,21 @@ class Receipts:
|
|
|
272
249
|
assert_condition(
|
|
273
250
|
get_response.result.receipt._id == receipt_id,
|
|
274
251
|
"Retrieved the receipt details successfully.",
|
|
275
|
-
test_case="Get Test"
|
|
252
|
+
test_case="Get Test",
|
|
276
253
|
)
|
|
277
254
|
|
|
278
255
|
# Test 7: Retrieve All Receipts
|
|
279
256
|
get_all_response = self.get_all(
|
|
280
|
-
count=1,
|
|
281
|
-
from_=1730322122000,
|
|
282
|
-
to=1730398982000,
|
|
283
|
-
offset=0
|
|
257
|
+
count=1, from_=1730322122000, to=1730398982000, offset=0
|
|
284
258
|
)
|
|
285
259
|
assert_condition(
|
|
286
260
|
isinstance(get_all_response.result, list),
|
|
287
261
|
"Retrieved all receipts successfully.",
|
|
288
|
-
test_case="Get All Test"
|
|
262
|
+
test_case="Get All Test",
|
|
289
263
|
)
|
|
290
264
|
|
|
291
265
|
# pylint: disable=W0212
|
|
292
266
|
def _assert_and_print(
|
|
293
|
-
self,
|
|
294
|
-
condition: bool,
|
|
295
|
-
success_message: str,
|
|
296
|
-
test_case: Optional[str] = None
|
|
267
|
+
self, condition: bool, success_message: str, test_case: t.Optional[str] = None
|
|
297
268
|
):
|
|
298
269
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
96
|
+
|
|
97
|
+
status_code = status.HTTP_200_OK
|
|
90
98
|
error_code = -31001
|
|
91
99
|
message = {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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:
|
|
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:
|
|
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
|
|
|
@@ -212,4 +228,5 @@ class GetAllResponse(Common):
|
|
|
212
228
|
"""
|
|
213
229
|
The result object for the get all response.
|
|
214
230
|
"""
|
|
215
|
-
|
|
231
|
+
|
|
232
|
+
result: t.Optional[t.List[Receipt]] = None
|
|
@@ -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 = {
|
|
11
|
+
response = {"result": {}}
|
|
11
12
|
for key, value in self.__dict__.items():
|
|
12
|
-
response[
|
|
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:
|
|
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:
|
|
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:
|
|
127
|
-
perform_time: Optional[
|
|
128
|
-
cancel_time: Optional[
|
|
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
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/migrations/0002_paymetransactions_fiscal_data.py
RENAMED
|
File without changes
|
{payme_pkg-3.0.24 → payme_pkg-3.0.25b0}/payme/migrations/0003_alter_paymetransactions_fiscal_data.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|