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.
Files changed (37) hide show
  1. payme/__init__.py +1 -0
  2. payme/admin.cpython-312-darwin.so +0 -0
  3. payme/apps.cpython-312-darwin.so +0 -0
  4. payme/classes/__init__.py +0 -0
  5. payme/classes/cards.cpython-312-darwin.so +0 -0
  6. payme/classes/client.py +313 -0
  7. payme/classes/http.cpython-312-darwin.so +0 -0
  8. payme/classes/initializer.cpython-312-darwin.so +0 -0
  9. payme/classes/receipts.cpython-312-darwin.so +0 -0
  10. payme/const.cpython-312-darwin.so +0 -0
  11. payme/exceptions/__init__.py +5 -0
  12. payme/exceptions/general.cpython-312-darwin.so +0 -0
  13. payme/exceptions/webhook.cpython-312-darwin.so +0 -0
  14. payme/licensing.cpython-312-darwin.so +0 -0
  15. payme/migrations/0001_initial.py +60 -0
  16. payme/migrations/0002_paymetransactions_fiscal_data.py +18 -0
  17. payme/migrations/0003_alter_paymetransactions_fiscal_data.py +18 -0
  18. payme/migrations/0004_alter_paymetransactions_account_id.py +18 -0
  19. payme/migrations/0005_alter_paymetransactions_amount.py +19 -0
  20. payme/migrations/__init__.py +0 -0
  21. payme/models.cpython-312-darwin.so +0 -0
  22. payme/types/__init__.py +0 -0
  23. payme/types/request/__init__.py +0 -0
  24. payme/types/response/__init__.py +4 -0
  25. payme/types/response/cards.py +122 -0
  26. payme/types/response/receipts.py +242 -0
  27. payme/types/response/webhook.py +154 -0
  28. payme/urls.cpython-312-darwin.so +0 -0
  29. payme/util.cpython-312-darwin.so +0 -0
  30. payme/views/__init__.py +5 -0
  31. payme/views/base.cpython-312-darwin.so +0 -0
  32. payme/views/payme.py +31 -0
  33. payme_pkg-3.3.0.dist-info/METADATA +444 -0
  34. payme_pkg-3.3.0.dist-info/RECORD +37 -0
  35. payme_pkg-3.3.0.dist-info/WHEEL +5 -0
  36. payme_pkg-3.3.0.dist-info/licenses/LICENSE.txt +24 -0
  37. payme_pkg-3.3.0.dist-info/top_level.txt +1 -0
