payme-pkg 3.0.6__tar.gz → 3.0.8__tar.gz
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_pkg-3.0.8/PKG-INFO +143 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/README.md +7 -3
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/classes/cards.py +0 -9
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/classes/client.py +1 -3
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/classes/initializer.py +0 -20
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/classes/receipts.py +0 -9
- payme_pkg-3.0.8/payme/const.py +12 -0
- payme_pkg-3.0.8/payme/util.py +26 -0
- payme_pkg-3.0.8/payme_pkg.egg-info/PKG-INFO +143 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/setup.py +7 -1
- payme_pkg-3.0.6/PKG-INFO +0 -12
- payme_pkg-3.0.6/payme/const.py +0 -35
- payme_pkg-3.0.6/payme/util.py +0 -53
- payme_pkg-3.0.6/payme_pkg.egg-info/PKG-INFO +0 -12
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/LICENSE.txt +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/__init__.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/admin.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/apps.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/classes/__init__.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/classes/http.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/exceptions/__init__.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/exceptions/general.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/exceptions/webhook.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/migrations/__init__.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/models.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/types/__init__.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/types/request/__init__.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/types/response/__init__.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/types/response/cards.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/types/response/receipts.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/types/response/webhook.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/urls.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme/views.py +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme_pkg.egg-info/SOURCES.txt +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme_pkg.egg-info/dependency_links.txt +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme_pkg.egg-info/requires.txt +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/payme_pkg.egg-info/top_level.txt +0 -0
- {payme_pkg-3.0.6 → payme_pkg-3.0.8}/setup.cfg +0 -0
payme_pkg-3.0.8/PKG-INFO
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: payme-pkg
|
|
3
|
+
Version: 3.0.8
|
|
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: dataclasses==0.*; python_version < "3.7"
|
|
13
|
+
Requires-Dist: djangorestframework==3.*
|
|
14
|
+
|
|
15
|
+
<h1 align="center">Payme PKG</h1>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="https://docs.pay-tech.uz"><img src="https://img.shields.io/static/v1?message=Documented%20on%20GitBook&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1"></a>
|
|
20
|
+
<a href="https://github.com/PayTechUz/payme-pkg"><img src="https://img.shields.io/badge/Open_Source-❤️-FDA599?"/></a>
|
|
21
|
+
<a href="t.me/+DK7n7lKx8GY5ZDZi"><img src="https://img.shields.io/badge/Community-Join%20Us-blueviolet"/></a>
|
|
22
|
+
<a href="https://github.com/PayTechUz/payme-pkg/issues"><img src="https://img.shields.io/github/issues/gitbookIO/gitbook"/></a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center">Welcome to payme-pkg, the open source payme sdk for python.</p>
|
|
26
|
+
|
|
27
|
+
<p align="center">You can use for test and production mode. Join our community and ask everything you need.
|
|
28
|
+
</p>
|
|
29
|
+
<a href="https://docs.pay-tech.uz">
|
|
30
|
+
<p align="center">Visit to full documentation for Merchant and Subcribe Api</p>
|
|
31
|
+
</a>
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img style="width: 60%;" src="https://i.postimg.cc/WbD32bHC/payme-pkg-demo-m4a.gif">
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
pip install payme-pkg
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Installation to Django
|
|
43
|
+
|
|
44
|
+
Add `'payme'` in to your settings.py
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
INSTALLED_APPS = [
|
|
48
|
+
...
|
|
49
|
+
'payme',
|
|
50
|
+
...
|
|
51
|
+
]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Add `'payme'` credentials inside to settings.py
|
|
55
|
+
|
|
56
|
+
One time payment (Однаразовый платеж) configuration settings.py
|
|
57
|
+
|
|
58
|
+
Example project: https://github.com/PayTechUz/shop-backend
|
|
59
|
+
```python
|
|
60
|
+
PAYME_ID = "your-payme-id"
|
|
61
|
+
PAYME_KEY = "your-payme-key"
|
|
62
|
+
PAYME_ACCOUNT_FIELD = "order_id"
|
|
63
|
+
PAYME_AMOUNT_FIELD = "total_amount"
|
|
64
|
+
PAYME_ACCOUNT_MODEL = "orders.models.Orders"
|
|
65
|
+
PAYME_ONE_TIME_PAYMENT = True
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Multi payment (Накопительный) configuration settings.py
|
|
69
|
+
|
|
70
|
+
Example project: Coming soon
|
|
71
|
+
```python
|
|
72
|
+
PAYME_ID = "your-payme-id"
|
|
73
|
+
PAYME_KEY = "your-payme-key"
|
|
74
|
+
PAYME_ACCOUNT_FIELD = "id"
|
|
75
|
+
PAYME_ACCOUNT_MODEL = "clients.models.Client"
|
|
76
|
+
PAYME_ONE_TIME_PAYMENT = False
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Create a new View that about handling call backs
|
|
80
|
+
```python
|
|
81
|
+
from payme.views import PaymeWebHookAPIView
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class PaymeCallBackAPIView(PaymeWebHookAPIView):
|
|
85
|
+
def handle_created_payment(self, params, result, *args, **kwargs):
|
|
86
|
+
"""
|
|
87
|
+
Handle the successful payment. You can override this method
|
|
88
|
+
"""
|
|
89
|
+
print(f"Transaction created for this params: {params} and cr_result: {result}")
|
|
90
|
+
|
|
91
|
+
def handle_successfully_payment(self, params, result, *args, **kwargs):
|
|
92
|
+
"""
|
|
93
|
+
Handle the successful payment. You can override this method
|
|
94
|
+
"""
|
|
95
|
+
print(f"Transaction successfully performed for this params: {params} and performed_result: {result}")
|
|
96
|
+
|
|
97
|
+
def handle_cancelled_payment(self, params, result, *args, **kwargs):
|
|
98
|
+
"""
|
|
99
|
+
Handle the cancelled payment. You can override this method
|
|
100
|
+
"""
|
|
101
|
+
print(f"Transaction cancelled for this params: {params} and cancelled_result: {result}")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Add a `payme` path to core of urlpatterns:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from django.urls import path
|
|
108
|
+
from django.urls import include
|
|
109
|
+
|
|
110
|
+
from your_app.views import PaymeCallBackAPIView
|
|
111
|
+
|
|
112
|
+
urlpatterns = [
|
|
113
|
+
...
|
|
114
|
+
path("payment/update/", PaymeCallBackAPIView.as_view()),
|
|
115
|
+
...
|
|
116
|
+
]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Run migrations
|
|
120
|
+
```shell
|
|
121
|
+
python3 manage.py makemigrations && python manage.py migrate
|
|
122
|
+
```
|
|
123
|
+
🎉 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.
|
|
124
|
+
|
|
125
|
+
## Generate Pay Link
|
|
126
|
+
|
|
127
|
+
Example to generate link:
|
|
128
|
+
|
|
129
|
+
- Input
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from payme import Payme
|
|
133
|
+
|
|
134
|
+
payme = Payme(payme_id="your-payme-id")
|
|
135
|
+
pay_link = payme.initializer.generate_pay_link(id=123456, amount=5000, return_url="https://example.com")
|
|
136
|
+
print(pay_link)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- Output
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
https://checkout.paycom.uz/bT15b3VyLXBheW1lLWlkO2FjLmlkPTEyMzQ1NjthPTUwMDAwMDtjPWh0dHBzOi8vZXhhbXBsZS5jb20=
|
|
143
|
+
```
|
|
@@ -39,17 +39,21 @@ INSTALLED_APPS = [
|
|
|
39
39
|
|
|
40
40
|
Add `'payme'` credentials inside to settings.py
|
|
41
41
|
|
|
42
|
-
One time payment configuration settings.py
|
|
42
|
+
One time payment (Однаразовый платеж) configuration settings.py
|
|
43
|
+
|
|
44
|
+
Example project: https://github.com/PayTechUz/shop-backend
|
|
43
45
|
```python
|
|
44
46
|
PAYME_ID = "your-payme-id"
|
|
45
47
|
PAYME_KEY = "your-payme-key"
|
|
46
|
-
PAYME_ACCOUNT_FIELD = "
|
|
48
|
+
PAYME_ACCOUNT_FIELD = "order_id"
|
|
47
49
|
PAYME_AMOUNT_FIELD = "total_amount"
|
|
48
50
|
PAYME_ACCOUNT_MODEL = "orders.models.Orders"
|
|
49
51
|
PAYME_ONE_TIME_PAYMENT = True
|
|
50
52
|
```
|
|
51
53
|
|
|
52
|
-
Multi payment configuration settings.py
|
|
54
|
+
Multi payment (Накопительный) configuration settings.py
|
|
55
|
+
|
|
56
|
+
Example project: Coming soon
|
|
53
57
|
```python
|
|
54
58
|
PAYME_ID = "your-payme-id"
|
|
55
59
|
PAYME_KEY = "your-payme-key"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
|
|
3
|
-
from payme.util import input_type_checker
|
|
4
3
|
from payme.classes.http import HttpClient
|
|
5
4
|
from payme.types.response import cards as response
|
|
6
5
|
|
|
@@ -20,8 +19,6 @@ class Cards:
|
|
|
20
19
|
services. It allows you to create new cards and retrieve verification
|
|
21
20
|
codes for existing cards.
|
|
22
21
|
"""
|
|
23
|
-
|
|
24
|
-
@input_type_checker
|
|
25
22
|
def __init__(self, url: str, payme_id: str) -> "Cards":
|
|
26
23
|
"""
|
|
27
24
|
Initialize the Cards client.
|
|
@@ -35,7 +32,6 @@ class Cards:
|
|
|
35
32
|
}
|
|
36
33
|
self.http = HttpClient(url, headers)
|
|
37
34
|
|
|
38
|
-
@input_type_checker
|
|
39
35
|
def create(self, number: str, expire: str, save: bool = False,
|
|
40
36
|
timeout: int = 10) -> response.CardsCreateResponse:
|
|
41
37
|
"""
|
|
@@ -53,7 +49,6 @@ class Cards:
|
|
|
53
49
|
params = {"card": {"number": number, "expire": expire}, "save": save}
|
|
54
50
|
return self._post_request(method, params, timeout)
|
|
55
51
|
|
|
56
|
-
@input_type_checker
|
|
57
52
|
def get_verify_code(self, token: str, timeout: int = 10) -> \
|
|
58
53
|
response.GetVerifyResponse:
|
|
59
54
|
"""
|
|
@@ -68,7 +63,6 @@ class Cards:
|
|
|
68
63
|
params = {"token": token}
|
|
69
64
|
return self._post_request(method, params, timeout)
|
|
70
65
|
|
|
71
|
-
@input_type_checker
|
|
72
66
|
def verify(self, token: str, code: str, timeout: int = 10) -> \
|
|
73
67
|
response.VerifyResponse:
|
|
74
68
|
"""
|
|
@@ -84,7 +78,6 @@ class Cards:
|
|
|
84
78
|
params = {"token": token, "code": code}
|
|
85
79
|
return self._post_request(method, params, timeout)
|
|
86
80
|
|
|
87
|
-
@input_type_checker
|
|
88
81
|
def remove(self, token: str, timeout: int = 10) -> response.RemoveResponse:
|
|
89
82
|
"""
|
|
90
83
|
Remove a card from the Paycom system.
|
|
@@ -98,7 +91,6 @@ class Cards:
|
|
|
98
91
|
params = {"token": token}
|
|
99
92
|
return self._post_request(method, params, timeout)
|
|
100
93
|
|
|
101
|
-
@input_type_checker
|
|
102
94
|
def check(self, token: str, timeout: int = 10) -> response.CheckResponse:
|
|
103
95
|
"""
|
|
104
96
|
Check the status of a card.
|
|
@@ -112,7 +104,6 @@ class Cards:
|
|
|
112
104
|
params = {"token": token}
|
|
113
105
|
return self._post_request(method, params, timeout)
|
|
114
106
|
|
|
115
|
-
@input_type_checker
|
|
116
107
|
def _post_request(self, method: str, params: dict,
|
|
117
108
|
timeout: int = 10) -> response.Common:
|
|
118
109
|
"""
|
|
@@ -3,7 +3,6 @@ from typing import Union
|
|
|
3
3
|
|
|
4
4
|
from payme.const import Networks
|
|
5
5
|
from payme.classes.cards import Cards
|
|
6
|
-
from payme.util import input_type_checker
|
|
7
6
|
from payme.classes.receipts import Receipts
|
|
8
7
|
from payme.classes.initializer import Initializer
|
|
9
8
|
|
|
@@ -12,7 +11,6 @@ class Payme:
|
|
|
12
11
|
"""
|
|
13
12
|
The payme class provides a simple interface
|
|
14
13
|
"""
|
|
15
|
-
@input_type_checker
|
|
16
14
|
def __init__(
|
|
17
15
|
self,
|
|
18
16
|
payme_id: str,
|
|
@@ -24,7 +22,7 @@ class Payme:
|
|
|
24
22
|
url = Networks.PROD_NET
|
|
25
23
|
|
|
26
24
|
if is_test_mode is True:
|
|
27
|
-
url = Networks.TEST_NET
|
|
25
|
+
url = Networks.TEST_NET.value
|
|
28
26
|
|
|
29
27
|
self.cards = Cards(url=url, payme_id=payme_id)
|
|
30
28
|
self.initializer = Initializer(payme_id=payme_id)
|
|
@@ -2,8 +2,6 @@ import base64
|
|
|
2
2
|
|
|
3
3
|
from django.conf import settings
|
|
4
4
|
|
|
5
|
-
from payme.util import input_type_checker
|
|
6
|
-
|
|
7
5
|
|
|
8
6
|
class Initializer:
|
|
9
7
|
"""
|
|
@@ -15,7 +13,6 @@ class Initializer:
|
|
|
15
13
|
The Payme ID associated with your account
|
|
16
14
|
"""
|
|
17
15
|
|
|
18
|
-
@input_type_checker
|
|
19
16
|
def __init__(self, payme_id: str = None):
|
|
20
17
|
self.payme_id = payme_id
|
|
21
18
|
|
|
@@ -58,20 +55,3 @@ class Initializer:
|
|
|
58
55
|
)
|
|
59
56
|
params = base64.b64encode(params.encode("utf-8")).decode("utf-8")
|
|
60
57
|
return f"https://checkout.paycom.uz/{params}"
|
|
61
|
-
|
|
62
|
-
def test(self):
|
|
63
|
-
"""
|
|
64
|
-
Test method for the Initializer class.
|
|
65
|
-
|
|
66
|
-
This method generates a payment link for a sample order and checks
|
|
67
|
-
if the result is a valid string. If successful, it prints a
|
|
68
|
-
confirmation message.
|
|
69
|
-
"""
|
|
70
|
-
result = self.generate_pay_link(
|
|
71
|
-
id=12345,
|
|
72
|
-
amount=7000,
|
|
73
|
-
return_url="https://example.com"
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
assert isinstance(result, str), "Failed to generate payment link"
|
|
77
|
-
print("Success: Payment link generated successfully.")
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from typing import Union, Optional
|
|
2
2
|
|
|
3
3
|
from payme.classes.cards import Cards
|
|
4
|
-
from payme.util import input_type_checker
|
|
5
4
|
from payme.classes.http import HttpClient
|
|
6
5
|
from payme.types.response import receipts as response
|
|
7
6
|
|
|
@@ -37,7 +36,6 @@ class Receipts:
|
|
|
37
36
|
}
|
|
38
37
|
self.http = HttpClient(url, headers)
|
|
39
38
|
|
|
40
|
-
@input_type_checker
|
|
41
39
|
def create(
|
|
42
40
|
self,
|
|
43
41
|
account: dict,
|
|
@@ -64,7 +62,6 @@ class Receipts:
|
|
|
64
62
|
}
|
|
65
63
|
return self._post_request(method, params, timeout)
|
|
66
64
|
|
|
67
|
-
@input_type_checker
|
|
68
65
|
def pay(
|
|
69
66
|
self, receipts_id: str, token: str, timeout: int = 10
|
|
70
67
|
) -> response.PayResponse:
|
|
@@ -83,7 +80,6 @@ class Receipts:
|
|
|
83
80
|
}
|
|
84
81
|
return self._post_request(method, params, timeout)
|
|
85
82
|
|
|
86
|
-
@input_type_checker
|
|
87
83
|
def send(
|
|
88
84
|
self, receipts_id: str, phone: str, timeout: int = 10
|
|
89
85
|
) -> response.SendResponse:
|
|
@@ -101,7 +97,6 @@ class Receipts:
|
|
|
101
97
|
}
|
|
102
98
|
return self._post_request(method, params, timeout)
|
|
103
99
|
|
|
104
|
-
@input_type_checker
|
|
105
100
|
def cancel(
|
|
106
101
|
self, receipts_id: str, timeout: int = 10
|
|
107
102
|
) -> response.CancelResponse:
|
|
@@ -117,7 +112,6 @@ class Receipts:
|
|
|
117
112
|
}
|
|
118
113
|
return self._post_request(method, params, timeout)
|
|
119
114
|
|
|
120
|
-
@input_type_checker
|
|
121
115
|
def check(
|
|
122
116
|
self, receipts_id: str, timeout: int = 10
|
|
123
117
|
) -> response.CheckResponse:
|
|
@@ -133,7 +127,6 @@ class Receipts:
|
|
|
133
127
|
}
|
|
134
128
|
return self._post_request(method, params, timeout)
|
|
135
129
|
|
|
136
|
-
@input_type_checker
|
|
137
130
|
def get(
|
|
138
131
|
self, receipts_id: str, timeout: int = 10
|
|
139
132
|
) -> response.GetResponse:
|
|
@@ -149,7 +142,6 @@ class Receipts:
|
|
|
149
142
|
}
|
|
150
143
|
return self._post_request(method, params, timeout)
|
|
151
144
|
|
|
152
|
-
@input_type_checker
|
|
153
145
|
def get_all(
|
|
154
146
|
self, count: int, from_: int, to: int, offset: int, timeout: int = 10
|
|
155
147
|
) -> response.GetAllResponse:
|
|
@@ -171,7 +163,6 @@ class Receipts:
|
|
|
171
163
|
}
|
|
172
164
|
return self._post_request(method, params, timeout)
|
|
173
165
|
|
|
174
|
-
@input_type_checker
|
|
175
166
|
def _post_request(
|
|
176
167
|
self, method: str, params: dict, timeout: int = 10
|
|
177
168
|
) -> response.Common:
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def time_to_payme(datatime) -> int:
|
|
5
|
+
"""
|
|
6
|
+
Convert datetime object to Payme's datetime format.
|
|
7
|
+
|
|
8
|
+
Payme's datetime format is in the format: YYYY-MM-DD HH:MM:SS.ssssss
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
datatime (datetime): The datetime object to convert.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
str: The datetime object in Payme's datetime format.
|
|
15
|
+
"""
|
|
16
|
+
if not datatime:
|
|
17
|
+
return 0
|
|
18
|
+
|
|
19
|
+
return int(datatime.timestamp() * 1000)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def time_to_service(milliseconds: int) -> datetime:
|
|
23
|
+
"""
|
|
24
|
+
Converts milliseconds since the epoch to a datetime object.
|
|
25
|
+
"""
|
|
26
|
+
return datetime.fromtimestamp(milliseconds / 1000)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: payme-pkg
|
|
3
|
+
Version: 3.0.8
|
|
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: dataclasses==0.*; python_version < "3.7"
|
|
13
|
+
Requires-Dist: djangorestframework==3.*
|
|
14
|
+
|
|
15
|
+
<h1 align="center">Payme PKG</h1>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="https://docs.pay-tech.uz"><img src="https://img.shields.io/static/v1?message=Documented%20on%20GitBook&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1"></a>
|
|
20
|
+
<a href="https://github.com/PayTechUz/payme-pkg"><img src="https://img.shields.io/badge/Open_Source-❤️-FDA599?"/></a>
|
|
21
|
+
<a href="t.me/+DK7n7lKx8GY5ZDZi"><img src="https://img.shields.io/badge/Community-Join%20Us-blueviolet"/></a>
|
|
22
|
+
<a href="https://github.com/PayTechUz/payme-pkg/issues"><img src="https://img.shields.io/github/issues/gitbookIO/gitbook"/></a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center">Welcome to payme-pkg, the open source payme sdk for python.</p>
|
|
26
|
+
|
|
27
|
+
<p align="center">You can use for test and production mode. Join our community and ask everything you need.
|
|
28
|
+
</p>
|
|
29
|
+
<a href="https://docs.pay-tech.uz">
|
|
30
|
+
<p align="center">Visit to full documentation for Merchant and Subcribe Api</p>
|
|
31
|
+
</a>
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img style="width: 60%;" src="https://i.postimg.cc/WbD32bHC/payme-pkg-demo-m4a.gif">
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
pip install payme-pkg
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Installation to Django
|
|
43
|
+
|
|
44
|
+
Add `'payme'` in to your settings.py
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
INSTALLED_APPS = [
|
|
48
|
+
...
|
|
49
|
+
'payme',
|
|
50
|
+
...
|
|
51
|
+
]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Add `'payme'` credentials inside to settings.py
|
|
55
|
+
|
|
56
|
+
One time payment (Однаразовый платеж) configuration settings.py
|
|
57
|
+
|
|
58
|
+
Example project: https://github.com/PayTechUz/shop-backend
|
|
59
|
+
```python
|
|
60
|
+
PAYME_ID = "your-payme-id"
|
|
61
|
+
PAYME_KEY = "your-payme-key"
|
|
62
|
+
PAYME_ACCOUNT_FIELD = "order_id"
|
|
63
|
+
PAYME_AMOUNT_FIELD = "total_amount"
|
|
64
|
+
PAYME_ACCOUNT_MODEL = "orders.models.Orders"
|
|
65
|
+
PAYME_ONE_TIME_PAYMENT = True
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Multi payment (Накопительный) configuration settings.py
|
|
69
|
+
|
|
70
|
+
Example project: Coming soon
|
|
71
|
+
```python
|
|
72
|
+
PAYME_ID = "your-payme-id"
|
|
73
|
+
PAYME_KEY = "your-payme-key"
|
|
74
|
+
PAYME_ACCOUNT_FIELD = "id"
|
|
75
|
+
PAYME_ACCOUNT_MODEL = "clients.models.Client"
|
|
76
|
+
PAYME_ONE_TIME_PAYMENT = False
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Create a new View that about handling call backs
|
|
80
|
+
```python
|
|
81
|
+
from payme.views import PaymeWebHookAPIView
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class PaymeCallBackAPIView(PaymeWebHookAPIView):
|
|
85
|
+
def handle_created_payment(self, params, result, *args, **kwargs):
|
|
86
|
+
"""
|
|
87
|
+
Handle the successful payment. You can override this method
|
|
88
|
+
"""
|
|
89
|
+
print(f"Transaction created for this params: {params} and cr_result: {result}")
|
|
90
|
+
|
|
91
|
+
def handle_successfully_payment(self, params, result, *args, **kwargs):
|
|
92
|
+
"""
|
|
93
|
+
Handle the successful payment. You can override this method
|
|
94
|
+
"""
|
|
95
|
+
print(f"Transaction successfully performed for this params: {params} and performed_result: {result}")
|
|
96
|
+
|
|
97
|
+
def handle_cancelled_payment(self, params, result, *args, **kwargs):
|
|
98
|
+
"""
|
|
99
|
+
Handle the cancelled payment. You can override this method
|
|
100
|
+
"""
|
|
101
|
+
print(f"Transaction cancelled for this params: {params} and cancelled_result: {result}")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Add a `payme` path to core of urlpatterns:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from django.urls import path
|
|
108
|
+
from django.urls import include
|
|
109
|
+
|
|
110
|
+
from your_app.views import PaymeCallBackAPIView
|
|
111
|
+
|
|
112
|
+
urlpatterns = [
|
|
113
|
+
...
|
|
114
|
+
path("payment/update/", PaymeCallBackAPIView.as_view()),
|
|
115
|
+
...
|
|
116
|
+
]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Run migrations
|
|
120
|
+
```shell
|
|
121
|
+
python3 manage.py makemigrations && python manage.py migrate
|
|
122
|
+
```
|
|
123
|
+
🎉 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.
|
|
124
|
+
|
|
125
|
+
## Generate Pay Link
|
|
126
|
+
|
|
127
|
+
Example to generate link:
|
|
128
|
+
|
|
129
|
+
- Input
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from payme import Payme
|
|
133
|
+
|
|
134
|
+
payme = Payme(payme_id="your-payme-id")
|
|
135
|
+
pay_link = payme.initializer.generate_pay_link(id=123456, amount=5000, return_url="https://example.com")
|
|
136
|
+
print(pay_link)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- Output
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
https://checkout.paycom.uz/bT15b3VyLXBheW1lLWlkO2FjLmlkPTEyMzQ1NjthPTUwMDAwMDtjPWh0dHBzOi8vZXhhbXBsZS5jb20=
|
|
143
|
+
```
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import pathlib
|
|
1
2
|
from setuptools import setup, find_packages
|
|
2
3
|
|
|
4
|
+
here = pathlib.Path(__file__).parent.resolve()
|
|
5
|
+
|
|
6
|
+
long_description = (here / "README.md").read_text(encoding="utf-8")
|
|
3
7
|
|
|
4
8
|
setup(
|
|
5
9
|
name='payme-pkg',
|
|
6
|
-
version='3.0.
|
|
10
|
+
version='3.0.8',
|
|
7
11
|
license='MIT',
|
|
8
12
|
author="Muhammadali Akbarov",
|
|
9
13
|
author_email='muhammadali17abc@gmail.com',
|
|
@@ -15,4 +19,6 @@ setup(
|
|
|
15
19
|
"dataclasses==0.*;python_version<'3.7'", # will only install on py3.6
|
|
16
20
|
'djangorestframework==3.*'
|
|
17
21
|
],
|
|
22
|
+
long_description=long_description,
|
|
23
|
+
long_description_content_type="text/markdown",
|
|
18
24
|
)
|
payme_pkg-3.0.6/PKG-INFO
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: payme-pkg
|
|
3
|
-
Version: 3.0.6
|
|
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: dataclasses==0.*; python_version < "3.7"
|
|
12
|
-
Requires-Dist: djangorestframework==3.*
|
payme_pkg-3.0.6/payme/const.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Payme enumerations
|
|
3
|
-
"""
|
|
4
|
-
from enum import Enum
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Methods(str, Enum):
|
|
8
|
-
"""
|
|
9
|
-
The enumeration of create transaction methods.
|
|
10
|
-
|
|
11
|
-
Available Methods:
|
|
12
|
-
- GET_STATEMENT: Fetches transaction statement.
|
|
13
|
-
- CHECK_TRANSACTION: Checks a transaction.
|
|
14
|
-
- CREATE_TRANSACTION: Creates a new transaction.
|
|
15
|
-
- CANCEL_TRANSACTION: Cancels an existing transaction.
|
|
16
|
-
- PERFORM_TRANSACTION: Performs a transaction.
|
|
17
|
-
- CHECK_PERFORM_TRANSACTION: Checks if the transaction can be performed.
|
|
18
|
-
"""
|
|
19
|
-
GET_STATEMENT = "GetStatement"
|
|
20
|
-
CHECK_TRANSACTION = "CheckTransaction"
|
|
21
|
-
CREATE_TRANSACTION = "CreateTransaction"
|
|
22
|
-
CANCEL_TRANSACTION = "CancelTransaction"
|
|
23
|
-
PERFORM_TRANSACTION = "PerformTransaction"
|
|
24
|
-
CHECK_PERFORM_TRANSACTION = "CheckPerformTransaction"
|
|
25
|
-
|
|
26
|
-
def __str__(self):
|
|
27
|
-
return str(self.value)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class Networks(str, Enum):
|
|
31
|
-
"""
|
|
32
|
-
Payme networks
|
|
33
|
-
"""
|
|
34
|
-
PROD_NET = "https://checkout.paycom.uz/api"
|
|
35
|
-
TEST_NET = "https://checkout.test.paycom.uz/api"
|
payme_pkg-3.0.6/payme/util.py
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from functools import wraps
|
|
2
|
-
from datetime import datetime
|
|
3
|
-
from typing import get_type_hints
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def time_to_payme(datatime) -> int:
|
|
7
|
-
"""
|
|
8
|
-
Convert datetime object to Payme's datetime format.
|
|
9
|
-
|
|
10
|
-
Payme's datetime format is in the format: YYYY-MM-DD HH:MM:SS.ssssss
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
datatime (datetime): The datetime object to convert.
|
|
14
|
-
|
|
15
|
-
Returns:
|
|
16
|
-
str: The datetime object in Payme's datetime format.
|
|
17
|
-
"""
|
|
18
|
-
if not datatime:
|
|
19
|
-
return 0
|
|
20
|
-
|
|
21
|
-
return int(datatime.timestamp() * 1000)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def time_to_service(milliseconds: int) -> datetime:
|
|
25
|
-
"""
|
|
26
|
-
Converts milliseconds since the epoch to a datetime object.
|
|
27
|
-
"""
|
|
28
|
-
return datetime.fromtimestamp(milliseconds / 1000)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def input_type_checker(func):
|
|
32
|
-
"""
|
|
33
|
-
input type checker decorator helps to
|
|
34
|
-
validate the input types of the function before executing it.
|
|
35
|
-
"""
|
|
36
|
-
@wraps(func)
|
|
37
|
-
def wrapper(*args, **kwargs):
|
|
38
|
-
"""
|
|
39
|
-
Get the type hints of the function
|
|
40
|
-
"""
|
|
41
|
-
hints = get_type_hints(func)
|
|
42
|
-
|
|
43
|
-
all_args = kwargs.copy()
|
|
44
|
-
all_args.update(zip(func.__code__.co_varnames, args))
|
|
45
|
-
|
|
46
|
-
for arg_name, arg_type in hints.items():
|
|
47
|
-
if arg_name in all_args and not isinstance(all_args[arg_name], arg_type): # noqa
|
|
48
|
-
raise TypeError(
|
|
49
|
-
f"Argument '{arg_name}' in {func.__name__} must be of type {arg_type.__name__}, " # noqa
|
|
50
|
-
f"but got {type(all_args[arg_name]).__name__}."
|
|
51
|
-
)
|
|
52
|
-
return func(*args, **kwargs)
|
|
53
|
-
return wrapper
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: payme-pkg
|
|
3
|
-
Version: 3.0.6
|
|
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: dataclasses==0.*; python_version < "3.7"
|
|
12
|
-
Requires-Dist: djangorestframework==3.*
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|