payme-pkg 2.5.3__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 +0 -0
- payme/admin.py +11 -0
- payme/apps.py +10 -0
- payme/cards/__init__.py +1 -0
- payme/cards/subscribe_cards.py +166 -0
- payme/decorators/__init__.py +0 -0
- payme/decorators/decorators.py +34 -0
- payme/errors/__init__.py +0 -0
- payme/errors/exceptions.py +89 -0
- payme/methods/__init__.py +0 -0
- payme/methods/cancel_transaction.py +54 -0
- payme/methods/check_perform_transaction.py +26 -0
- payme/methods/check_transaction.py +43 -0
- payme/methods/create_transaction.py +68 -0
- payme/methods/generate_link.py +74 -0
- payme/methods/get_statement.py +65 -0
- payme/methods/perform_transaction.py +47 -0
- payme/migrations/0001_initial.py +48 -0
- payme/migrations/__init__.py +0 -0
- payme/models.py +61 -0
- payme/receipts/__init__.py +1 -0
- payme/receipts/subscribe_receipts.py +217 -0
- payme/serializers.py +88 -0
- payme/urls.py +8 -0
- payme/utils/__init__.py +0 -0
- payme/utils/get_params.py +24 -0
- payme/utils/logging.py +9 -0
- payme/utils/make_aware_datetime.py +21 -0
- payme/utils/support.py +8 -0
- payme/utils/to_json.py +12 -0
- payme/views.py +163 -0
- payme_pkg-2.5.3.dist-info/LICENSE.txt +20 -0
- payme_pkg-2.5.3.dist-info/METADATA +17 -0
- payme_pkg-2.5.3.dist-info/RECORD +36 -0
- payme_pkg-2.5.3.dist-info/WHEEL +5 -0
- payme_pkg-2.5.3.dist-info/top_level.txt +1 -0
payme/views.py
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import binascii
|
|
3
|
+
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
|
|
6
|
+
from rest_framework.views import APIView
|
|
7
|
+
from rest_framework.response import Response
|
|
8
|
+
from rest_framework.exceptions import ValidationError
|
|
9
|
+
|
|
10
|
+
from payme.utils.logging import logger
|
|
11
|
+
|
|
12
|
+
from payme.errors.exceptions import MethodNotFound
|
|
13
|
+
from payme.errors.exceptions import PermissionDenied
|
|
14
|
+
from payme.errors.exceptions import PerformTransactionDoesNotExist
|
|
15
|
+
|
|
16
|
+
from payme.methods.get_statement import GetStatement
|
|
17
|
+
from payme.methods.check_transaction import CheckTransaction
|
|
18
|
+
from payme.methods.cancel_transaction import CancelTransaction
|
|
19
|
+
from payme.methods.create_transaction import CreateTransaction
|
|
20
|
+
from payme.methods.perform_transaction import PerformTransaction
|
|
21
|
+
from payme.methods.check_perform_transaction import CheckPerformTransaction
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class MerchantAPIView(APIView):
|
|
25
|
+
"""
|
|
26
|
+
MerchantAPIView class provides payme call back functionality.
|
|
27
|
+
"""
|
|
28
|
+
permission_classes = ()
|
|
29
|
+
authentication_classes = ()
|
|
30
|
+
|
|
31
|
+
def post(self, request) -> Response:
|
|
32
|
+
"""
|
|
33
|
+
Payme sends post request to our call back url.
|
|
34
|
+
That methods are includes 5 methods
|
|
35
|
+
- CheckPerformTransaction
|
|
36
|
+
- CreateTransaction
|
|
37
|
+
- PerformTransaction
|
|
38
|
+
- CancelTransaction
|
|
39
|
+
- CheckTransaction
|
|
40
|
+
- GetStatement
|
|
41
|
+
"""
|
|
42
|
+
password = request.META.get('HTTP_AUTHORIZATION')
|
|
43
|
+
if self.authorize(password):
|
|
44
|
+
incoming_data: dict = request.data
|
|
45
|
+
incoming_method: str = incoming_data.get("method")
|
|
46
|
+
|
|
47
|
+
logger.info("Call back data is incoming %s", incoming_data)
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
paycom_method = self.get_paycom_method_by_name(
|
|
51
|
+
incoming_method=incoming_method
|
|
52
|
+
)
|
|
53
|
+
except ValidationError as error:
|
|
54
|
+
logger.error("Validation Error occurred: %s", error)
|
|
55
|
+
raise MethodNotFound() from error
|
|
56
|
+
|
|
57
|
+
except PerformTransactionDoesNotExist as error:
|
|
58
|
+
logger.error("PerformTransactionDoesNotExist Error occurred: %s", error)
|
|
59
|
+
raise PerformTransactionDoesNotExist() from error
|
|
60
|
+
|
|
61
|
+
order_id, action = paycom_method(incoming_data.get("params"))
|
|
62
|
+
|
|
63
|
+
if isinstance(paycom_method, CreateTransaction):
|
|
64
|
+
self.create_transaction(
|
|
65
|
+
order_id=order_id,
|
|
66
|
+
action=action,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if isinstance(paycom_method, PerformTransaction):
|
|
70
|
+
self.perform_transaction(
|
|
71
|
+
order_id=order_id,
|
|
72
|
+
action=action,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if isinstance(paycom_method, CancelTransaction):
|
|
76
|
+
self.cancel_transaction(
|
|
77
|
+
order_id=order_id,
|
|
78
|
+
action=action,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
return Response(data=action)
|
|
82
|
+
|
|
83
|
+
def get_paycom_method_by_name(self, incoming_method: str) -> object:
|
|
84
|
+
"""
|
|
85
|
+
Use this static method to get the paycom method by name.
|
|
86
|
+
:param incoming_method: string -> incoming method name
|
|
87
|
+
"""
|
|
88
|
+
available_methods: dict = {
|
|
89
|
+
"CheckPerformTransaction": CheckPerformTransaction,
|
|
90
|
+
"CreateTransaction": CreateTransaction,
|
|
91
|
+
"PerformTransaction": PerformTransaction,
|
|
92
|
+
"CancelTransaction": CancelTransaction,
|
|
93
|
+
"CheckTransaction": CheckTransaction,
|
|
94
|
+
"GetStatement": GetStatement
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
merchant_method = available_methods[incoming_method]
|
|
99
|
+
except Exception as error:
|
|
100
|
+
error_message = "Unavailable method: %s", incoming_method
|
|
101
|
+
logger.error(error_message)
|
|
102
|
+
raise MethodNotFound(error_message=error_message) from error
|
|
103
|
+
|
|
104
|
+
merchant_method = merchant_method()
|
|
105
|
+
|
|
106
|
+
return merchant_method
|
|
107
|
+
|
|
108
|
+
@staticmethod
|
|
109
|
+
def authorize(password: str) -> None:
|
|
110
|
+
"""
|
|
111
|
+
Authorize the Merchant.
|
|
112
|
+
:param password: string -> Merchant authorization password
|
|
113
|
+
"""
|
|
114
|
+
is_payme: bool = False
|
|
115
|
+
error_message: str = ""
|
|
116
|
+
|
|
117
|
+
if not isinstance(password, str):
|
|
118
|
+
error_message = "Request from an unauthorized source!"
|
|
119
|
+
logger.error(error_message)
|
|
120
|
+
raise PermissionDenied(error_message=error_message)
|
|
121
|
+
|
|
122
|
+
password = password.split()[-1]
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
password = base64.b64decode(password).decode('utf-8')
|
|
126
|
+
except (binascii.Error, UnicodeDecodeError) as error:
|
|
127
|
+
error_message = "Error when authorize request to merchant!"
|
|
128
|
+
logger.error(error_message)
|
|
129
|
+
|
|
130
|
+
raise PermissionDenied(error_message=error_message) from error
|
|
131
|
+
|
|
132
|
+
merchant_key = password.split(':')[-1]
|
|
133
|
+
|
|
134
|
+
if merchant_key == settings.PAYME.get('PAYME_KEY'):
|
|
135
|
+
is_payme = True
|
|
136
|
+
|
|
137
|
+
if merchant_key != settings.PAYME.get('PAYME_KEY'):
|
|
138
|
+
logger.error("Invalid key in request!")
|
|
139
|
+
|
|
140
|
+
if is_payme is False:
|
|
141
|
+
raise PermissionDenied(
|
|
142
|
+
error_message="Unavailable data for unauthorized users!"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
return is_payme
|
|
146
|
+
|
|
147
|
+
def create_transaction(self, order_id, action) -> None:
|
|
148
|
+
"""
|
|
149
|
+
need implement in your view class
|
|
150
|
+
"""
|
|
151
|
+
pass
|
|
152
|
+
|
|
153
|
+
def perform_transaction(self, order_id, action) -> None:
|
|
154
|
+
"""
|
|
155
|
+
need implement in your view class
|
|
156
|
+
"""
|
|
157
|
+
pass
|
|
158
|
+
|
|
159
|
+
def cancel_transaction(self,order_id, action) -> None:
|
|
160
|
+
"""
|
|
161
|
+
need implement in your view class
|
|
162
|
+
"""
|
|
163
|
+
pass
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2021 Giorgos Myrianthous
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: payme-pkg
|
|
3
|
+
Version: 2.5.3
|
|
4
|
+
Summary: UNKNOWN
|
|
5
|
+
Home-page: https://github.com/Muhammadali-Akbarov/payme-pkg
|
|
6
|
+
Author: Muhammadali Akbarov
|
|
7
|
+
Author-email: muhammadali17abc@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: paymeuz paycomuz payme-merchant merchant-api subscribe-api payme-pkg payme-api
|
|
10
|
+
Platform: UNKNOWN
|
|
11
|
+
Requires-Dist: requests (==2.*)
|
|
12
|
+
Requires-Dist: dataclasses (==0.*)
|
|
13
|
+
Requires-Dist: djangorestframework (==3.14.0)
|
|
14
|
+
|
|
15
|
+
UNKNOWN
|
|
16
|
+
|
|
17
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
payme/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
payme/admin.py,sha256=hpxXEVUNfXSBW3G9NLEaABW_JSycM4e4xEG43v-17VI,287
|
|
3
|
+
payme/apps.py,sha256=7b92Ava_YcKd1XYRZg9iopgAgh_85D23pqDYFaHfwvs,264
|
|
4
|
+
payme/models.py,sha256=WTJATic7HEjnkVDQkGxj76i51jgpQV3xkMuglXpGvm0,2208
|
|
5
|
+
payme/serializers.py,sha256=-6twLxZ3WlQXVemN0Ruy-YwtKRwh044tZL4THoLSXt0,2795
|
|
6
|
+
payme/urls.py,sha256=Yn4w_CQN9q2bi0MbyKMQfvQPMO0ZSSCCp-WgymZYVv4,139
|
|
7
|
+
payme/views.py,sha256=w-ZwE0eWc0rUYyCE6OlWWiM8_sXa8YvMqy-DwWIYhtc,5423
|
|
8
|
+
payme/cards/__init__.py,sha256=_kXz2r5vOjEXYeMsfx3iu1XUmJXnsLt2Ylj9zAqAsWc,29
|
|
9
|
+
payme/cards/subscribe_cards.py,sha256=_Yr1OnwrZJ1dlSGsjwVRoXdrrgqb2ZW88CyDW8LYWa4,5071
|
|
10
|
+
payme/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
payme/decorators/decorators.py,sha256=7Hwsu2OuM5ajG8j4jRnoiqQXXG0Cw2wdQq2BAZMRNCE,908
|
|
12
|
+
payme/errors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
payme/errors/exceptions.py,sha256=8YhIPz6yXN35a0c823lpShPCw891JKpLj4aFMLrhLpQ,2241
|
|
14
|
+
payme/methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
payme/methods/cancel_transaction.py,sha256=BFlTXYXFxnGgvnBGD-tRgN1kW1DfTtkAeYwQvpx9mG4,1870
|
|
16
|
+
payme/methods/check_perform_transaction.py,sha256=91MG3HYj57_ouf_606qcyEDTdptfUrHADYYCepS0yak,714
|
|
17
|
+
payme/methods/check_transaction.py,sha256=rE6jhDJhEO-1ndUsaCuuZwu6yC59zZNPAjclM-yovfI,1429
|
|
18
|
+
payme/methods/create_transaction.py,sha256=UMGzzuCn3ZuqW3oWr53cP5NqWLL_6u5IL4Qussuc0s4,2312
|
|
19
|
+
payme/methods/generate_link.py,sha256=Br4LJVEurtYMxmCLRl6_zMo02FFlwxac105AvJW6HAY,1964
|
|
20
|
+
payme/methods/get_statement.py,sha256=dApK2PXQ_QhsIl_IJcibs7bOEJWYL6-b8ylRokbfyqE,2129
|
|
21
|
+
payme/methods/perform_transaction.py,sha256=gwruqKrMU_U_UjG6tUJG_C4Y6DowzNmRy2pL5P0cfyY,1560
|
|
22
|
+
payme/migrations/0001_initial.py,sha256=3umrPcN8JQ0Bw_TsCtdjhRqzPNum8HyRv-FhlmBrEJs,2021
|
|
23
|
+
payme/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
+
payme/receipts/__init__.py,sha256=u36DT2QLC96om-biU4pFK5lrskCKOD2z3vOofh5IRO0,32
|
|
25
|
+
payme/receipts/subscribe_receipts.py,sha256=tI15ulNvfPhB9dIWiBXQ8qWl7DyiAVJy7qlApydSvtk,6616
|
|
26
|
+
payme/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
payme/utils/get_params.py,sha256=93dJ-sc38BnYFPJssYfJ2W0yJjv2SGM1hMzVeIxRIUM,719
|
|
28
|
+
payme/utils/logging.py,sha256=jp4YbMxxLPqtbpKDNvi-tAyvp3cgg_PjH-6X6ePUc2E,186
|
|
29
|
+
payme/utils/make_aware_datetime.py,sha256=S0qmf7SgFvSS3tV7Zv4snTwMemvkf07EbOM-10e6xwE,546
|
|
30
|
+
payme/utils/support.py,sha256=UE6bgkvVDbhoMolYPaTnadb_-i-Hc_AIDQTZ-vddA3A,209
|
|
31
|
+
payme/utils/to_json.py,sha256=WYt2z-bkX8VyrF-QZkHCj8TKAOKYntTK4PlESoJPlrw,236
|
|
32
|
+
payme_pkg-2.5.3.dist-info/LICENSE.txt,sha256=s2LHnt00v2iSinmz-OptOb9OF8q89_lo606KrgOFLOE,1062
|
|
33
|
+
payme_pkg-2.5.3.dist-info/METADATA,sha256=gGukwbDu0DdjrGMs8rh5AI8HL1XpMWrNckCsy-M41jI,443
|
|
34
|
+
payme_pkg-2.5.3.dist-info/WHEEL,sha256=00yskusixUoUt5ob_CiUp6LsnN5lqzTJpoqOFg_FVIc,92
|
|
35
|
+
payme_pkg-2.5.3.dist-info/top_level.txt,sha256=8mN-hGAa38pWbhrKHFs9CZywPCdidhMuwPKwuFJa0qw,6
|
|
36
|
+
payme_pkg-2.5.3.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
payme
|