payme/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from payme.classes.client import Payme # noqa
Binary file
Binary file
File without changes
@@ -0,0 +1,313 @@
1
+ import typing as t
2
+
3
+ from payme.const import Networks
4
+
5
+ from payme.licensing import validate_api_key
6
+
7
+ from payme.classes.cards import Cards
8
+ from payme.classes.receipts import Receipts
9
+ from payme.classes.initializer import Initializer
10
+ from payme.types.response import cards as card_response
11
+ from payme.types.response import receipts as receipt_response
12
+
13
+
14
+ class Payme:
15
+ """
16
+ The payme class provides a simple interface
17
+ """
18
+
19
+ def __init__(
20
+ self,
21
+ payme_id: str,
22
+ fallback_id: t.Optional[str] = None,
23
+ payme_key: t.Optional[str] = None,
24
+ is_test_mode: bool = False,
25
+ license_api_key: t.Optional[str] = None,
26
+ ) -> None:
27
+ validate_api_key(license_api_key)
28
+
29
+ url = Networks.PROD_NET.value
30
+
31
+ if is_test_mode is True:
32
+ url = Networks.TEST_NET.value
33
+
34
+ self.cards = Cards(url=url, payme_id=payme_id)
35
+ self.initializer = Initializer(
36
+ payme_id=payme_id, fallback_id=fallback_id, is_test_mode=is_test_mode
37
+ )
38
+ if payme_key:
39
+ self.receipts = Receipts(url=url, payme_id=payme_id, payme_key=payme_key)
40
+
41
+ def cards_create(
42
+ self,
43
+ number: str,
44
+ expire: str,
45
+ save: bool = False,
46
+ timeout: int = 10
47
+ ) -> card_response.CardsCreateResponse:
48
+ """
49
+ Create a new card.
50
+
51
+ :param number: The card number.
52
+ :param expire: The expiration date of the card in MMYY format.
53
+ :param save: A boolean indicating whether to save the card for future
54
+ use (default is False).
55
+ :param timeout: The request timeout duration in seconds (default is
56
+ 10 seconds).
57
+ :return: A CardsCreateResponse object containing the response data.
58
+ """
59
+ return self.cards.create(number=number, expire=expire, save=save, timeout=timeout)
60
+
61
+ def cards_get_verify_code(
62
+ self,
63
+ token: str,
64
+ timeout: int = 10
65
+ ) -> card_response.GetVerifyResponse:
66
+ """
67
+ Retrieve a verification code for a specified token.
68
+
69
+ :param token: The token associated with the card.
70
+ :param timeout: The request timeout duration in seconds (default is
71
+ 10 seconds).
72
+ :return: A GetVerifyResponse object containing the response data.
73
+ """
74
+ return self.cards.get_verify_code(token=token, timeout=timeout)
75
+
76
+ def cards_verify(
77
+ self,
78
+ token: str,
79
+ code: str,
80
+ timeout: int = 10
81
+ ) -> card_response.VerifyResponse:
82
+ """
83
+ Verify a verification code for a specified token.
84
+
85
+ :param token: The token associated with the card.
86
+ :param code: The verification code to be verified.
87
+ :param timeout: The request timeout duration in seconds (default is
88
+ 10 seconds).
89
+ :return: A VerifyResponse object containing the response data.
90
+ """
91
+ return self.cards.verify(token=token, code=code, timeout=timeout)
92
+
93
+ def cards_remove(
94
+ self,
95
+ token: str,
96
+ timeout: int = 10
97
+ ) -> card_response.RemoveResponse:
98
+ """
99
+ Remove a card from the Paycom system.
100
+
101
+ :param token: The token associated with the card.
102
+ :param timeout: The request timeout duration in seconds (default is
103
+ 10 seconds).
104
+ :return: A RemoveResponse object containing the response data.
105
+ """
106
+ return self.cards.remove(token=token, timeout=timeout)
107
+
108
+ def cards_check(
109
+ self,
110
+ token: str,
111
+ timeout: int = 10
112
+ ) -> card_response.CheckResponse:
113
+ """
114
+ Check the status of a card.
115
+
116
+ :param token: The token associated with the card.
117
+ :param timeout: The request timeout duration in seconds (default is
118
+ 10 seconds).
119
+ :return: A CheckResponse object containing the response data.
120
+ """
121
+ return self.cards.check(token=token, timeout=timeout)
122
+
123
+ def cards_test(self) -> None:
124
+ """
125
+ Run a comprehensive test suite for card functionalities including
126
+ creation, verification, status check, and removal.
127
+ """
128
+ return self.cards.test()
129
+
130
+ def receipts_create(
131
+ self,
132
+ account: dict,
133
+ amount: t.Union[float, int],
134
+ description: t.Optional[str] = None,
135
+ detail: t.Optional[t.Dict] = None,
136
+ timeout: int = 10,
137
+ ) -> receipt_response.CreateResponse:
138
+ """
139
+ Create a new receipt.
140
+
141
+ :param account: The account details for the receipt.
142
+ :param amount: The amount of the receipt.
143
+ :param description: Optional description for the receipt.
144
+ :param detail: Optional additional details for the receipt.
145
+ :param timeout: The request timeout duration in seconds (default 10).
146
+ """
147
+ return self.receipts.create(
148
+ account=account,
149
+ amount=amount,
150
+ description=description,
151
+ detail=detail,
152
+ timeout=timeout
153
+ )
154
+
155
+ def receipts_pay(
156
+ self,
157
+ receipts_id: str,
158
+ token: str,
159
+ timeout: int = 10
160
+ ) -> receipt_response.PayResponse:
161
+ """
162
+ Pay the receipt using a token.
163
+
164
+ :param receipts_id: The ID of the receipt used for payment.
165
+ :param token: The token associated with the card.
166
+ :param timeout: The request timeout duration in seconds (default is 10).
167
+ """
168
+ return self.receipts.pay(receipts_id=receipts_id, token=token, timeout=timeout)
169
+
170
+ def receipts_send(
171
+ self,
172
+ receipts_id: str,
173
+ phone: str,
174
+ timeout: int = 10
175
+ ) -> receipt_response.SendResponse:
176
+ """
177
+ Send the receipt to a mobile phone.
178
+
179
+ :param receipts_id: The ID of the receipt used for payment.
180
+ :param phone: The phone number to send the receipt to.
181
+ :param timeout: The request timeout duration in seconds (default 10).
182
+ """
183
+ return self.receipts.send(receipts_id=receipts_id, phone=phone, timeout=timeout)
184
+
185
+ def receipts_cancel(
186
+ self,
187
+ receipts_id: str,
188
+ timeout: int = 10
189
+ ) -> receipt_response.CancelResponse:
190
+ """
191
+ Cancel the receipt.
192
+
193
+ :param receipts_id: The ID of the receipt used for payment.
194
+ :param timeout: The request timeout duration in seconds (default 10).
195
+ """
196
+ return self.receipts.cancel(receipts_id=receipts_id, timeout=timeout)
197
+
198
+ def receipts_check(
199
+ self,
200
+ receipts_id: str,
201
+ timeout: int = 10
202
+ ) -> receipt_response.CheckResponse:
203
+ """
204
+ Check the status of a receipt.
205
+
206
+ :param receipts_id: The ID of the receipt used for payment.
207
+ :param timeout: The request timeout duration in seconds (default 10).
208
+ """
209
+ return self.receipts.check(receipts_id=receipts_id, timeout=timeout)
210
+
211
+ def receipts_get(
212
+ self,
213
+ receipts_id: str,
214
+ timeout: int = 10
215
+ ) -> receipt_response.GetResponse:
216
+ """
217
+ Get the details of a specific receipt.
218
+
219
+ :param receipts_id: The ID of the receipt used for payment.
220
+ :param timeout: The request timeout duration in seconds (default 10).
221
+ """
222
+ return self.receipts.get(receipts_id=receipts_id, timeout=timeout)
223
+
224
+ def receipts_get_all(
225
+ self,
226
+ count: int,
227
+ from_: int,
228
+ to: int,
229
+ offset: int,
230
+ timeout: int = 10
231
+ ) -> receipt_response.GetAllResponse:
232
+ """
233
+ Get all receipts for a specific account.
234
+
235
+ :param count: The number of receipts to retrieve.
236
+ :param from_: The start index of the receipts to retrieve.
237
+ :param to: The end index of the receipts to retrieve.
238
+ :param offset: The offset for pagination.
239
+ :param timeout: The request timeout duration in seconds (default 10).
240
+ """
241
+ return self.receipts.get_all(
242
+ count=count,
243
+ from_=from_,
244
+ to=to,
245
+ offset=offset,
246
+ timeout=timeout
247
+ )
248
+
249
+ def receipts_set_fiscal_data(
250
+ self,
251
+ receipt_id: str,
252
+ qr_code_url: str,
253
+ timeout: int = 10
254
+ ) -> receipt_response.SetFiscalDataResponse:
255
+ """
256
+ Set fiscal data for a receipt.
257
+
258
+ :param receipt_id: The ID of the receipt used for payment.
259
+ :param qr_code_url: URL of the fiscal check from the ofd.uz.
260
+ :param timeout: The request timeout duration in seconds (default 10).
261
+ """
262
+ return self.receipts.set_fiscal_data(
263
+ receipt_id=receipt_id,
264
+ qr_code_url=qr_code_url,
265
+ timeout=timeout
266
+ )
267
+
268
+ def receipts_test(self) -> None:
269
+ """
270
+ Run a comprehensive test suite for receipts functionalities.
271
+ """
272
+ if not hasattr(self, 'receipts'):
273
+ raise AttributeError("Receipts not initialized. Provide payme_key in constructor.")
274
+ return self.receipts.test()
275
+
276
+ def generate_pay_link(
277
+ self,
278
+ id: int,
279
+ amount: int,
280
+ return_url: str
281
+ ) -> str:
282
+ """
283
+ Generate a payment link for a specific order.
284
+
285
+ This method encodes the payment parameters into a base64 string and
286
+ constructs a URL for the Payme checkout.
287
+
288
+ :param id: Unique identifier for the account.
289
+ :param amount: The amount associated with the order in currency units.
290
+ :param return_url: The URL to which the user will be redirected after
291
+ the payment is processed.
292
+ :return: A payment link formatted as a URL, ready to be used in the
293
+ payment process.
294
+ """
295
+ return self.initializer.generate_pay_link(
296
+ id=id,
297
+ amount=amount,
298
+ return_url=return_url
299
+ )
300
+
301
+ def generate_fallback_link(
302
+ self,
303
+ form_fields: dict = None
304
+ ) -> str:
305
+ """
306
+ Generate a fallback URL for the Payme checkout.
307
+
308
+ :param form_fields: Additional query parameters to be appended to the
309
+ fallback URL.
310
+ :return: A fallback URL formatted as a URL, ready to be used in the
311
+ payment process.
312
+ """
313
+ return self.initializer.generate_fallback_link(form_fields=form_fields)
Binary file
Binary file
@@ -0,0 +1,5 @@
1
+ """
2
+ init all payme exceptions
3
+ """
4
+ from .general import * # noqa
5
+ from .webhook import * # noqa
Binary file
@@ -0,0 +1,60 @@
1
+ # Generated by Django 5.1.2 on 2024-12-22 05:15
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ initial = True
9
+
10
+ dependencies = []
11
+
12
+ operations = [
13
+ migrations.CreateModel(
14
+ name="PaymeTransactions",
15
+ fields=[
16
+ (
17
+ "id",
18
+ models.BigAutoField(
19
+ auto_created=True,
20
+ primary_key=True,
21
+ serialize=False,
22
+ verbose_name="ID",
23
+ ),
24
+ ),
25
+ ("transaction_id", models.CharField(max_length=50)),
26
+ ("account_id", models.BigIntegerField()),
27
+ ("amount", models.DecimalField(decimal_places=2, max_digits=10)),
28
+ (
29
+ "state",
30
+ models.IntegerField(
31
+ choices=[
32
+ (0, "Created"),
33
+ (1, "Initiating"),
34
+ (2, "Successfully"),
35
+ (-2, "Canceled after successful performed"),
36
+ (-1, "Canceled during initiation"),
37
+ ],
38
+ default=0,
39
+ ),
40
+ ),
41
+ ("cancel_reason", models.IntegerField(blank=True, null=True)),
42
+ ("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
43
+ ("updated_at", models.DateTimeField(auto_now=True, db_index=True)),
44
+ (
45
+ "performed_at",
46
+ models.DateTimeField(blank=True, db_index=True, null=True),
47
+ ),
48
+ (
49
+ "cancelled_at",
50
+ models.DateTimeField(blank=True, db_index=True, null=True),
51
+ ),
52
+ ],
53
+ options={
54
+ "verbose_name": "Payme Transaction",
55
+ "verbose_name_plural": "Payme Transactions",
56
+ "db_table": "payme_transactions",
57
+ "ordering": ["-created_at"],
58
+ },
59
+ ),
60
+ ]
@@ -0,0 +1,18 @@
1
+ # Generated by Django 5.1.2 on 2025-03-14 08:01
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("payme", "0001_initial"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AddField(
14
+ model_name="paymetransactions",
15
+ name="fiscal_data",
16
+ field=models.JSONField(blank=True, null=True),
17
+ ),
18
+ ]
@@ -0,0 +1,18 @@
1
+ # Generated by Django 5.1.2 on 2025-03-14 08:20
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("payme", "0002_paymetransactions_fiscal_data"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AlterField(
14
+ model_name="paymetransactions",
15
+ name="fiscal_data",
16
+ field=models.JSONField(default=dict),
17
+ ),
18
+ ]
@@ -0,0 +1,18 @@
1
+ # Generated by Django 5.2.5 on 2025-08-25 19:12
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("payme", "0003_alter_paymetransactions_fiscal_data"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AlterField(
14
+ model_name="paymetransactions",
15
+ name="account_id",
16
+ field=models.CharField(max_length=256),
17
+ ),
18
+ ]
@@ -0,0 +1,19 @@
1
+ # Generated migration to increase amount field precision
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("payme", "0004_alter_paymetransactions_account_id"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AlterField(
14
+ model_name="paymetransactions",
15
+ name="amount",
16
+ field=models.DecimalField(decimal_places=2, max_digits=15),
17
+ ),
18
+ ]
19
+
File without changes
Binary file
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ """
2
+ init all response typing of payme provider
3
+ """
4
+ from .webhook import * # noqa
@@ -0,0 +1,122 @@
1
+ import typing as t
2
+ import inspect
3
+ from dataclasses import dataclass
4
+
5
+
6
+ @dataclass
7
+ class Common:
8
+ """
9
+ The common response structure.
10
+ """
11
+
12
+ @classmethod
13
+ def from_dict(cls, data: t.Dict):
14
+ """
15
+ Prepare fields for nested dataclasses
16
+ """
17
+ field_values = {}
18
+ for field in cls.__dataclass_fields__:
19
+ field_type = cls.__dataclass_fields__[field].type
20
+ field_data = data.get(field)
21
+
22
+ # Check if field_type is a class and subclass of Common
23
+ if isinstance(field_data, dict) and inspect.isclass(field_type) and issubclass(field_type, Common):
24
+ field_values[field] = field_type.from_dict(field_data)
25
+ else:
26
+ field_values[field] = field_data
27
+
28
+ return cls(**field_values)
29
+
30
+
31
+ @dataclass
32
+ class Card(Common):
33
+ """
34
+ The card object represents a credit card.
35
+ """
36
+
37
+ number: str
38
+ expire: str
39
+ token: str
40
+ recurrent: bool
41
+ verify: bool
42
+ type: str
43
+ number_hash: t.Optional[str] = None
44
+
45
+
46
+ @dataclass
47
+ class Result(Common):
48
+ """
49
+ The result object contains the created card.
50
+ """
51
+
52
+ card: Card
53
+
54
+
55
+ @dataclass
56
+ class CardsCreateResponse(Common):
57
+ """
58
+ The cards.create response.
59
+ """
60
+
61
+ jsonrpc: str
62
+ result: Result
63
+
64
+
65
+ @dataclass
66
+ class VerifyResult(Common):
67
+ """
68
+ The result object for the verification response.
69
+ """
70
+
71
+ sent: bool
72
+ phone: str
73
+ wait: int
74
+
75
+
76
+ @dataclass
77
+ class GetVerifyResponse(Common):
78
+ """
79
+ The verification response structure.
80
+ """
81
+
82
+ jsonrpc: str
83
+ result: VerifyResult
84
+
85
+
86
+ @dataclass
87
+ class VerifyResponse(Common):
88
+ """
89
+ The verification response structure.
90
+ """
91
+
92
+ jsonrpc: str
93
+ result: Result
94
+
95
+
96
+ @dataclass
97
+ class RemoveCardResult(Common):
98
+ """
99
+ The result object for the removal response.
100
+ """
101
+
102
+ success: bool
103
+
104
+
105
+ @dataclass
106
+ class RemoveResponse(Common):
107
+ """
108
+ The remove response structure.
109
+ """
110
+
111
+ jsonrpc: str
112
+ result: RemoveCardResult
113
+
114
+
115
+ @dataclass
116
+ class CheckResponse(Common):
117
+ """
118
+ The check response structure.
119
+ """
120
+
121
+ jsonrpc: str
122
+ result: Result