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.

Files changed (64) 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 +113 -46
  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-3.0.17.dist-info/top_level.txt +1 -0
  24. core/asgi.py +0 -16
  25. core/settings.py +0 -133
  26. core/urls.py +0 -25
  27. core/wsgi.py +0 -16
  28. my_app/admin.py +0 -3
  29. my_app/apps.py +0 -6
  30. my_app/models.py +0 -3
  31. my_app/tests.py +0 -3
  32. my_app/views.py +0 -16
  33. payme/cards/__init__.py +0 -1
  34. payme/cards/subscribe_cards.py +0 -166
  35. payme/decorators/__init__.py +0 -0
  36. payme/decorators/decorators.py +0 -34
  37. payme/errors/__init__.py +0 -0
  38. payme/errors/exceptions.py +0 -89
  39. payme/methods/__init__.py +0 -0
  40. payme/methods/cancel_transaction.py +0 -54
  41. payme/methods/check_perform_transaction.py +0 -26
  42. payme/methods/check_transaction.py +0 -43
  43. payme/methods/create_transaction.py +0 -68
  44. payme/methods/generate_link.py +0 -83
  45. payme/methods/get_statement.py +0 -65
  46. payme/methods/perform_transaction.py +0 -47
  47. payme/migrations/0001_initial.py +0 -48
  48. payme/receipts/__init__.py +0 -1
  49. payme/receipts/subscribe_receipts.py +0 -217
  50. payme/serializers.py +0 -86
  51. payme/utils/__init__.py +0 -0
  52. payme/utils/get_params.py +0 -24
  53. payme/utils/logging.py +0 -9
  54. payme/utils/make_aware_datetime.py +0 -21
  55. payme/utils/support.py +0 -8
  56. payme/utils/to_json.py +0 -13
  57. payme_pkg-2.6.7.dist-info/METADATA +0 -13
  58. payme_pkg-2.6.7.dist-info/RECORD +0 -48
  59. payme_pkg-2.6.7.dist-info/top_level.txt +0 -3
  60. {core → payme/classes}/__init__.py +0 -0
  61. {my_app → payme/types}/__init__.py +0 -0
  62. {my_app/migrations → payme/types/request}/__init__.py +0 -0
  63. {payme_pkg-2.6.7.dist-info → payme_pkg-3.0.17.dist-info}/LICENSE.txt +0 -0
  64. {payme_pkg-2.6.7.dist-info → payme_pkg-3.0.17.dist-info}/WHEEL +0 -0
