payme-pkg 2.6.5__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.

Files changed (51) hide show
  1. payme/__init__.py +1 -0
  2. payme/admin.py +12 -6
  3. payme/apps.py +0 -4
  4. payme/classes/cards.py +203 -0
  5. payme/classes/client.py +30 -0
  6. payme/classes/http.py +107 -0
  7. payme/classes/initializer.py +82 -0
  8. payme/classes/receipts.py +298 -0
  9. payme/const.py +12 -0
  10. payme/exceptions/__init__.py +5 -0
  11. payme/exceptions/general.py +275 -0
  12. payme/exceptions/webhook.py +125 -0
  13. payme/models.py +114 -40
  14. payme/types/response/__init__.py +4 -0
  15. payme/types/response/cards.py +110 -0
  16. payme/types/response/receipts.py +215 -0
  17. payme/types/response/webhook.py +136 -0
  18. payme/urls.py +2 -2
  19. payme/util.py +26 -0
  20. payme/views.py +287 -113
  21. payme_pkg-3.0.17.dist-info/METADATA +193 -0
  22. payme_pkg-3.0.17.dist-info/RECORD +29 -0
  23. {payme_pkg-2.6.5.dist-info → payme_pkg-3.0.17.dist-info}/WHEEL +1 -1
  24. payme/cards/__init__.py +0 -1
  25. payme/cards/subscribe_cards.py +0 -166
  26. payme/decorators/decorators.py +0 -34
  27. payme/errors/exceptions.py +0 -89
  28. payme/methods/cancel_transaction.py +0 -54
  29. payme/methods/check_perform_transaction.py +0 -26
  30. payme/methods/check_transaction.py +0 -43
  31. payme/methods/create_transaction.py +0 -68
  32. payme/methods/generate_link.py +0 -83
  33. payme/methods/get_statement.py +0 -65
  34. payme/methods/perform_transaction.py +0 -47
  35. payme/migrations/0001_initial.py +0 -48
  36. payme/receipts/__init__.py +0 -1
  37. payme/receipts/subscribe_receipts.py +0 -217
  38. payme/serializers.py +0 -86
  39. payme/utils/__init__.py +0 -0
  40. payme/utils/get_params.py +0 -24
  41. payme/utils/logging.py +0 -9
  42. payme/utils/make_aware_datetime.py +0 -21
  43. payme/utils/support.py +0 -8
  44. payme/utils/to_json.py +0 -13
  45. payme_pkg-2.6.5.dist-info/METADATA +0 -13
  46. payme_pkg-2.6.5.dist-info/RECORD +0 -36
  47. /payme/{decorators → classes}/__init__.py +0 -0
  48. /payme/{errors → types}/__init__.py +0 -0
  49. /payme/{methods → types/request}/__init__.py +0 -0
  50. {payme_pkg-2.6.5.dist-info → payme_pkg-3.0.17.dist-info}/LICENSE.txt +0 -0
  51. {payme_pkg-2.6.5.dist-info → payme_pkg-3.0.17.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.1
2
+ Name: payme-pkg
3
+ Version: 3.0.17
4
+ Home-page: https://github.com/Muhammadali-Akbarov/payme-pkg
5
+ Author: Muhammadali Akbarov
6
+ Author-email: muhammadali17abc@gmail.com
7
+ License: MIT
8
+ Keywords: paymeuz paycomuz payme-merchant merchant-api subscribe-api payme-pkg payme-api
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE.txt
11
+ Requires-Dist: requests (==2.*)
12
+ Requires-Dist: djangorestframework (==3.*)
13
+ Requires-Dist: dataclasses (==0.*) ; python_version < "3.7"
14
+
15
+ <h1 align="center">Payme Software Development Kit</h1>
16
+
17
+ <p align="center">
18
+ <a href="https://t.me/+lO97J78xBj45MzBi">
19
+ <img src="https://img.shields.io/badge/Support%20Group-blue?logo=telegram&logoColor=white" alt="Support Group on Telegram"/>
20
+ </a>
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a href="https://docs.pay-tech.uz"><img src="https://img.shields.io/static/v1?message=Documentation&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1"></a>
25
+ <a href="https://github.com/PayTechUz/payme-pkg"><img src="https://img.shields.io/badge/Open_Source-❤️-FDA599?"/></a>
26
+ <a href="https://github.com/PayTechUz/payme-pkg/issues">
27
+ <img src="https://img.shields.io/github/issues/PayTechUz/payme-pkg" />
28
+ </a>
29
+ <a href="https://pepy.tech/project/payme-pkg">
30
+ <img src="https://static.pepy.tech/badge/payme-pkg" alt="PyPI - Downloads" />
31
+ </a>
32
+ </p>
33
+
34
+ <p align="center">Welcome to payme-pkg, the open source payme SDK for Python.</p>
35
+
36
+ <p align="center">You can use it for test and production mode. Join our community and ask everything you need.</p>
37
+
38
+ <a href="https://docs.pay-tech.uz">
39
+ <p align="center">Visit the full documentation for Merchant and Subscribe API</p>
40
+ </a>
41
+
42
+ <a href="https://youtu.be/xxiIggu_RNk?si=Idpg8omFvFDCYtcm" target="_blank">
43
+ <p align="center">
44
+ <img style="width: 60%;" src="https://i.postimg.cc/WbD32bHC/payme-pkg-demo-m4a.gif" alt="Payme PKG Demo">
45
+ </p>
46
+ </a>
47
+
48
+ <p align="center">
49
+ <a href="https://youtu.be/7q7-c72tHpc?si=Sr0EAmEawWAFRk1m" target="_blank">
50
+ <img src="https://img.shields.io/badge/Watch%20Demo-red?logo=youtube&logoColor=white&style=for-the-badge"
51
+ alt="Watch the YouTube Demo"
52
+ style="width: 150px; height: 30px; border-radius: 7px;" />
53
+ </a>
54
+ </p>
55
+
56
+
57
+ ## Installation
58
+
59
+ ```shell
60
+ pip install payme-pkg
61
+ ```
62
+
63
+ ## Installation to Django
64
+
65
+ Add `'payme'` in to your settings.py
66
+
67
+ ```python
68
+ INSTALLED_APPS = [
69
+ ...
70
+ 'payme',
71
+ ...
72
+ ]
73
+ ```
74
+
75
+ Add `'payme'` credentials inside to settings.py
76
+
77
+ One time payment (Однаразовый платеж) configuration settings.py
78
+
79
+ Example project: https://github.com/PayTechUz/shop-backend
80
+ ```python
81
+ PAYME_ID = "your-payme-id"
82
+ PAYME_KEY = "your-payme-key"
83
+ PAYME_ACCOUNT_FIELD = "order_id"
84
+ PAYME_AMOUNT_FIELD = "total_amount"
85
+ PAYME_ACCOUNT_MODEL = "orders.models.Orders"
86
+ PAYME_ONE_TIME_PAYMENT = True
87
+ ```
88
+
89
+ Multi payment (Накопительный) configuration settings.py
90
+
91
+ Example project: Coming soon
92
+ ```python
93
+ PAYME_ID = "your-payme-id"
94
+ PAYME_KEY = "your-payme-key"
95
+ PAYME_ACCOUNT_FIELD = "id"
96
+ PAYME_ACCOUNT_MODEL = "clients.models.Client"
97
+ PAYME_ONE_TIME_PAYMENT = False
98
+ ```
99
+
100
+ Create a new View that about handling call backs
101
+ ```python
102
+ from payme.views import PaymeWebHookAPIView
103
+
104
+
105
+ class PaymeCallBackAPIView(PaymeWebHookAPIView):
106
+ def handle_created_payment(self, params, result, *args, **kwargs):
107
+ """
108
+ Handle the successful payment. You can override this method
109
+ """
110
+ print(f"Transaction created for this params: {params} and cr_result: {result}")
111
+
112
+ def handle_successfully_payment(self, params, result, *args, **kwargs):
113
+ """
114
+ Handle the successful payment. You can override this method
115
+ """
116
+ print(f"Transaction successfully performed for this params: {params} and performed_result: {result}")
117
+
118
+ def handle_cancelled_payment(self, params, result, *args, **kwargs):
119
+ """
120
+ Handle the cancelled payment. You can override this method
121
+ """
122
+ print(f"Transaction cancelled for this params: {params} and cancelled_result: {result}")
123
+ ```
124
+
125
+ Add a `payme` path to core of urlpatterns:
126
+
127
+ ```python
128
+ from django.urls import path
129
+ from django.urls import include
130
+
131
+ from your_app.views import PaymeCallBackAPIView
132
+
133
+ urlpatterns = [
134
+ ...
135
+ path("payment/update/", PaymeCallBackAPIView.as_view()),
136
+ ...
137
+ ]
138
+ ```
139
+
140
+ Run migrations
141
+ ```shell
142
+ python3 manage.py makemigrations && python manage.py migrate
143
+ ```
144
+ 🎉 Congratulations you have been integrated merchant api methods with django, keep reading docs. After successfull migrations check your admin panel and see results what happened.
145
+
146
+ ## Generate Pay Link
147
+
148
+ Example to generate link:
149
+
150
+ - Input
151
+
152
+ ```python
153
+ from payme import Payme
154
+
155
+ payme = Payme(payme_id="your-payme-id")
156
+ pay_link = payme.initializer.generate_pay_link(id=123456, amount=5000, return_url="https://example.com")
157
+ print(pay_link)
158
+ ```
159
+
160
+ - Output
161
+
162
+ ```
163
+ https://checkout.paycom.uz/bT15b3VyLXBheW1lLWlkO2FjLmlkPTEyMzQ1NjthPTUwMDAwMDtjPWh0dHBzOi8vZXhhbXBsZS5jb20=
164
+ ```
165
+
166
+
167
+ ## Generate Fallback Link
168
+
169
+
170
+ Example to generate fallback link:
171
+
172
+ - Input
173
+
174
+ The ID in the fallback is different from the merchant ID. You can get the ID from the Payme team.
175
+ ```python
176
+ from payme import Payme
177
+
178
+ payme = Payme(payme_id="your-payme-id", fallback_id="your-fallback-id")
179
+
180
+ form_fields = {
181
+ "driver_id": 12345,
182
+ "amount": 1000
183
+ }
184
+
185
+ fallback_link = payme.initializer.generate_fallback_link(form_fields) # form field is optional
186
+ print(fallback_link)
187
+ ```
188
+
189
+ - Output
190
+
191
+ ```
192
+ https://payme.uz/fallback/merchant/?id=examplelinkgenerated&driver_id=12345&amount=1000
193
+ ```
@@ -0,0 +1,29 @@
1
+ payme/__init__.py,sha256=dzLIyA9kQl0sO6z9nHkZDTjkfiI1BepdifKtJbjX2Cw,46
2
+ payme/admin.py,sha256=67uHZiZe2w2s0TE23PS2v-V3xXRaha6o9acjVmNIQbM,470
3
+ payme/apps.py,sha256=HHCY4zUNKPcjz25z0MahZcks0lsAxTGPS0Ml3U4DhZc,142
4
+ payme/const.py,sha256=azndfKR53fe7mDfGW82Q-kwWdMu3x4S1upKc4gkYdlA,214
5
+ payme/models.py,sha256=mT6sIeDOs-pKZ_b8Y9oafHBv5GruioJkpTqTGZ8AulA,4360
6
+ payme/urls.py,sha256=_oUOwxW1Suc5TUmnj--lySYbotRg4yTDkDLJU20CGjE,145
7
+ payme/util.py,sha256=UFb4cEnaufS_hh9C_0z079CSgJGivYjIgOl2iAFrBMs,625
8
+ payme/views.py,sha256=A5_GxSFS1Hif2W1LAGP5YfnGazdaaqLXgFLEy2z0A7k,11928
9
+ payme/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ payme/classes/cards.py,sha256=dr3SQdKAhfQmECtwHYW2nmx8wXaNYQFkg5uQU9z8vs4,7624
11
+ payme/classes/client.py,sha256=_eMcSTiwMdwIe0aeccVav-43Uq7ORdH7idOuSTPjpcg,837
12
+ payme/classes/http.py,sha256=KoEbjbeNCUCeCo2R36FH3SfDlyrZTU9OjiSmRA-dVms,3411
13
+ payme/classes/initializer.py,sha256=FvzKp068JfSzHwcQ_w-eXYTomV5ggz7_p5zYBkAtBI4,2326
14
+ payme/classes/receipts.py,sha256=KU4qyGHWZpWW88SjmmTD_N2Tz8pWOCvBbOPnw5tcS3Y,10094
15
+ payme/exceptions/__init__.py,sha256=HoBFnDA3eW_xWZiFlonJK4vhBDTsuik91tvgzXTy8KA,94
16
+ payme/exceptions/general.py,sha256=quy9TRv0HCUjP5EfplHyoLXuAGbrRnPveHeQZmBlHa8,7655
17
+ payme/exceptions/webhook.py,sha256=f0J-fmCW_wpgsTmjGAOtyoZjIOoFpbQwkh_7cZUZkv0,3046
18
+ payme/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ payme/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ payme/types/request/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ payme/types/response/__init__.py,sha256=GAj5pjZ9oIO67T6YMiPd1fhTIvGrPfTv96tykfeChQc,81
22
+ payme/types/response/cards.py,sha256=ilXFDUOPNabVsrQN1KWEzDiL6cDxdVvCbfEl6jCzGpU,1997
23
+ payme/types/response/receipts.py,sha256=TlZeJyymRVHIorg0kbUaogy6MZxN1oq2jHGVRUnlY5A,4070
24
+ payme/types/response/webhook.py,sha256=Br6Gr_-h7sCmOc3ag7H5yBryB8j-bm2mrt39Cy_Fy2E,2918
25
+ payme_pkg-3.0.17.dist-info/LICENSE.txt,sha256=75dBVYmbzWUhwtaB1MSZfj-M-PGaMmeT9UVPli2-ZJ0,1086
26
+ payme_pkg-3.0.17.dist-info/METADATA,sha256=dwjIyS9BH5OHbiivwBoOwZ90OTJwWt0hBMsr5QmwvuU,5534
27
+ payme_pkg-3.0.17.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
28
+ payme_pkg-3.0.17.dist-info/top_level.txt,sha256=8mN-hGAa38pWbhrKHFs9CZywPCdidhMuwPKwuFJa0qw,6
29
+ payme_pkg-3.0.17.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: setuptools (73.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
payme/cards/__init__.py DELETED
@@ -1 +0,0 @@
1
- from . import subscribe_cards
@@ -1,166 +0,0 @@
1
- from ..decorators.decorators import payme_request
2
- from ..utils.to_json import to_json
3
-
4
-
5
- class PaymeSubscribeCards:
6
- """
7
- The PaymeSubscribeCards class includes
8
- all paycom methods which are belongs to cards.
9
-
10
- Parameters
11
- ----------
12
- base_url: str — The base url of the paycom api
13
- paycom_id: str — The paycom_id uses to identify
14
- timeout: int — How many seconds to wait for the server to send data
15
-
16
- Full method documentation
17
- -------------------------
18
- https://developer.help.paycom.uz/metody-subscribe-api/
19
- """
20
- def __init__(
21
- self,
22
- base_url: str,
23
- paycom_id: str,
24
- timeout=5
25
- ) -> "PaymeSubscribeCards":
26
- self.base_url: str = base_url
27
- self.timeout: int = timeout
28
- self.headers: dict = {
29
- "X-Auth": paycom_id,
30
- }
31
- self.__methods: dict = {
32
- "cards_check": "cards.check",
33
- "cards_create": "cards.create",
34
- "cards_remove": "cards.remove",
35
- "cards_verify": "cards.verify",
36
- "cards_get_verify_code": "cards.get_verify_code",
37
- }
38
-
39
- @payme_request
40
- def __request(self, data) -> dict:
41
- """
42
- Use this private method to request.
43
- On success,response will be OK with format JSON.
44
-
45
- Parameters
46
- ----------
47
- data: dict — Includes request data.
48
-
49
- Returns dictionary Payme Response
50
- ---------------------------------
51
- """
52
- return data
53
-
54
- def cards_create(self, number: str, expire: str, save: bool = True) -> dict:
55
- """
56
- Use this method to create a new card's token.
57
-
58
- Parameters
59
- ----------
60
- number: str — The card number maximum length 18 char
61
- expire: str — The card expiration string maximum length 5 char
62
- save: bool \
63
- Type of token. Optional parameter
64
- The option is enabled or disabled depending on the application's business logic
65
- If the flag is true, the token can be used for further payments
66
- if the flag is false the token can only be used once
67
- The one-time token is deleted after payment
68
-
69
- Full method documentation
70
- -------------------------
71
- https://developer.help.paycom.uz/metody-subscribe-api/cards.create
72
- """
73
- data: dict = {
74
- "method": self.__methods.get("cards_create"),
75
- "params": {
76
- "card": {
77
- "number": number,
78
- "expire": expire,
79
- },
80
- "save": save,
81
- }
82
- }
83
- return self.__request(to_json(**data))
84
-
85
- def card_get_verify_code(self, token: str) -> dict:
86
- """
87
- Use this method to get the verification code.
88
-
89
- Parameters
90
- ----------
91
- token: str — The card's non-active token
92
-
93
- Full method documentation
94
- -------------------------
95
- https://developer.help.paycom.uz/metody-subscribe-api/cards.get_verify_code
96
- """
97
- data: dict = {
98
- "method": self.__methods.get('cards_get_verify_code'),
99
- "params": {
100
- "token": token,
101
- }
102
- }
103
- return self.__request(to_json(**data))
104
-
105
- def cards_verify(self, verify_code: str, token: str) -> dict:
106
- """
107
- Verification of the card using the code sent via SMS.
108
-
109
- Parameters
110
- ----------
111
- verify_code: str — Code for verification
112
- token: str — The card's non-active token
113
-
114
- Full method documentation
115
- -------------------------
116
- https://developer.help.paycom.uz/metody-subscribe-api/cards.verify
117
- """
118
- data: dict = {
119
- "method": self.__methods.get("cards_verify"),
120
- "params": {
121
- "token": token,
122
- "code": verify_code
123
- }
124
- }
125
- return self.__request(to_json(**data))
126
-
127
- def cards_check(self, token: str) -> dict:
128
- """
129
- Checking the card token active or non-active.
130
-
131
- Parameters
132
- ----------
133
- token: str — The card's non-active token
134
-
135
- Full method documentation
136
- -------------------------
137
- https://developer.help.paycom.uz/metody-subscribe-api/cards.check
138
- """
139
- data: dict = {
140
- "method": self.__methods.get("cards_check"),
141
- "params": {
142
- "token": token,
143
- }
144
- }
145
-
146
- return self.__request(to_json(**data))
147
-
148
- def cards_remove(self, token: str) -> dict:
149
- """
150
- Delete card's token on success returns success.
151
-
152
- Parameters
153
- ----------
154
- token: str — The card's non-active token
155
-
156
- Full method documentation
157
- -------------------------
158
- https://developer.help.paycom.uz/metody-subscribe-api/cards.remove
159
- """
160
- data: dict = {
161
- "method": self.__methods.get("cards_remove"),
162
- "params": {
163
- "token": token,
164
- }
165
- }
166
- return self.__request(to_json(**data))
@@ -1,34 +0,0 @@
1
- import functools
2
-
3
- from requests import request
4
- from requests.exceptions import Timeout
5
- from requests.exceptions import RequestException
6
-
7
- from ..utils.logging import logger
8
-
9
- from ..errors.exceptions import PaymeTimeoutException
10
-
11
-
12
- def payme_request(func):
13
- """
14
- Payme request decorator.
15
- """
16
- @functools.wraps(func)
17
- def wrapper(self, data):
18
- response = None
19
- req_data = {
20
- "method": "POST",
21
- "url": self.base_url,
22
- "data": data,
23
- "headers": self.headers,
24
- "timeout": self.timeout,
25
- }
26
- try:
27
- response = request(**req_data)
28
- response.raise_for_status()
29
- except (Timeout, RequestException) as error:
30
- logger.info("Payme request has been failed as error: %s", error)
31
- raise PaymeTimeoutException() from error
32
- return response.json()
33
-
34
- return wrapper
@@ -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
- """
@@ -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