payme-pkg 2.6.7__py3-none-any.whl → 3.0.18__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 +111 -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.18.dist-info/METADATA +193 -0
- payme_pkg-3.0.18.dist-info/RECORD +29 -0
- payme_pkg-3.0.18.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.18.dist-info}/LICENSE.txt +0 -0
- {payme_pkg-2.6.7.dist-info → payme_pkg-3.0.18.dist-info}/WHEEL +0 -0
payme/errors/exceptions.py
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
from rest_framework.exceptions import APIException
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class BasePaymeException(APIException):
|
|
5
|
-
"""
|
|
6
|
-
BasePaymeException it's APIException.
|
|
7
|
-
"""
|
|
8
|
-
status_code = 200
|
|
9
|
-
error_code = None
|
|
10
|
-
message = None
|
|
11
|
-
|
|
12
|
-
# pylint: disable=super-init-not-called
|
|
13
|
-
def __init__(self, error_message: str = None):
|
|
14
|
-
detail: dict = {
|
|
15
|
-
"error": {
|
|
16
|
-
"code": self.error_code,
|
|
17
|
-
"message": self.message,
|
|
18
|
-
"data": error_message
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
self.detail = detail
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class PermissionDenied(BasePaymeException):
|
|
25
|
-
"""
|
|
26
|
-
PermissionDenied APIException \
|
|
27
|
-
That is raised when the client is not allowed to server.
|
|
28
|
-
"""
|
|
29
|
-
status_code = 200
|
|
30
|
-
error_code = -32504
|
|
31
|
-
message = "Permission denied"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class MethodNotFound(BasePaymeException):
|
|
35
|
-
"""
|
|
36
|
-
MethodNotFound APIException \
|
|
37
|
-
That is raised when the method does not exist.
|
|
38
|
-
"""
|
|
39
|
-
status_code = 405
|
|
40
|
-
error_code = -32601
|
|
41
|
-
message = 'Method not found'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class TooManyRequests(BasePaymeException):
|
|
45
|
-
"""
|
|
46
|
-
TooManyRequests APIException \
|
|
47
|
-
That is raised when the request exceeds the limit.
|
|
48
|
-
"""
|
|
49
|
-
status_code = 200
|
|
50
|
-
error_code = -31099
|
|
51
|
-
message = {
|
|
52
|
-
"uz": "Buyurtma tolovni amalga oshirish jarayonida",
|
|
53
|
-
"ru": "Транзакция в очереди",
|
|
54
|
-
"en": "Order payment status is queued"
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class IncorrectAmount(BasePaymeException):
|
|
59
|
-
"""
|
|
60
|
-
IncorrectAmount APIException \
|
|
61
|
-
That is raised when the amount is not incorrect.
|
|
62
|
-
"""
|
|
63
|
-
status_code = 200
|
|
64
|
-
error_code = -31001
|
|
65
|
-
message = {
|
|
66
|
-
'ru': 'Неверная сумма',
|
|
67
|
-
'uz': "Noto'g'ri qiymat",
|
|
68
|
-
'en': 'Incorrect amount',
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
class PerformTransactionDoesNotExist(BasePaymeException):
|
|
73
|
-
"""
|
|
74
|
-
PerformTransactionDoesNotExist APIException \
|
|
75
|
-
That is raised when a transaction does not exist or deleted.
|
|
76
|
-
"""
|
|
77
|
-
status_code = 200
|
|
78
|
-
error_code = -31050
|
|
79
|
-
message = {
|
|
80
|
-
"uz": "Buyurtma topilmadi",
|
|
81
|
-
"ru": "Заказ не существует",
|
|
82
|
-
"en": "Order does not exists"
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
class PaymeTimeoutException(Exception):
|
|
87
|
-
"""
|
|
88
|
-
Payme timeout exception that means that payme is working slowly.
|
|
89
|
-
"""
|
payme/methods/__init__.py
DELETED
|
File without changes
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import time
|
|
2
|
-
|
|
3
|
-
from django.db import transaction
|
|
4
|
-
|
|
5
|
-
from payme.utils.logging import logger
|
|
6
|
-
from payme.models import MerchantTransactionsModel
|
|
7
|
-
from payme.errors.exceptions import PerformTransactionDoesNotExist
|
|
8
|
-
from payme.serializers import MerchantTransactionsModelSerializer as MTMS
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class CancelTransaction:
|
|
12
|
-
"""
|
|
13
|
-
CancelTransaction class
|
|
14
|
-
That is used to cancel a transaction.
|
|
15
|
-
|
|
16
|
-
Full method documentation
|
|
17
|
-
-------------------------
|
|
18
|
-
https://developer.help.paycom.uz/metody-merchant-api/canceltransaction
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
@transaction.atomic
|
|
22
|
-
def __call__(self, params: dict):
|
|
23
|
-
clean_data: dict = MTMS.get_validated_data(
|
|
24
|
-
params=params
|
|
25
|
-
)
|
|
26
|
-
try:
|
|
27
|
-
with transaction.atomic():
|
|
28
|
-
transactions: MerchantTransactionsModel = \
|
|
29
|
-
MerchantTransactionsModel.objects.filter(
|
|
30
|
-
_id=clean_data.get('_id'),
|
|
31
|
-
).first()
|
|
32
|
-
if transactions.cancel_time == 0:
|
|
33
|
-
transactions.cancel_time = int(time.time() * 1000)
|
|
34
|
-
if transactions.perform_time == 0:
|
|
35
|
-
transactions.state = -1
|
|
36
|
-
if transactions.perform_time != 0:
|
|
37
|
-
transactions.state = -2
|
|
38
|
-
transactions.reason = clean_data.get("reason")
|
|
39
|
-
transactions.save()
|
|
40
|
-
|
|
41
|
-
except PerformTransactionDoesNotExist as error:
|
|
42
|
-
logger.error("Paycom transaction does not exist: %s", error)
|
|
43
|
-
raise PerformTransactionDoesNotExist() from error
|
|
44
|
-
|
|
45
|
-
response: dict = {
|
|
46
|
-
"result": {
|
|
47
|
-
"state": transactions.state,
|
|
48
|
-
"cancel_time": transactions.cancel_time,
|
|
49
|
-
"transaction": transactions.transaction_id,
|
|
50
|
-
"reason": int(transactions.reason),
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return transactions.order_id, response
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
from payme.utils.get_params import get_params
|
|
2
|
-
from payme.serializers import MerchantTransactionsModelSerializer
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class CheckPerformTransaction:
|
|
6
|
-
"""
|
|
7
|
-
CheckPerformTransaction class
|
|
8
|
-
That's used to check perform transaction.
|
|
9
|
-
|
|
10
|
-
Full method documentation
|
|
11
|
-
-------------------------
|
|
12
|
-
https://developer.help.paycom.uz/metody-merchant-api/checktransaction
|
|
13
|
-
"""
|
|
14
|
-
def __call__(self, params: dict) -> tuple:
|
|
15
|
-
serializer = MerchantTransactionsModelSerializer(
|
|
16
|
-
data=get_params(params)
|
|
17
|
-
)
|
|
18
|
-
serializer.is_valid(raise_exception=True)
|
|
19
|
-
|
|
20
|
-
response = {
|
|
21
|
-
"result": {
|
|
22
|
-
"allow": True,
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return None, response
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
from django.db import DatabaseError
|
|
2
|
-
|
|
3
|
-
from payme.utils.logging import logger
|
|
4
|
-
from payme.models import MerchantTransactionsModel
|
|
5
|
-
from payme.serializers import MerchantTransactionsModelSerializer as MTMS
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class CheckTransaction:
|
|
9
|
-
"""
|
|
10
|
-
CheckTransaction class
|
|
11
|
-
That's used to check transaction
|
|
12
|
-
|
|
13
|
-
Full method documentation
|
|
14
|
-
-------------------------
|
|
15
|
-
https://developer.help.paycom.uz/metody-merchant-api/checkperformtransaction
|
|
16
|
-
"""
|
|
17
|
-
def __call__(self, params: dict) -> tuple:
|
|
18
|
-
clean_data: dict = MTMS.get_validated_data(
|
|
19
|
-
params=params
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
try:
|
|
23
|
-
transaction = \
|
|
24
|
-
MerchantTransactionsModel.objects.get(
|
|
25
|
-
_id=clean_data.get("_id"),
|
|
26
|
-
)
|
|
27
|
-
response = {
|
|
28
|
-
"result": {
|
|
29
|
-
"create_time": int(transaction.created_at_ms),
|
|
30
|
-
"perform_time": transaction.perform_time,
|
|
31
|
-
"cancel_time": transaction.cancel_time,
|
|
32
|
-
"transaction": transaction.transaction_id,
|
|
33
|
-
"state": transaction.state,
|
|
34
|
-
"reason": None,
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if transaction.reason is not None:
|
|
38
|
-
response["result"]["reason"] = int(transaction.reason)
|
|
39
|
-
|
|
40
|
-
except DatabaseError as error:
|
|
41
|
-
logger.error("Error getting transaction in database: %s", error)
|
|
42
|
-
|
|
43
|
-
return None, response
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import uuid
|
|
2
|
-
import time
|
|
3
|
-
import datetime
|
|
4
|
-
|
|
5
|
-
from payme.utils.logging import logger
|
|
6
|
-
from payme.utils.get_params import get_params
|
|
7
|
-
from payme.models import MerchantTransactionsModel
|
|
8
|
-
from payme.errors.exceptions import TooManyRequests
|
|
9
|
-
from payme.serializers import MerchantTransactionsModelSerializer
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class CreateTransaction:
|
|
13
|
-
"""
|
|
14
|
-
CreateTransaction class
|
|
15
|
-
That's used to create transaction
|
|
16
|
-
|
|
17
|
-
Full method documentation
|
|
18
|
-
-------------------------
|
|
19
|
-
https://developer.help.paycom.uz/metody-merchant-api/createtransaction
|
|
20
|
-
"""
|
|
21
|
-
def __call__(self, params: dict) -> tuple:
|
|
22
|
-
serializer = MerchantTransactionsModelSerializer(
|
|
23
|
-
data=get_params(params)
|
|
24
|
-
)
|
|
25
|
-
serializer.is_valid(raise_exception=True)
|
|
26
|
-
order_id = serializer.validated_data.get("order_id")
|
|
27
|
-
|
|
28
|
-
try:
|
|
29
|
-
transaction = MerchantTransactionsModel.objects.filter(
|
|
30
|
-
order_id=order_id
|
|
31
|
-
).last()
|
|
32
|
-
|
|
33
|
-
if transaction is not None:
|
|
34
|
-
if transaction._id != serializer.validated_data.get("_id"):
|
|
35
|
-
raise TooManyRequests()
|
|
36
|
-
|
|
37
|
-
except TooManyRequests as error:
|
|
38
|
-
logger.error("Too many requests for transaction %s", error)
|
|
39
|
-
raise TooManyRequests() from error
|
|
40
|
-
|
|
41
|
-
if transaction is None:
|
|
42
|
-
transaction, _ = \
|
|
43
|
-
MerchantTransactionsModel.objects.get_or_create(
|
|
44
|
-
_id=serializer.validated_data.get('_id'),
|
|
45
|
-
order_id=serializer.validated_data.get('order_id'),
|
|
46
|
-
transaction_id=uuid.uuid4(),
|
|
47
|
-
amount=serializer.validated_data.get('amount'),
|
|
48
|
-
created_at_ms=int(time.time() * 1000),
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
if transaction:
|
|
52
|
-
response: dict = {
|
|
53
|
-
"result": {
|
|
54
|
-
"create_time": int(transaction.created_at_ms),
|
|
55
|
-
"transaction": transaction.transaction_id,
|
|
56
|
-
"state": int(transaction.state),
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return order_id, response
|
|
61
|
-
|
|
62
|
-
@staticmethod
|
|
63
|
-
def _convert_ms_to_datetime(time_ms: int) -> datetime:
|
|
64
|
-
"""Use this format to convert from time ms to datetime format.
|
|
65
|
-
"""
|
|
66
|
-
readable_datetime = datetime.datetime.fromtimestamp(time_ms / 1000)
|
|
67
|
-
|
|
68
|
-
return readable_datetime
|
payme/methods/generate_link.py
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
from decimal import Decimal
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
|
|
5
|
-
from django.conf import settings
|
|
6
|
-
|
|
7
|
-
PAYME_ID = settings.PAYME.get('PAYME_ID')
|
|
8
|
-
PAYME_ACCOUNT = settings.PAYME.get('PAYME_ACCOUNT')
|
|
9
|
-
PAYME_CALL_BACK_URL = settings.PAYME.get('PAYME_CALL_BACK_URL')
|
|
10
|
-
PAYME_URL = settings.PAYME.get("PAYME_URL")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@dataclass
|
|
14
|
-
class GeneratePayLink:
|
|
15
|
-
"""
|
|
16
|
-
GeneratePayLink dataclass
|
|
17
|
-
That's used to generate pay lint for each order.
|
|
18
|
-
|
|
19
|
-
Parameters
|
|
20
|
-
----------
|
|
21
|
-
order_id: int — The order_id for paying
|
|
22
|
-
amount: int — The amount belong to the order
|
|
23
|
-
callback_url: str \
|
|
24
|
-
The merchant api callback url to redirect after payment. Optional parameter.
|
|
25
|
-
By default, it takes PAYME_CALL_BACK_URL from your settings
|
|
26
|
-
|
|
27
|
-
Returns str — pay link
|
|
28
|
-
----------------------
|
|
29
|
-
|
|
30
|
-
Full method documentation
|
|
31
|
-
-------------------------
|
|
32
|
-
https://developer.help.paycom.uz/initsializatsiya-platezhey/
|
|
33
|
-
"""
|
|
34
|
-
order_id: str
|
|
35
|
-
amount: Decimal
|
|
36
|
-
callback_url: str = None
|
|
37
|
-
|
|
38
|
-
def generate_link(self) -> str:
|
|
39
|
-
"""
|
|
40
|
-
GeneratePayLink for each order.
|
|
41
|
-
"""
|
|
42
|
-
generated_pay_link: str = "{payme_url}/{encode_params}"
|
|
43
|
-
params: str = 'm={payme_id};ac.{payme_account}={order_id};a={amount};c={call_back_url}'
|
|
44
|
-
|
|
45
|
-
if self.callback_url:
|
|
46
|
-
redirect_url = self.callback_url
|
|
47
|
-
else:
|
|
48
|
-
redirect_url = PAYME_CALL_BACK_URL
|
|
49
|
-
|
|
50
|
-
params = params.format(
|
|
51
|
-
payme_id=PAYME_ID,
|
|
52
|
-
payme_account=PAYME_ACCOUNT,
|
|
53
|
-
order_id=self.order_id,
|
|
54
|
-
amount=self.amount,
|
|
55
|
-
call_back_url=redirect_url
|
|
56
|
-
)
|
|
57
|
-
encode_params = base64.b64encode(params.encode("utf-8"))
|
|
58
|
-
return generated_pay_link.format(
|
|
59
|
-
payme_url=PAYME_URL,
|
|
60
|
-
encode_params=str(encode_params, 'utf-8')
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
@staticmethod
|
|
64
|
-
def to_tiyin(amount: Decimal) -> Decimal:
|
|
65
|
-
"""
|
|
66
|
-
Convert from sum to tiyin.
|
|
67
|
-
|
|
68
|
-
Parameters
|
|
69
|
-
----------
|
|
70
|
-
amount: Decimal -> order amount
|
|
71
|
-
"""
|
|
72
|
-
return amount * 100
|
|
73
|
-
|
|
74
|
-
@staticmethod
|
|
75
|
-
def to_sum(amount: Decimal) -> Decimal:
|
|
76
|
-
"""
|
|
77
|
-
Convert from tiyin to sum.
|
|
78
|
-
|
|
79
|
-
Parameters
|
|
80
|
-
----------
|
|
81
|
-
amount: Decimal -> order amount
|
|
82
|
-
"""
|
|
83
|
-
return amount / 100
|
payme/methods/get_statement.py
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
from django.db import DatabaseError
|
|
2
|
-
|
|
3
|
-
from payme.utils.logging import logger
|
|
4
|
-
from payme.models import MerchantTransactionsModel
|
|
5
|
-
from payme.serializers import MerchantTransactionsModelSerializer as MTMS
|
|
6
|
-
from payme.utils.make_aware_datetime import make_aware_datetime as mad
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class GetStatement:
|
|
10
|
-
"""
|
|
11
|
-
GetStatement class
|
|
12
|
-
Transaction information is used for reconciliation
|
|
13
|
-
of merchant and Payme Business transactions.
|
|
14
|
-
|
|
15
|
-
Full method documentation
|
|
16
|
-
-------------------------
|
|
17
|
-
https://developer.help.paycom.uz/metody-merchant-api/getstatement
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
def __call__(self, params: dict) -> tuple:
|
|
21
|
-
clean_data: dict = MTMS.get_validated_data(
|
|
22
|
-
params=params
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
start_date, end_date = mad(
|
|
26
|
-
int(clean_data.get("start_date")),
|
|
27
|
-
int(clean_data.get("end_date"))
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
try:
|
|
31
|
-
transactions = \
|
|
32
|
-
MerchantTransactionsModel.objects.filter(
|
|
33
|
-
created_at__gte=start_date,
|
|
34
|
-
created_at__lte=end_date
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
if not transactions: # no transactions found for the period
|
|
38
|
-
return None, {"result": {"transactions": []}}
|
|
39
|
-
|
|
40
|
-
statements = [
|
|
41
|
-
{
|
|
42
|
-
'id': t._id,
|
|
43
|
-
'time': int(t.created_at.timestamp()),
|
|
44
|
-
'amount': t.amount,
|
|
45
|
-
'account': {'order_id': t.order_id},
|
|
46
|
-
'create_time': int(t.created_at_ms),
|
|
47
|
-
'perform_time': t.perform_time,
|
|
48
|
-
'cancel_time': t.cancel_time,
|
|
49
|
-
'transaction': t.order_id,
|
|
50
|
-
'state': t.state,
|
|
51
|
-
'reason': int(t.reason) if t.reason is not None else None,
|
|
52
|
-
'receivers': [] # not implemented
|
|
53
|
-
} for t in transactions
|
|
54
|
-
]
|
|
55
|
-
|
|
56
|
-
response: dict = {
|
|
57
|
-
"result": {
|
|
58
|
-
"transactions": statements
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
except DatabaseError as error:
|
|
62
|
-
logger.error("Error getting transaction in database: %s", error)
|
|
63
|
-
response = {"result": {"transactions": []}}
|
|
64
|
-
|
|
65
|
-
return None, response
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import time
|
|
2
|
-
|
|
3
|
-
from django.db import DatabaseError
|
|
4
|
-
|
|
5
|
-
from payme.utils.logging import logger
|
|
6
|
-
from payme.utils.get_params import get_params
|
|
7
|
-
from payme.models import MerchantTransactionsModel
|
|
8
|
-
from payme.serializers import MerchantTransactionsModelSerializer
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class PerformTransaction:
|
|
12
|
-
"""
|
|
13
|
-
PerformTransaction class
|
|
14
|
-
That's used to perform a transaction.
|
|
15
|
-
|
|
16
|
-
Full method documentation
|
|
17
|
-
-------------------------
|
|
18
|
-
https://developer.help.paycom.uz/metody-merchant-api/performtransaction
|
|
19
|
-
"""
|
|
20
|
-
def __call__(self, params: dict) -> tuple:
|
|
21
|
-
serializer = MerchantTransactionsModelSerializer(
|
|
22
|
-
data=get_params(params)
|
|
23
|
-
)
|
|
24
|
-
serializer.is_valid(raise_exception=True)
|
|
25
|
-
clean_data: dict = serializer.validated_data
|
|
26
|
-
response: dict = None
|
|
27
|
-
try:
|
|
28
|
-
transaction = \
|
|
29
|
-
MerchantTransactionsModel.objects.get(
|
|
30
|
-
_id=clean_data.get("_id"),
|
|
31
|
-
)
|
|
32
|
-
transaction.state = 2
|
|
33
|
-
if transaction.perform_time == 0:
|
|
34
|
-
transaction.perform_time = int(time.time() * 1000)
|
|
35
|
-
|
|
36
|
-
transaction.save()
|
|
37
|
-
response: dict = {
|
|
38
|
-
"result": {
|
|
39
|
-
"perform_time": int(transaction.perform_time),
|
|
40
|
-
"transaction": transaction.transaction_id,
|
|
41
|
-
"state": int(transaction.state),
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
except DatabaseError as error:
|
|
45
|
-
logger.error("error while getting transaction in db: %s", error)
|
|
46
|
-
|
|
47
|
-
return transaction.order_id, response
|
payme/migrations/0001_initial.py
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# pylint: disable=invalid-name
|
|
2
|
-
from django.db import migrations, models
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Migration(migrations.Migration):
|
|
6
|
-
# pylint: disable=missing-class-docstring
|
|
7
|
-
initial = True
|
|
8
|
-
dependencies = []
|
|
9
|
-
|
|
10
|
-
operations = [
|
|
11
|
-
migrations.CreateModel(
|
|
12
|
-
name='MerchantTransactionsModel',
|
|
13
|
-
fields=[
|
|
14
|
-
('id', models.BigAutoField(
|
|
15
|
-
auto_created=True,
|
|
16
|
-
primary_key=True,
|
|
17
|
-
serialize=False,
|
|
18
|
-
verbose_name='ID')
|
|
19
|
-
),
|
|
20
|
-
('_id', models.CharField(max_length=255, null=True)),
|
|
21
|
-
('transaction_id', models.CharField(max_length=255, null=True)),
|
|
22
|
-
('order_id', models.BigIntegerField(blank=True, null=True)),
|
|
23
|
-
('amount', models.FloatField(blank=True, null=True)),
|
|
24
|
-
('time', models.BigIntegerField(blank=True, null=True)),
|
|
25
|
-
('perform_time', models.BigIntegerField(default=0, null=True)),
|
|
26
|
-
('cancel_time', models.BigIntegerField(default=0, null=True)),
|
|
27
|
-
('state', models.IntegerField(default=1, null=True)),
|
|
28
|
-
('reason', models.CharField(blank=True, max_length=255, null=True)),
|
|
29
|
-
('created_at_ms', models.CharField(blank=True, max_length=255, null=True)),
|
|
30
|
-
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
31
|
-
('updated_at', models.DateTimeField(auto_now=True)),
|
|
32
|
-
],
|
|
33
|
-
),
|
|
34
|
-
migrations.CreateModel(
|
|
35
|
-
name='Order',
|
|
36
|
-
fields=[
|
|
37
|
-
('id', models.BigAutoField(
|
|
38
|
-
auto_created=True,
|
|
39
|
-
primary_key=True,
|
|
40
|
-
serialize=False,
|
|
41
|
-
verbose_name='ID')
|
|
42
|
-
),
|
|
43
|
-
('amount', models.IntegerField(blank=True, null=True)),
|
|
44
|
-
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
45
|
-
('updated_at', models.DateTimeField(auto_now=True)),
|
|
46
|
-
],
|
|
47
|
-
),
|
|
48
|
-
]
|
payme/receipts/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .import subscribe_receipts
|