@@ -1,217 +0,0 @@
1
- from ..decorators.decorators import payme_request
2
- from ..utils.to_json import to_json
3
-
4
-
5
- class PaymeSubscribeReceipts:
6
- """
7
- The PaymeSubscribeReceipts class includes
8
- all paycom methods which are belongs receipts part.
9
-
10
- Parameters
11
- ----------
12
- base_url string: The base url of the paycom api
13
- paycom_id string: The paycom_id uses to identify
14
- paycom_key string: The paycom_key uses to identify too
15
-
16
- Full method documentation
17
- -------------------------
18
- https://developer.help.paycom.uz/metody-subscribe-api/
19
- """
20
-
21
- def __init__(
22
- self,
23
- base_url: str,
24
- paycom_id: str,
25
- paycom_key: str,
26
- timeout: int = 5
27
- ) -> "PaymeSubscribeReceipts":
28
- self.base_url: str = base_url
29
- self.headers: dict = {
30
- "X-Auth": f"{paycom_id}:{paycom_key}"
31
- }
32
- self.__methods: dict = {
33
- "receipts_get": "receipts.get",
34
- "receipts_pay": "receipts.pay",
35
- "receipts_send": "receipts.send",
36
- "receipts_check": "receipts.check",
37
- "receipts_cancel": "receipts.cancel",
38
- "receipts_create": "receipts.create",
39
- "receipts_get_all": "receipts.get_all",
40
- }
41
- self.timeout = timeout
42
-
43
- @payme_request
44
- def __request(self, data) -> dict:
45
- """
46
- Use this private method to request.
47
- On success,response will be OK with format JSON.
48
-
49
- Parameters
50
- ----------
51
- data: dict — Includes request data.
52
-
53
- Returns dictionary Payme Response
54
- ---------------------------------
55
- """
56
- return data
57
-
58
- def receipts_create(self, amount: float, order_id: int) -> dict:
59
- """
60
- Use this method to create a new payment receipt.
61
-
62
- Parameters
63
- ----------
64
- amount: float — Payment amount in tiyins
65
- order_id: int — Order object ID
66
-
67
- Full method documentation
68
- -------------------------
69
- https://developer.help.paycom.uz/metody-subscribe-api/receipts.create
70
- """
71
- data: dict = {
72
- "method": self.__methods.get("receipts_create"),
73
- "params": {
74
- "amount": amount,
75
- "account": {
76
- "order_id": order_id,
77
- }
78
- }
79
- }
80
- return self.__request(to_json(**data))
81
-
82
- def receipts_pay(self, invoice_id: str, token: str, phone: str) -> dict:
83
- """
84
- Use this method to pay for an exist receipt.
85
-
86
- Parameters
87
- ----------
88
- invoice_id: str — Invoice id for identity transaction
89
- token: str — The card's active token
90
- phone: str —The payer's phone number
91
-
92
- Full method documentation
93
- -------------------------
94
- https://developer.help.paycom.uz/metody-subscribe-api/receipts.pay
95
- """
96
- data: dict = {
97
- "method": self.__methods.get("receipts_pay"),
98
- "params": {
99
- "id": invoice_id,
100
- "token": token,
101
- "payer": {
102
- "phone": phone,
103
- }
104
- }
105
- }
106
- return self.__request(to_json(**data))
107
-
108
- def receipts_send(self, invoice_id: str, phone: str) -> dict:
109
- """
110
- Use this method to send a receipt for payment in an SMS message.
111
-
112
- Parameters
113
- ----------
114
- invoice_id: str — The invoice id for identity transaction
115
- phone: str — The payer's phone number
116
-
117
- Full method documentation
118
- -------------------------
119
- https://developer.help.paycom.uz/metody-subscribe-api/receipts.send
120
- """
121
- data: dict = {
122
- "method": self.__methods.get('receipts_send'),
123
- "params": {
124
- "id": invoice_id,
125
- "phone": phone
126
- }
127
- }
128
- return self.__request(to_json(**data))
129
-
130
- def receipts_cancel(self, invoice_id: str) -> dict:
131
- """
132
- Use this method a paid check in the queue for cancellation.
133
-
134
- Parameters
135
- ----------
136
- invoice_id: str — The invoice id for identity transaction
137
-
138
- Full method documentation
139
- -------------------------
140
- https://developer.help.paycom.uz/metody-subscribe-api/receipts.cancel
141
- """
142
- data: dict = {
143
- "method": self.__methods.get('receipts_cancel'),
144
- "params": {
145
- "id": invoice_id
146
- }
147
- }
148
-
149
- return self.__request(to_json(**data))
150
-
151
- def receipts_check(self, invoice_id: str) -> dict:
152
- """
153
- Use this method check for an exist receipt.
154
-
155
- Parameters
156
- ----------
157
- invoice_id: str — The invoice id for identity transaction
158
-
159
- Full method documentation
160
- -------------------------
161
- https://developer.help.paycom.uz/metody-subscribe-api/receipts.check
162
- """
163
- data: dict = {
164
- "method": self.__methods.get('receipts_check'),
165
- "params": {
166
- "id": invoice_id
167
- }
168
- }
169
-
170
- return self.__request(to_json(**data))
171
-
172
- def receipts_get(self, invoice_id: str) -> dict:
173
- """
174
- Use this method check status for an exist receipt.
175
-
176
- Parameters
177
- ----------
178
- invoice_id: str — The invoice id for identity transaction
179
-
180
- Full method documentation
181
- -------------------------
182
- https://developer.help.paycom.uz/metody-subscribe-api/receipts.get
183
- """
184
- data: dict = {
185
- "method": self.__methods.get('receipts_get'),
186
- "params": {
187
- "id": invoice_id
188
- }
189
- }
190
-
191
- return self.__request(to_json(**data))
192
-
193
- def receipts_get_all(self, count: int, _from: int, _to: int, offset: int) -> dict:
194
- """
195
- Use this method get all complete information, on checks for a certain period.
196
-
197
- Parameters
198
- ----------
199
- count: int — The number of checks. Maximum value - 50
200
- _from: str — The date of the beginning
201
- _to: int — The date of the ending
202
- offset: str — The number of subsequent skipped checks.
203
-
204
- Full method documentation
205
- -------------------------
206
- https://developer.help.paycom.uz/metody-subscribe-api/receipts.get_all
207
- """
208
- data: dict = {
209
- "method": self.__methods.get('receipts_get_all'),
210
- "params": {
211
- "count": count,
212
- "from": _from,
213
- "to": _to,
214
- "offset": offset
215
- }
216
- }
217
- return self.__request(to_json(**data))
payme/serializers.py DELETED
@@ -1,86 +0,0 @@
1
- from django.conf import settings
2
-
3
- from rest_framework import serializers
4
-
5
- from payme.models import Order
6
- from payme.utils.logging import logger
7
- from payme.utils.get_params import get_params
8
- from payme.models import MerchantTransactionsModel
9
- from payme.errors.exceptions import IncorrectAmount
10
- from payme.errors.exceptions import PerformTransactionDoesNotExist
11
-
12
-
13
- class MerchantTransactionsModelSerializer(serializers.ModelSerializer):
14
- """
15
- MerchantTransactionsModelSerializer class \
16
- That's used to serialize merchant transactions data.
17
- """
18
- start_date = serializers.IntegerField(allow_null=True)
19
- end_date = serializers.IntegerField(allow_null=True)
20
-
21
- class Meta:
22
- # pylint: disable=missing-class-docstring
23
- model: MerchantTransactionsModel = MerchantTransactionsModel
24
- fields: str = "__all__"
25
- extra_fields = ['start_date', 'end_date']
26
-
27
- def validate(self, attrs) -> dict:
28
- """
29
- Validate the data given to the MerchantTransactionsModel.
30
- """
31
- if attrs.get("order_id") is not None:
32
- try:
33
- order = Order.objects.get(
34
- id=attrs['order_id']
35
- )
36
- if order.amount != int(attrs['amount']):
37
- raise IncorrectAmount()
38
-
39
- except IncorrectAmount as error:
40
- logger.error("Invalid amount for order: %s", attrs['order_id'])
41
- raise IncorrectAmount() from error
42
-
43
- return attrs
44
-
45
- def validate_amount(self, amount: int) -> int:
46
- """
47
- Validator for Transactions Amount.
48
- """
49
- if amount is not None:
50
- if int(amount) <= int(settings.PAYME.get("PAYME_MIN_AMOUNT", 0)):
51
- raise IncorrectAmount("Payment amount is less than allowed.")
52
-
53
- return amount
54
-
55
- def validate_order_id(self, order_id) -> int:
56
- """
57
- Use this method to check if a transaction is allowed to be executed.
58
-
59
- Parameters
60
- ----------
61
- order_id: str -> Order Indentation.
62
- """
63
- try:
64
- Order.objects.get(id=order_id)
65
- except Order.DoesNotExist as error:
66
- logger.error("Order does not exist order_id: %s", order_id)
67
- raise PerformTransactionDoesNotExist() from error
68
-
69
- return order_id
70
-
71
- @staticmethod
72
- def get_validated_data(params: dict) -> dict:
73
- """
74
- This static method helps to get validated data.
75
-
76
- Parameters
77
- ----------
78
- params: dict — Includes request params.
79
- """
80
- serializer = MerchantTransactionsModelSerializer(
81
- data=get_params(params)
82
- )
83
- serializer.is_valid(raise_exception=True)
84
- clean_data: dict = serializer.validated_data
85
-
86
- return clean_data
payme/utils/__init__.py DELETED
File without changes
payme/utils/get_params.py DELETED
@@ -1,24 +0,0 @@
1
- from django.conf import settings
2
-
3
-
4
- def get_params(params: dict) -> dict:
5
- """
6
- Use this function to get the parameters from the payme.
7
- """
8
- account: dict = params.get("account")
9
-
10
- clean_params: dict = {}
11
- clean_params["_id"] = params.get("id")
12
- clean_params["time"] = params.get("time")
13
- clean_params["amount"] = params.get("amount")
14
- clean_params["reason"] = params.get("reason")
15
-
16
- # get statement method params
17
- clean_params["start_date"] = params.get("from")
18
- clean_params["end_date"] = params.get("to")
19
-
20
- if account is not None:
21
- account_name: str = settings.PAYME.get("PAYME_ACCOUNT")
22
- clean_params["order_id"] = account[account_name]
23
-
24
- return clean_params
payme/utils/logging.py DELETED
@@ -1,9 +0,0 @@
1
- import logging
2
-
3
- logging.basicConfig(
4
- level=logging.DEBUG,
5
- format='%(asctime)s %(levelname)s %(message)s',
6
- datefmt='%Y-%m-%d %H:%M:%S'
7
- )
8
-
9
- logger = logging.getLogger(__name__)
@@ -1,21 +0,0 @@
1
- from django.utils.timezone import datetime as dt
2
- from django.utils.timezone import make_aware
3
-
4
-
5
- def make_aware_datetime(start_date: int, end_date: int):
6
- """
7
- Convert Unix timestamps to aware datetimes.
8
-
9
- :param start_date: Unix timestamp (milliseconds)
10
- :param end_date: Unix timestamp (milliseconds)
11
-
12
- :return: A tuple of two aware datetimes
13
- """
14
- return map(
15
- lambda timestamp: make_aware(
16
- dt.fromtimestamp(
17
- timestamp / 1000
18
- )
19
- ),
20
- [start_date, end_date]
21
- )
payme/utils/support.py DELETED
@@ -1,8 +0,0 @@
1
- """
2
- Author: Muhammadali Akbarov
3
- Gmail: muhammadali17abc@gmail.com
4
- Phone: +998888351717
5
- Telegram: @Muhammadalive
6
- Twitter: https://twitter.com/muhammadali_abc
7
- GitHub: https://github.com/Muhammadali-Akbarov/
8
- """
payme/utils/to_json.py DELETED
@@ -1,13 +0,0 @@
1
- import json
2
-
3
-
4
- def to_json(**kwargs) -> dict:
5
- """
6
- Use this static method to data dumps.
7
- """
8
- data: dict = {
9
- "method": kwargs.pop("method"),
10
- "params": kwargs.pop("params"),
11
- }
12
-
13
- return json.dumps(data)
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: payme-pkg
3
- Version: 2.6.7
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
- License-File: LICENSE.txt
10
- Requires-Dist: requests (==2.*)
11
- Requires-Dist: djangorestframework (==3.*)
12
- Requires-Dist: dataclasses (==0.*) ; python_version < "3.7"
13
-
@@ -1,48 +0,0 @@
1
- core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- core/asgi.py,sha256=aYBcmL9ZIJl-k2KlHQcFzaQIcZjvjRwyIm--GS9_L7g,385
3
- core/settings.py,sha256=W6gs8ixOHijinNTszPd7uTMQi_Y4emBMKQK3N0Y84JA,3614
4
- core/urls.py,sha256=J3rpTR5ONotcf6Zi8aNJDDWCJ2ujlh-f9l30rczdJi4,858
5
- core/wsgi.py,sha256=3DHSJFkQKrahriFL2FI-hjg6ApBbiaDzA_8jIOPRhdI,385
6
- my_app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- my_app/admin.py,sha256=suMo4x8I3JBxAFBVIdE-5qnqZ6JAZV0FESABHOSc-vg,63
8
- my_app/apps.py,sha256=kV6-feXWDL_p3CD3QYih-yYk9WKQFfe_tfGH9QX5P10,143
9
- my_app/models.py,sha256=Vjc0p2XbAPgE6HyTF6vll98A4eDhA5AvaQqsc4kQ9AQ,57
10
- my_app/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
11
- my_app/views.py,sha256=1ikQkSo_GbUc8TghNptl5D_-xhjA-hgzCLTpgFrZzX8,608
12
- my_app/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- payme/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- payme/admin.py,sha256=Wj-Iz6r3V0qRJ1fSithR6tNb8IfbPKF6m-x9dk_Ddxc,289
15
- payme/apps.py,sha256=7b92Ava_YcKd1XYRZg9iopgAgh_85D23pqDYFaHfwvs,264
16
- payme/models.py,sha256=POUQp4s1wsCsXRKAYB7uP2yODqBudE9d0dagMsChTpg,2877
17
- payme/serializers.py,sha256=4auC-VJgM9jnF03PqOofDlAd7LkBmrquIxnUdZEcKfk,2783
18
- payme/urls.py,sha256=Yn4w_CQN9q2bi0MbyKMQfvQPMO0ZSSCCp-WgymZYVv4,139
19
- payme/views.py,sha256=qhJ1CQISJWQO22yGFPoYx2Uz87u-W8GOGFq2PdpYDQI,5424
20
- payme/cards/__init__.py,sha256=pkRVms5BueiLeSk6Lo3NKyv67gqg3awi1Aw4G0wRFOo,30
21
- payme/cards/subscribe_cards.py,sha256=IGuFk37FmGvfsj6nj2qQ0AfadRiBv7dOth2e1vFESPI,5064
22
- payme/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- payme/decorators/decorators.py,sha256=RcRl6ppUf_Mr_kwwSqShDizRcycc1izb8_PjouYHtBk,904
24
- payme/errors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- payme/errors/exceptions.py,sha256=99fpyeDcyAckGTypUDSBmgT-gQiERkRoO-XHOSo-kt4,2241
26
- payme/methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- payme/methods/cancel_transaction.py,sha256=3M-aF78VBWCZcMrkq4g56M4nWeaFhuB0VReARJTI8Us,1874
28
- payme/methods/check_perform_transaction.py,sha256=Nq6D60kARCrGftwPtEgITS_KHPZ1Rv9cjEqV-ij5vTw,717
29
- payme/methods/check_transaction.py,sha256=EWzVLorAFsjyxivMdQMAKB8GlQup0ir2Rz28XwruFxI,1433
30
- payme/methods/create_transaction.py,sha256=5i_CEWQeWJkMiZDyvqMnBM50E006D33mOnpg0QAExe0,2323
31
- payme/methods/generate_link.py,sha256=eoV9-sCcK5OFyBbCo973EK2J_9seBqvl-yIdVS-dvFk,2294
32
- payme/methods/get_statement.py,sha256=bBbQyWpS-cTc0TXNTZkCtGkq8NoIbbIXYOsrIpnSWao,2199
33
- payme/methods/perform_transaction.py,sha256=pwscwBw5HRfmCbLGfQq4Az31hilxwhap8QthUVrrQAE,1565
34
- payme/migrations/0001_initial.py,sha256=qp2Ho1inLo29Y9PzWTwkmr1qrqhIbRcifZ8bN9p9il8,2023
35
- payme/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- payme/receipts/__init__.py,sha256=u36DT2QLC96om-biU4pFK5lrskCKOD2z3vOofh5IRO0,32
37
- payme/receipts/subscribe_receipts.py,sha256=WA0pZW65WRytk3qH62UikZ06eDXlJUNo_RkXWOAY7eo,6605
38
- payme/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
- payme/utils/get_params.py,sha256=93dJ-sc38BnYFPJssYfJ2W0yJjv2SGM1hMzVeIxRIUM,719
40
- payme/utils/logging.py,sha256=jp4YbMxxLPqtbpKDNvi-tAyvp3cgg_PjH-6X6ePUc2E,186
41
- payme/utils/make_aware_datetime.py,sha256=S0qmf7SgFvSS3tV7Zv4snTwMemvkf07EbOM-10e6xwE,546
42
- payme/utils/support.py,sha256=UE6bgkvVDbhoMolYPaTnadb_-i-Hc_AIDQTZ-vddA3A,209
43
- payme/utils/to_json.py,sha256=XqRHRuIq4W2NXdXftAQ-pvFBvZyTDZ-ajUrJAqCooUE,237
44
- payme_pkg-2.6.7.dist-info/LICENSE.txt,sha256=75dBVYmbzWUhwtaB1MSZfj-M-PGaMmeT9UVPli2-ZJ0,1086
45
- payme_pkg-2.6.7.dist-info/METADATA,sha256=8WeCxhywx_V9ToHgS8m2FHAbkHRhuhlMqryVKrtuVkw,446
46
- payme_pkg-2.6.7.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
47
- payme_pkg-2.6.7.dist-info/top_level.txt,sha256=D0GInMfFt19S63Vvv4HMFRO-_YULuWk7A3vo7_lO5_M,18
48
- payme_pkg-2.6.7.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- core
2
- my_app
3
- payme
File without changes
File without changes
File without changes