payme-pkg 2.6.7__py3-none-any.whl → 3.0.17__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.
Potentially problematic release.
This version of payme-pkg might be problematic. Click here for more details.
- payme/__init__.py +1 -0
- payme/admin.py +12 -6
- payme/apps.py +0 -4
- payme/classes/cards.py +203 -0
- payme/classes/client.py +30 -0
- payme/classes/http.py +107 -0
- payme/classes/initializer.py +82 -0
- payme/classes/receipts.py +298 -0
- payme/const.py +12 -0
- payme/exceptions/__init__.py +5 -0
- payme/exceptions/general.py +275 -0
- payme/exceptions/webhook.py +125 -0
- payme/models.py +113 -46
- payme/types/response/__init__.py +4 -0
- payme/types/response/cards.py +110 -0
- payme/types/response/receipts.py +215 -0
- payme/types/response/webhook.py +136 -0
- payme/urls.py +2 -2
- payme/util.py +26 -0
- payme/views.py +287 -113
- payme_pkg-3.0.17.dist-info/METADATA +193 -0
- payme_pkg-3.0.17.dist-info/RECORD +29 -0
- payme_pkg-3.0.17.dist-info/top_level.txt +1 -0
- core/asgi.py +0 -16
- core/settings.py +0 -133
- core/urls.py +0 -25
- core/wsgi.py +0 -16
- my_app/admin.py +0 -3
- my_app/apps.py +0 -6
- my_app/models.py +0 -3
- my_app/tests.py +0 -3
- my_app/views.py +0 -16
- payme/cards/__init__.py +0 -1
- payme/cards/subscribe_cards.py +0 -166
- payme/decorators/__init__.py +0 -0
- payme/decorators/decorators.py +0 -34
- payme/errors/__init__.py +0 -0
- payme/errors/exceptions.py +0 -89
- payme/methods/__init__.py +0 -0
- payme/methods/cancel_transaction.py +0 -54
- payme/methods/check_perform_transaction.py +0 -26
- payme/methods/check_transaction.py +0 -43
- payme/methods/create_transaction.py +0 -68
- payme/methods/generate_link.py +0 -83
- payme/methods/get_statement.py +0 -65
- payme/methods/perform_transaction.py +0 -47
- payme/migrations/0001_initial.py +0 -48
- payme/receipts/__init__.py +0 -1
- payme/receipts/subscribe_receipts.py +0 -217
- payme/serializers.py +0 -86
- payme/utils/__init__.py +0 -0
- payme/utils/get_params.py +0 -24
- payme/utils/logging.py +0 -9
- payme/utils/make_aware_datetime.py +0 -21
- payme/utils/support.py +0 -8
- payme/utils/to_json.py +0 -13
- payme_pkg-2.6.7.dist-info/METADATA +0 -13
- payme_pkg-2.6.7.dist-info/RECORD +0 -48
- payme_pkg-2.6.7.dist-info/top_level.txt +0 -3
- {core → payme/classes}/__init__.py +0 -0
- {my_app → payme/types}/__init__.py +0 -0
- {my_app/migrations → payme/types/request}/__init__.py +0 -0
- {payme_pkg-2.6.7.dist-info → payme_pkg-3.0.17.dist-info}/LICENSE.txt +0 -0
- {payme_pkg-2.6.7.dist-info → payme_pkg-3.0.17.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
from typing import Union, Optional
|
|
2
|
+
|
|
3
|
+
from payme.classes.cards import Cards
|
|
4
|
+
from payme.classes.http import HttpClient
|
|
5
|
+
from payme.types.response import receipts as response
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
ALLOWED_METHODS = {
|
|
9
|
+
"receipts.create": response.CreateResponse,
|
|
10
|
+
"receipts.pay": response.PayResponse,
|
|
11
|
+
"receipts.send": response.SendResponse,
|
|
12
|
+
"receipts.cancel": response.CancelResponse,
|
|
13
|
+
"receipts.check": response.CheckResponse,
|
|
14
|
+
"receipts.get": response.GetResponse,
|
|
15
|
+
"receipts.get_all": response.GetAllResponse,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Receipts:
|
|
20
|
+
"""
|
|
21
|
+
The Receipts class provides methods to interact with the Payme Receipts.
|
|
22
|
+
"""
|
|
23
|
+
def __init__(self, payme_id: str, payme_key: str, url: str) -> "Receipts":
|
|
24
|
+
"""
|
|
25
|
+
Initialize the Receipts client.
|
|
26
|
+
|
|
27
|
+
:param payme_id: The Payme ID associated with your account.
|
|
28
|
+
:param payme_key: The Payme API key associated with your account.
|
|
29
|
+
:param url: The base URL for the Payme Receipts API.
|
|
30
|
+
"""
|
|
31
|
+
self.__cards = Cards(url, payme_id)
|
|
32
|
+
|
|
33
|
+
headers = {
|
|
34
|
+
"X-Auth": f"{payme_id}:{payme_key}",
|
|
35
|
+
"Content-Type": "application/json"
|
|
36
|
+
}
|
|
37
|
+
self.http = HttpClient(url, headers)
|
|
38
|
+
|
|
39
|
+
def create(
|
|
40
|
+
self,
|
|
41
|
+
account: dict,
|
|
42
|
+
amount: Union[float, int],
|
|
43
|
+
description: Optional[str] = None,
|
|
44
|
+
detail: Optional[dict] = None,
|
|
45
|
+
timeout: int = 10
|
|
46
|
+
) -> response.CreateResponse:
|
|
47
|
+
"""
|
|
48
|
+
Create a new receipt.
|
|
49
|
+
|
|
50
|
+
:param account: The account details for the receipt.
|
|
51
|
+
:param amount: The amount of the receipt.
|
|
52
|
+
:param description: Optional description for the receipt.
|
|
53
|
+
:param detail: Optional additional details for the receipt.
|
|
54
|
+
:param timeout: The request timeout duration in seconds (default 10).
|
|
55
|
+
"""
|
|
56
|
+
method = "receipts.create"
|
|
57
|
+
params = {
|
|
58
|
+
"amount": amount,
|
|
59
|
+
"account": account,
|
|
60
|
+
"description": description,
|
|
61
|
+
"detail": detail
|
|
62
|
+
}
|
|
63
|
+
return self._post_request(method, params, timeout)
|
|
64
|
+
|
|
65
|
+
def pay(
|
|
66
|
+
self, receipts_id: str, token: str, timeout: int = 10
|
|
67
|
+
) -> response.PayResponse:
|
|
68
|
+
"""
|
|
69
|
+
Pay the receipt using a cheque.
|
|
70
|
+
|
|
71
|
+
:param receipts_id: The ID of the cheque used for payment.
|
|
72
|
+
:param token: The token associated with the cheque.
|
|
73
|
+
:param timeout:
|
|
74
|
+
The request timeout duration in seconds (default is 10).
|
|
75
|
+
"""
|
|
76
|
+
method = "receipts.pay"
|
|
77
|
+
params = {
|
|
78
|
+
"id": receipts_id,
|
|
79
|
+
"token": token
|
|
80
|
+
}
|
|
81
|
+
return self._post_request(method, params, timeout)
|
|
82
|
+
|
|
83
|
+
def send(
|
|
84
|
+
self, receipts_id: str, phone: str, timeout: int = 10
|
|
85
|
+
) -> response.SendResponse:
|
|
86
|
+
"""
|
|
87
|
+
Send the receipt to a mobile phone.
|
|
88
|
+
|
|
89
|
+
:param receipts_id: The ID of the cheque used for payment.
|
|
90
|
+
:param phone: The phone number to send the receipt to.
|
|
91
|
+
:param timeout: The request timeout duration in seconds (default 10).
|
|
92
|
+
"""
|
|
93
|
+
method = "receipts.send"
|
|
94
|
+
params = {
|
|
95
|
+
"id": receipts_id,
|
|
96
|
+
"phone": phone
|
|
97
|
+
}
|
|
98
|
+
return self._post_request(method, params, timeout)
|
|
99
|
+
|
|
100
|
+
def cancel(
|
|
101
|
+
self, receipts_id: str, timeout: int = 10
|
|
102
|
+
) -> response.CancelResponse:
|
|
103
|
+
"""
|
|
104
|
+
Cancel the receipt.
|
|
105
|
+
|
|
106
|
+
:param receipts_id: The ID of the cheque used for payment.
|
|
107
|
+
:param timeout: The request timeout duration in seconds (default 10).
|
|
108
|
+
"""
|
|
109
|
+
method = "receipts.cancel"
|
|
110
|
+
params = {
|
|
111
|
+
"id": receipts_id
|
|
112
|
+
}
|
|
113
|
+
return self._post_request(method, params, timeout)
|
|
114
|
+
|
|
115
|
+
def check(
|
|
116
|
+
self, receipts_id: str, timeout: int = 10
|
|
117
|
+
) -> response.CheckResponse:
|
|
118
|
+
"""
|
|
119
|
+
Check the status of a cheque.
|
|
120
|
+
|
|
121
|
+
:param receipts_id: The ID of the cheque used for payment.
|
|
122
|
+
:param timeout: The request timeout duration in seconds (default 10).
|
|
123
|
+
"""
|
|
124
|
+
method = "receipts.check"
|
|
125
|
+
params = {
|
|
126
|
+
"id": receipts_id
|
|
127
|
+
}
|
|
128
|
+
return self._post_request(method, params, timeout)
|
|
129
|
+
|
|
130
|
+
def get(
|
|
131
|
+
self, receipts_id: str, timeout: int = 10
|
|
132
|
+
) -> response.GetResponse:
|
|
133
|
+
"""
|
|
134
|
+
Get the details of a specific cheque.
|
|
135
|
+
|
|
136
|
+
:param receipts_id: The ID of the cheque used for payment.
|
|
137
|
+
:param timeout: The request timeout duration in seconds (default 10).
|
|
138
|
+
"""
|
|
139
|
+
method = "receipts.get"
|
|
140
|
+
params = {
|
|
141
|
+
"id": receipts_id
|
|
142
|
+
}
|
|
143
|
+
return self._post_request(method, params, timeout)
|
|
144
|
+
|
|
145
|
+
def get_all(
|
|
146
|
+
self, count: int, from_: int, to: int, offset: int, timeout: int = 10
|
|
147
|
+
) -> response.GetAllResponse:
|
|
148
|
+
"""
|
|
149
|
+
Get all cheques for a specific account.
|
|
150
|
+
|
|
151
|
+
:param count: The number of cheques to retrieve.
|
|
152
|
+
:param from_: The start index of the cheques to retrieve.
|
|
153
|
+
:param to: The end index of the cheques to retrieve.
|
|
154
|
+
:param offset: The offset for pagination.
|
|
155
|
+
:param timeout: The request timeout duration in seconds (default 10).
|
|
156
|
+
"""
|
|
157
|
+
method = "receipts.get_all"
|
|
158
|
+
params = {
|
|
159
|
+
"count": count,
|
|
160
|
+
"from": from_,
|
|
161
|
+
"to": to,
|
|
162
|
+
"offset": offset
|
|
163
|
+
}
|
|
164
|
+
return self._post_request(method, params, timeout)
|
|
165
|
+
|
|
166
|
+
def _post_request(
|
|
167
|
+
self, method: str, params: dict, timeout: int = 10
|
|
168
|
+
) -> response.Common:
|
|
169
|
+
"""
|
|
170
|
+
Helper method to post requests to the HTTP client.
|
|
171
|
+
|
|
172
|
+
:param method: The API method to be called.
|
|
173
|
+
:param params: The parameters to be sent with the request.
|
|
174
|
+
:param timeout: The request timeout duration in seconds (default 10).
|
|
175
|
+
:return: A response object corresponding to the method called.
|
|
176
|
+
"""
|
|
177
|
+
json = {"method": method, "params": params}
|
|
178
|
+
dict_result = self.http.post(json, timeout)
|
|
179
|
+
response_class = ALLOWED_METHODS[method]
|
|
180
|
+
return response_class.from_dict(dict_result)
|
|
181
|
+
|
|
182
|
+
def test(self):
|
|
183
|
+
"""
|
|
184
|
+
Run a comprehensive suite of tests for the Receipts class,
|
|
185
|
+
covering creation, payment, sending, cancellation, status checks,
|
|
186
|
+
retrieval of a single receipt, and retrieval of multiple receipts.
|
|
187
|
+
"""
|
|
188
|
+
# Helper to assert conditions with messaging
|
|
189
|
+
def assert_condition(condition, message, test_case):
|
|
190
|
+
self._assert_and_print(condition, message, test_case=test_case)
|
|
191
|
+
|
|
192
|
+
# Helper to create a receipt for reuse
|
|
193
|
+
def create_sample_receipt():
|
|
194
|
+
return self.create(
|
|
195
|
+
account={"id": 12345},
|
|
196
|
+
amount=1000,
|
|
197
|
+
description="Test receipt",
|
|
198
|
+
detail={"key": "value"}
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
# Test 1: Initialization check
|
|
202
|
+
assert_condition(
|
|
203
|
+
isinstance(self, Receipts),
|
|
204
|
+
"Initialized Receipts class successfully.",
|
|
205
|
+
test_case="Initialization Test"
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
# Test 2: Create and Pay Receipt
|
|
209
|
+
create_response = create_sample_receipt()
|
|
210
|
+
assert_condition(
|
|
211
|
+
isinstance(create_response, response.CreateResponse),
|
|
212
|
+
"Created a new receipt successfully.",
|
|
213
|
+
test_case="Receipt Creation Test"
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
# pylint: disable=W0212
|
|
217
|
+
assert_condition(
|
|
218
|
+
isinstance(create_response.result.receipt._id, str),
|
|
219
|
+
"Created a valid receipt ID.",
|
|
220
|
+
test_case="Receipt ID Test"
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
# Prepare card and verification
|
|
224
|
+
cards_create_response = self.__cards.create(
|
|
225
|
+
number="8600495473316478",
|
|
226
|
+
expire="0399",
|
|
227
|
+
save=True
|
|
228
|
+
)
|
|
229
|
+
token = cards_create_response.result.card.token
|
|
230
|
+
self.__cards.get_verify_code(token=token)
|
|
231
|
+
self.__cards.verify(token=token, code="666666")
|
|
232
|
+
|
|
233
|
+
# Pay receipt and verify payment state
|
|
234
|
+
receipt_id = create_response.result.receipt._id
|
|
235
|
+
pay_response = self.pay(receipts_id=receipt_id, token=token)
|
|
236
|
+
assert_condition(
|
|
237
|
+
pay_response.result.receipt.state == 4,
|
|
238
|
+
"Paid the receipt successfully.",
|
|
239
|
+
test_case="Payment Test"
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
# Test 3: Create and Send Receipt
|
|
243
|
+
create_response = create_sample_receipt()
|
|
244
|
+
receipt_id = create_response.result.receipt._id
|
|
245
|
+
send_response = self.send(receipts_id=receipt_id, phone="998901304527")
|
|
246
|
+
assert_condition(
|
|
247
|
+
send_response.result.success is True,
|
|
248
|
+
"Sent the receipt successfully.",
|
|
249
|
+
test_case="Send Test"
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
# Test 4: Create and Cancel Receipt
|
|
253
|
+
create_response = create_sample_receipt()
|
|
254
|
+
receipt_id = create_response.result.receipt._id
|
|
255
|
+
cancel_response = self.cancel(receipts_id=receipt_id)
|
|
256
|
+
assert_condition(
|
|
257
|
+
cancel_response.result.receipt.state == 50,
|
|
258
|
+
"Cancelled the receipt successfully.",
|
|
259
|
+
test_case="Cancel Test"
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# Test 5: Check Receipt Status
|
|
263
|
+
check_response = self.check(receipts_id=receipt_id)
|
|
264
|
+
assert_condition(
|
|
265
|
+
check_response.result.state == 50,
|
|
266
|
+
"Checked the receipt status successfully.",
|
|
267
|
+
test_case="Check Test"
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
# Test 6: Get Receipt Details
|
|
271
|
+
get_response = self.get(receipts_id=receipt_id)
|
|
272
|
+
assert_condition(
|
|
273
|
+
get_response.result.receipt._id == receipt_id,
|
|
274
|
+
"Retrieved the receipt details successfully.",
|
|
275
|
+
test_case="Get Test"
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
# Test 7: Retrieve All Receipts
|
|
279
|
+
get_all_response = self.get_all(
|
|
280
|
+
count=1,
|
|
281
|
+
from_=1730322122000,
|
|
282
|
+
to=1730398982000,
|
|
283
|
+
offset=0
|
|
284
|
+
)
|
|
285
|
+
assert_condition(
|
|
286
|
+
isinstance(get_all_response.result, list),
|
|
287
|
+
"Retrieved all receipts successfully.",
|
|
288
|
+
test_case="Get All Test"
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
# pylint: disable=W0212
|
|
292
|
+
def _assert_and_print(
|
|
293
|
+
self,
|
|
294
|
+
condition: bool,
|
|
295
|
+
success_message: str,
|
|
296
|
+
test_case: Optional[str] = None
|
|
297
|
+
):
|
|
298
|
+
self.__cards._assert_and_print(condition, success_message, test_case)
|
payme/const.py
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class BaseError(Exception):
|
|
5
|
+
"""Base class for all errors in the payment system."""
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
def __init__(self, code, message, data=None):
|
|
9
|
+
super().__init__(message)
|
|
10
|
+
self.code = code
|
|
11
|
+
self.data = data
|
|
12
|
+
|
|
13
|
+
# pylint: disable=W1203
|
|
14
|
+
self.logger.error(f"Error {code}: {message}. Data: {data}")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CardError(BaseError):
|
|
18
|
+
"""Base class for card-related errors."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TransportError(CardError):
|
|
22
|
+
"""Transport error occurred during card operation."""
|
|
23
|
+
message = "Transport error."
|
|
24
|
+
|
|
25
|
+
def __init__(self, data=None):
|
|
26
|
+
super().__init__(-32300, self.message, data)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ParseError(CardError):
|
|
30
|
+
"""Parse error occurred during card operation."""
|
|
31
|
+
message = "Parse error."
|
|
32
|
+
|
|
33
|
+
def __init__(self, data=None):
|
|
34
|
+
super().__init__(-32700, self.message, data)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class InvalidRequestError(CardError):
|
|
38
|
+
"""Invalid request made during card operation."""
|
|
39
|
+
message = "Invalid Request."
|
|
40
|
+
|
|
41
|
+
def __init__(self, data=None):
|
|
42
|
+
super().__init__(-32600, self.message, data)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class InvalidResponseError(CardError):
|
|
46
|
+
"""Invalid response received during card operation."""
|
|
47
|
+
message = "Invalid Response."
|
|
48
|
+
|
|
49
|
+
def __init__(self, data=None):
|
|
50
|
+
super().__init__(-32600, self.message, data)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class SystemError(CardError):
|
|
54
|
+
"""System error occurred during card operation."""
|
|
55
|
+
message = "System error."
|
|
56
|
+
|
|
57
|
+
def __init__(self, data=None):
|
|
58
|
+
super().__init__(-32400, self.message, data)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class MethodNotFoundError(CardError):
|
|
62
|
+
"""Method not found during card operation."""
|
|
63
|
+
message = "Method not found."
|
|
64
|
+
|
|
65
|
+
def __init__(self, data=None):
|
|
66
|
+
super().__init__(-32601, self.message, data)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class InvalidParamsError(CardError):
|
|
70
|
+
"""Invalid parameters provided during card operation."""
|
|
71
|
+
message = "Invalid Params."
|
|
72
|
+
|
|
73
|
+
def __init__(self, data=None):
|
|
74
|
+
super().__init__(-32602, self.message, data)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class InvalidTokenFormat(CardError):
|
|
78
|
+
"""Invalid token format during card operation."""
|
|
79
|
+
message = "Invalid token format."
|
|
80
|
+
|
|
81
|
+
def __init__(self, data=None):
|
|
82
|
+
super().__init__(-32500, self.message, data)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class AccessDeniedError(CardError):
|
|
86
|
+
"""Access denied for the card operation."""
|
|
87
|
+
message = "Access denied."
|
|
88
|
+
|
|
89
|
+
def __init__(self, data=None):
|
|
90
|
+
super().__init__(-32504, self.message, data)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class CardNotFoundError(CardError):
|
|
94
|
+
"""Card not found during operation."""
|
|
95
|
+
message = "Card not found."
|
|
96
|
+
|
|
97
|
+
def __init__(self, data=None):
|
|
98
|
+
super().__init__(-31400, self.message, data)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class SmsNotConnectedError(CardError):
|
|
102
|
+
"""SMS notification not connected."""
|
|
103
|
+
message = "SMS notification not connected."
|
|
104
|
+
|
|
105
|
+
def __init__(self, data=None):
|
|
106
|
+
super().__init__(-31301, self.message, data)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class CardExpiredError(CardError):
|
|
110
|
+
"""Card has expired."""
|
|
111
|
+
message = "Card has expired."
|
|
112
|
+
|
|
113
|
+
def __init__(self, data=None):
|
|
114
|
+
super().__init__(-31301, self.message, data)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class CardBlockedError(CardError):
|
|
118
|
+
"""Card is blocked."""
|
|
119
|
+
message = "Card is blocked."
|
|
120
|
+
|
|
121
|
+
def __init__(self, data=None):
|
|
122
|
+
super().__init__(-31301, self.message, data)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class CorporateCardError(CardError):
|
|
126
|
+
"""Financial operations with corporate cards are not allowed."""
|
|
127
|
+
message = "Financial operations with corporate cards are not allowed."
|
|
128
|
+
|
|
129
|
+
def __init__(self, data=None):
|
|
130
|
+
super().__init__(-31300, self.message, data)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class BalanceError(CardError):
|
|
134
|
+
"""Unable to retrieve card balance. Please try again later."""
|
|
135
|
+
message = "Unable to retrieve card balance. Please try again later."
|
|
136
|
+
|
|
137
|
+
def __init__(self, data=None):
|
|
138
|
+
super().__init__(-31302, self.message, data)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class InsufficientFundsError(CardError):
|
|
142
|
+
"""Insufficient funds on the card."""
|
|
143
|
+
message = "Insufficient funds on the card."
|
|
144
|
+
|
|
145
|
+
def __init__(self, data=None):
|
|
146
|
+
super().__init__(-31303, self.message, data)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class InsufficientFundsErrorV2(CardError):
|
|
150
|
+
"""Insufficient funds on the card."""
|
|
151
|
+
message = "Insufficient funds on the card."
|
|
152
|
+
|
|
153
|
+
def __init__(self, data=None):
|
|
154
|
+
super().__init__(-31630, self.message, data)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class InvalidCardNumberError(CardError):
|
|
158
|
+
"""Invalid card number provided."""
|
|
159
|
+
message = "Invalid card number."
|
|
160
|
+
|
|
161
|
+
def __init__(self, data=None):
|
|
162
|
+
super().__init__(-31300, self.message, data)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class CardNotFoundWithNumberError(CardError):
|
|
166
|
+
"""Card with the provided number not found."""
|
|
167
|
+
message = "Card with this number not found."
|
|
168
|
+
|
|
169
|
+
def __init__(self, data=None):
|
|
170
|
+
super().__init__(-31300, self.message, data)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class InvalidExpiryDateError(CardError):
|
|
174
|
+
"""Invalid expiry date provided for the card."""
|
|
175
|
+
message = "Invalid expiry date for the card."
|
|
176
|
+
|
|
177
|
+
def __init__(self, data=None):
|
|
178
|
+
super().__init__(-31300, self.message, data)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class ProcessingServerError(CardError):
|
|
182
|
+
"""Processing center server is unavailable. Please try again later."""
|
|
183
|
+
message = \
|
|
184
|
+
"Processing center server is unavailable. Please try again later."
|
|
185
|
+
|
|
186
|
+
def __init__(self, data=None):
|
|
187
|
+
super().__init__(-31002, self.message, data)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
# OTP Module Errors
|
|
191
|
+
|
|
192
|
+
class OtpError(BaseError):
|
|
193
|
+
"""Base class for OTP-related errors."""
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class OtpSendError(OtpError):
|
|
197
|
+
"""Error occurred while sending OTP."""
|
|
198
|
+
message = "Error occurred while sending SMS. Please try again."
|
|
199
|
+
|
|
200
|
+
def __init__(self, data=None):
|
|
201
|
+
super().__init__(-31110, self.message, data)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class OtpCheckError(OtpError):
|
|
205
|
+
"""Base class for OTP check errors."""
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class OtpExpiredError(OtpCheckError):
|
|
209
|
+
"""OTP code has expired. Request a new code."""
|
|
210
|
+
message = "OTP code has expired. Request a new code."
|
|
211
|
+
|
|
212
|
+
def __init__(self, data=None):
|
|
213
|
+
super().__init__(-31101, self.message, data)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
class OtpAttemptsExceededError(OtpCheckError):
|
|
217
|
+
"""
|
|
218
|
+
Number of attempts to enter the code has been exceeded. Request a new code.
|
|
219
|
+
"""
|
|
220
|
+
message = "Number of attempts to enter the code has been exceeded."
|
|
221
|
+
|
|
222
|
+
def __init__(self, data=None):
|
|
223
|
+
super().__init__(-31102, self.message, data)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class OtpInvalidCodeError(OtpCheckError):
|
|
227
|
+
"""Invalid OTP code entered."""
|
|
228
|
+
message = "Invalid OTP code."
|
|
229
|
+
|
|
230
|
+
def __init__(self, data=None):
|
|
231
|
+
super().__init__(-31103, self.message, data)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class PaymeNetworkError(BaseError):
|
|
235
|
+
"""Network error occurred during request to Payme server."""
|
|
236
|
+
message = "Network error occurred during request to Payme server."
|
|
237
|
+
|
|
238
|
+
def __init__(self, data=None):
|
|
239
|
+
super().__init__(self.message, data)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class ReceiptsNotFoundError(BaseException):
|
|
243
|
+
"""No receipts found for the given transaction ID."""
|
|
244
|
+
def __init__(self, message="No receipts found for the given transaction ID.", data=None):
|
|
245
|
+
super().__init__(message, data)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
class UnknownPartnerError(BaseException):
|
|
249
|
+
"""The given partner ID is unknown."""
|
|
250
|
+
def __init__(self, message="Unknown partner or ID and Key not active", data=None):
|
|
251
|
+
super().__init__(message, data)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
errors_map = {
|
|
255
|
+
-32300: TransportError,
|
|
256
|
+
-32700: ParseError,
|
|
257
|
+
-32600: InvalidRequestError,
|
|
258
|
+
-32601: MethodNotFoundError,
|
|
259
|
+
-32602: InvalidParamsError,
|
|
260
|
+
-32504: AccessDeniedError,
|
|
261
|
+
-31400: CardNotFoundError,
|
|
262
|
+
-31301: SmsNotConnectedError,
|
|
263
|
+
-31302: BalanceError,
|
|
264
|
+
-31303: InsufficientFundsError,
|
|
265
|
+
-31630: InsufficientFundsErrorV2,
|
|
266
|
+
-31300: InvalidCardNumberError,
|
|
267
|
+
-31002: ProcessingServerError,
|
|
268
|
+
-31110: OtpSendError,
|
|
269
|
+
-31101: OtpExpiredError,
|
|
270
|
+
-31102: OtpAttemptsExceededError,
|
|
271
|
+
-31103: OtpInvalidCodeError,
|
|
272
|
+
-31602: ReceiptsNotFoundError,
|
|
273
|
+
-32500: InvalidTokenFormat,
|
|
274
|
+
-31601: UnknownPartnerError,
|
|
275
|
+
}
|