payme-pkg 3.3.0__cp312-cp312-macosx_10_13_universal2.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.
- payme/__init__.py +1 -0
- payme/admin.cpython-312-darwin.so +0 -0
- payme/apps.cpython-312-darwin.so +0 -0
- payme/classes/__init__.py +0 -0
- payme/classes/cards.cpython-312-darwin.so +0 -0
- payme/classes/client.py +313 -0
- payme/classes/http.cpython-312-darwin.so +0 -0
- payme/classes/initializer.cpython-312-darwin.so +0 -0
- payme/classes/receipts.cpython-312-darwin.so +0 -0
- payme/const.cpython-312-darwin.so +0 -0
- payme/exceptions/__init__.py +5 -0
- payme/exceptions/general.cpython-312-darwin.so +0 -0
- payme/exceptions/webhook.cpython-312-darwin.so +0 -0
- payme/licensing.cpython-312-darwin.so +0 -0
- payme/migrations/0001_initial.py +60 -0
- payme/migrations/0002_paymetransactions_fiscal_data.py +18 -0
- payme/migrations/0003_alter_paymetransactions_fiscal_data.py +18 -0
- payme/migrations/0004_alter_paymetransactions_account_id.py +18 -0
- payme/migrations/0005_alter_paymetransactions_amount.py +19 -0
- payme/migrations/__init__.py +0 -0
- payme/models.cpython-312-darwin.so +0 -0
- payme/types/__init__.py +0 -0
- payme/types/request/__init__.py +0 -0
- payme/types/response/__init__.py +4 -0
- payme/types/response/cards.py +122 -0
- payme/types/response/receipts.py +242 -0
- payme/types/response/webhook.py +154 -0
- payme/urls.cpython-312-darwin.so +0 -0
- payme/util.cpython-312-darwin.so +0 -0
- payme/views/__init__.py +5 -0
- payme/views/base.cpython-312-darwin.so +0 -0
- payme/views/payme.py +31 -0
- payme_pkg-3.3.0.dist-info/METADATA +444 -0
- payme_pkg-3.3.0.dist-info/RECORD +37 -0
- payme_pkg-3.3.0.dist-info/WHEEL +5 -0
- payme_pkg-3.3.0.dist-info/licenses/LICENSE.txt +24 -0
- payme_pkg-3.3.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
import typing as t
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class Common:
|
|
9
|
+
"""
|
|
10
|
+
The common response structure.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
jsonrpc: str
|
|
14
|
+
id: int
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def from_dict(cls, data: t.Dict):
|
|
18
|
+
"""
|
|
19
|
+
Prepare fields for nested dataclasses
|
|
20
|
+
"""
|
|
21
|
+
field_values = {}
|
|
22
|
+
for field in cls.__dataclass_fields__:
|
|
23
|
+
field_type = cls.__dataclass_fields__[field].type
|
|
24
|
+
field_data = data.get(field)
|
|
25
|
+
|
|
26
|
+
# Check if field_type is a class and subclass of Common
|
|
27
|
+
if isinstance(field_data, dict) and inspect.isclass(field_type) and issubclass(field_type, Common):
|
|
28
|
+
field_values[field] = field_type.from_dict(field_data)
|
|
29
|
+
else:
|
|
30
|
+
field_values[field] = field_data
|
|
31
|
+
|
|
32
|
+
return cls(**field_values)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass
|
|
36
|
+
class Account(Common):
|
|
37
|
+
"""
|
|
38
|
+
The account object represents a user's banking account.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
_id: str
|
|
42
|
+
account_number: str
|
|
43
|
+
account_name: str
|
|
44
|
+
account_type: str
|
|
45
|
+
bank_name: str
|
|
46
|
+
currency: str
|
|
47
|
+
status: str
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class PaymentMethod(Common):
|
|
52
|
+
"""
|
|
53
|
+
The payment method object represents a user's payment method.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
name: str
|
|
57
|
+
title: str
|
|
58
|
+
value: str
|
|
59
|
+
main: t.Optional[bool] = None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class Detail(Common):
|
|
64
|
+
"""
|
|
65
|
+
The detail object represents additional details for a receipt.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
discount: t.Optional[str] = None
|
|
69
|
+
shipping: t.Optional[str] = None
|
|
70
|
+
items: t.Optional[str] = None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# pylint: disable=C0103
|
|
74
|
+
@dataclass
|
|
75
|
+
class MerchantEpos(Common):
|
|
76
|
+
"""
|
|
77
|
+
The merchantEpos object represents a user's ePOS.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
eposId: str
|
|
81
|
+
eposName: str
|
|
82
|
+
eposType: str
|
|
83
|
+
eposTerminalId: str
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass
|
|
87
|
+
class Meta(Common):
|
|
88
|
+
"""
|
|
89
|
+
The meta object represents additional metadata for a receipt.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
source: t.Any = None
|
|
93
|
+
owner: t.Any = None
|
|
94
|
+
host: t.Any = None
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@dataclass
|
|
98
|
+
class Merchant:
|
|
99
|
+
"""
|
|
100
|
+
The merchant object represents a user's merchant.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
_id: str
|
|
104
|
+
name: str
|
|
105
|
+
organization: str
|
|
106
|
+
address: t.Optional[str] = None
|
|
107
|
+
business_id: t.Optional[str] = None
|
|
108
|
+
epos: t.Optional[MerchantEpos] = None
|
|
109
|
+
restrictions: t.Optional[str] = None
|
|
110
|
+
date: t.Optional[int] = None
|
|
111
|
+
logo: t.Optional[str] = None
|
|
112
|
+
type: t.Optional[str] = None
|
|
113
|
+
terms: t.Optional[str] = None
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@dataclass
|
|
117
|
+
class Payer(Common):
|
|
118
|
+
"""
|
|
119
|
+
The payer object represents a user's payer.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
phone: str
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@dataclass
|
|
126
|
+
class Receipt(Common):
|
|
127
|
+
"""
|
|
128
|
+
The receipt object represents a payment receipt.
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
_id: str
|
|
132
|
+
create_time: int
|
|
133
|
+
pay_time: int
|
|
134
|
+
cancel_time: int
|
|
135
|
+
state: int
|
|
136
|
+
type: int
|
|
137
|
+
external: bool
|
|
138
|
+
operation: int
|
|
139
|
+
error: t.Any = None
|
|
140
|
+
description: t.Optional[str] = None
|
|
141
|
+
detail: t.Optional[Detail] = None
|
|
142
|
+
currency: t.Optional[int] = None
|
|
143
|
+
commission: t.Optional[int] = None
|
|
144
|
+
card: t.Optional[str] = None
|
|
145
|
+
creator: t.Optional[str] = None
|
|
146
|
+
payer: t.Optional[Payer] = None
|
|
147
|
+
amount: t.Optional[t.Union[float, int]] = None
|
|
148
|
+
account: t.Optional[t.List[Account]] = None
|
|
149
|
+
merchant: t.Optional[Merchant] = None
|
|
150
|
+
processing_id: t.Optional[str] = None
|
|
151
|
+
meta: t.Optional[Meta] = None
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@dataclass
|
|
155
|
+
class CreateResult(Common):
|
|
156
|
+
"""
|
|
157
|
+
The result object for the create response.
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
receipt: Receipt
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@dataclass
|
|
164
|
+
class CreateResponse(Common):
|
|
165
|
+
"""
|
|
166
|
+
The create response structure.
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
result: CreateResult
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@dataclass
|
|
173
|
+
class PayResponse(CreateResponse):
|
|
174
|
+
"""
|
|
175
|
+
The pay response structure.
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@dataclass
|
|
180
|
+
class SendResult(Common):
|
|
181
|
+
"""
|
|
182
|
+
The result object for the send response.
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
success: bool
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
@dataclass
|
|
189
|
+
class SendResponse(Common):
|
|
190
|
+
"""
|
|
191
|
+
The send response structure.
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
result: SendResult
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@dataclass
|
|
198
|
+
class CancelResponse(CreateResponse):
|
|
199
|
+
"""
|
|
200
|
+
The cancel response structure.
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
@dataclass
|
|
205
|
+
class CheckResult(Common):
|
|
206
|
+
"""
|
|
207
|
+
The result object for the check response.
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
state: int
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
@dataclass
|
|
214
|
+
class CheckResponse(Common):
|
|
215
|
+
"""
|
|
216
|
+
The check response structure.
|
|
217
|
+
"""
|
|
218
|
+
|
|
219
|
+
result: CheckResult
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@dataclass
|
|
223
|
+
class GetResponse(CreateResponse):
|
|
224
|
+
"""
|
|
225
|
+
The result object for the get response.
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@dataclass
|
|
230
|
+
class GetAllResponse(Common):
|
|
231
|
+
"""
|
|
232
|
+
The result object for the get all response.
|
|
233
|
+
"""
|
|
234
|
+
result: list[Receipt] = None
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
@dataclass
|
|
238
|
+
class SetFiscalDataResponse(Common):
|
|
239
|
+
"""
|
|
240
|
+
The result object for the set_fiscal_data response.
|
|
241
|
+
"""
|
|
242
|
+
result: SendResult
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CommonResponse:
|
|
6
|
+
"""
|
|
7
|
+
The common response structure
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
def as_resp(self):
|
|
11
|
+
response = {"result": {}}
|
|
12
|
+
for key, value in self.__dict__.items():
|
|
13
|
+
response["result"][key] = value
|
|
14
|
+
return response
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class Shipping(CommonResponse):
|
|
19
|
+
"""
|
|
20
|
+
Shipping information response structure
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
title: str
|
|
24
|
+
price: int
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass
|
|
28
|
+
class Item(CommonResponse):
|
|
29
|
+
"""
|
|
30
|
+
Item information response structure
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
discount: int
|
|
34
|
+
title: str
|
|
35
|
+
price: int
|
|
36
|
+
count: int
|
|
37
|
+
code: str
|
|
38
|
+
units: int
|
|
39
|
+
vat_percent: int
|
|
40
|
+
package_code: str
|
|
41
|
+
|
|
42
|
+
def as_resp(self):
|
|
43
|
+
return {
|
|
44
|
+
"discount": self.discount,
|
|
45
|
+
"title": self.title,
|
|
46
|
+
"price": self.price,
|
|
47
|
+
"count": self.count,
|
|
48
|
+
"code": self.code,
|
|
49
|
+
"units": self.units,
|
|
50
|
+
"vat_percent": self.vat_percent,
|
|
51
|
+
"package_code": self.package_code,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class CheckPerformTransaction(CommonResponse):
|
|
57
|
+
"""
|
|
58
|
+
Receipt information response structure for transaction checks.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
allow: bool
|
|
62
|
+
additional: t.Optional[t.Dict[str, str]] = None
|
|
63
|
+
receipt_type: t.Optional[int] = None
|
|
64
|
+
shipping: t.Optional[Shipping] = None
|
|
65
|
+
items: t.List[Item] = field(default_factory=list)
|
|
66
|
+
|
|
67
|
+
def add_item(self, item: Item):
|
|
68
|
+
self.items.append(item)
|
|
69
|
+
|
|
70
|
+
def as_resp(self):
|
|
71
|
+
detail_dict = {}
|
|
72
|
+
receipt_dict = {"allow": self.allow}
|
|
73
|
+
|
|
74
|
+
if self.additional:
|
|
75
|
+
receipt_dict["additional"] = self.additional
|
|
76
|
+
|
|
77
|
+
if isinstance(self.receipt_type, int):
|
|
78
|
+
detail_dict["receipt_type"] = self.receipt_type
|
|
79
|
+
|
|
80
|
+
if self.shipping:
|
|
81
|
+
detail_dict["shipping"] = self.shipping.as_resp()
|
|
82
|
+
|
|
83
|
+
if self.items:
|
|
84
|
+
detail_dict["items"] = [item.as_resp() for item in self.items]
|
|
85
|
+
|
|
86
|
+
if detail_dict:
|
|
87
|
+
receipt_dict["detail"] = detail_dict
|
|
88
|
+
|
|
89
|
+
return {"result": receipt_dict}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@dataclass
|
|
93
|
+
class CreateTransaction(CommonResponse):
|
|
94
|
+
"""
|
|
95
|
+
The create transaction request
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
transaction: str
|
|
99
|
+
state: str
|
|
100
|
+
create_time: int
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@dataclass
|
|
104
|
+
class PerformTransaction(CommonResponse):
|
|
105
|
+
"""
|
|
106
|
+
The perform transaction response
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
transaction: str
|
|
110
|
+
state: str
|
|
111
|
+
perform_time: int
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass
|
|
115
|
+
class CancelTransaction(CommonResponse):
|
|
116
|
+
"""
|
|
117
|
+
The cancel transaction request
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
transaction: str
|
|
121
|
+
state: str
|
|
122
|
+
cancel_time: str
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@dataclass
|
|
126
|
+
class CheckTransaction(CommonResponse):
|
|
127
|
+
"""
|
|
128
|
+
The check transaction request
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
transaction: str
|
|
132
|
+
state: str
|
|
133
|
+
reason: str
|
|
134
|
+
create_time: int
|
|
135
|
+
perform_time: t.Optional[int] = None
|
|
136
|
+
cancel_time: t.Optional[int] = None
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@dataclass
|
|
140
|
+
class GetStatement(CommonResponse):
|
|
141
|
+
"""
|
|
142
|
+
The check perform transactions response
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
transactions: t.List[t.Dict[str, str | int | t.Dict[str, str | int]]]
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@dataclass
|
|
149
|
+
class SetFiscalData(CommonResponse):
|
|
150
|
+
"""
|
|
151
|
+
The set fiscal data request
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
success: bool
|
|
Binary file
|
|
Binary file
|
payme/views/__init__.py
ADDED
|
Binary file
|
payme/views/payme.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from payme.views.base import BasePaymeWebHookAPIView
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class PaymeWebHookAPIView(BasePaymeWebHookAPIView):
|
|
5
|
+
"""
|
|
6
|
+
A webhook view for Payme with callback handlers.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def handle_pre_payment(self, params, result, *args, **kwargs):
|
|
10
|
+
"""
|
|
11
|
+
Handle the pre_create_transaction action. You can override this method
|
|
12
|
+
"""
|
|
13
|
+
print(f"Transaction pre_created for this params: {params} and pre_created_result: {result}")
|
|
14
|
+
|
|
15
|
+
def handle_created_payment(self, params, result, *args, **kwargs):
|
|
16
|
+
"""
|
|
17
|
+
Handle the successful payment. You can override this method
|
|
18
|
+
"""
|
|
19
|
+
print(f"Transaction created for this params: {params} and cr_result: {result}")
|
|
20
|
+
|
|
21
|
+
def handle_successfully_payment(self, params, result, *args, **kwargs):
|
|
22
|
+
"""
|
|
23
|
+
Handle the successful payment. You can override this method
|
|
24
|
+
"""
|
|
25
|
+
print(f"Transaction successfully performed for this params: {params} and performed_result: {result}")
|
|
26
|
+
|
|
27
|
+
def handle_cancelled_payment(self, params, result, *args, **kwargs):
|
|
28
|
+
"""
|
|
29
|
+
Handle the cancelled payment. You can override this method
|
|
30
|
+
"""
|
|
31
|
+
print(f"Transaction cancelled for this params: {params} and cancelled_result: {result}")
|