payme-pkg 3.0.22__py3-none-any.whl → 3.0.24__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/admin.py CHANGED
@@ -1,3 +1,4 @@
1
+ from django.conf import settings
1
2
  from django.contrib import admin
2
3
 
3
4
  from payme.models import PaymeTransactions
@@ -13,4 +14,5 @@ class PaymeTransactionsUI(admin.ModelAdmin):
13
14
  ordering = ('-created_at',)
14
15
 
15
16
 
16
- admin.site.register(PaymeTransactions, PaymeTransactionsUI)
17
+ if not getattr(settings, 'PAYME_DISABLE_ADMIN', False):
18
+ admin.site.register(PaymeTransactions, PaymeTransactionsUI)
@@ -116,10 +116,42 @@ class TransactionAlreadyExists(BasePaymeException):
116
116
  }
117
117
 
118
118
 
119
+ class InvalidFiscalParams(BasePaymeException):
120
+ """
121
+ InvalidFiscalParams APIException.
122
+
123
+ Raised when the provided fiscal parameters are invalid.
124
+ """
125
+ status_code = 200
126
+ error_code = -32602
127
+ message = {
128
+ "uz": "Fiskal parameterlarida kamchiliklar bor",
129
+ "ru": "Неверные фискальные параметры.",
130
+ "en": "Invalid fiscal parameters."
131
+ }
132
+
133
+
134
+ class InvalidAccount(BasePaymeException):
135
+ """
136
+ InvalidAccount APIException.
137
+
138
+ Raised when the provided account is invalid.
139
+ """
140
+ status_code = 200
141
+ error_code = -32400
142
+ message = {
143
+ "uz": "Hisob nomida kamchilik bor",
144
+ "ru": "Неверный номер счета.",
145
+ "en": "Invalid account."
146
+ }
147
+
148
+
119
149
  exception_whitelist = (
120
150
  IncorrectAmount,
121
151
  MethodNotFound,
122
152
  PermissionDenied,
123
153
  AccountDoesNotExist,
124
- TransactionAlreadyExists
154
+ TransactionAlreadyExists,
155
+ InvalidFiscalParams,
156
+ InvalidAccount
125
157
  )
@@ -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
+ ]
payme/models.py CHANGED
@@ -29,6 +29,7 @@ class PaymeTransactions(models.Model):
29
29
  account_id = models.BigIntegerField(null=False)
30
30
  amount = models.DecimalField(max_digits=10, decimal_places=2)
31
31
  state = models.IntegerField(choices=STATE, default=CREATED)
32
+ fiscal_data = models.JSONField(default=dict)
32
33
  cancel_reason = models.IntegerField(null=True, blank=True)
33
34
  created_at = models.DateTimeField(auto_now_add=True, db_index=True)
34
35
  updated_at = models.DateTimeField(auto_now=True, db_index=True)
@@ -134,3 +134,11 @@ class GetStatement(CommonResponse):
134
134
  The check perform transactions response
135
135
  """
136
136
  transactions: List[str]
137
+
138
+
139
+ @dataclass
140
+ class SetFiscalData(CommonResponse):
141
+ """
142
+ The set fiscal data request
143
+ """
144
+ success: bool
payme/views.py CHANGED
@@ -66,6 +66,7 @@ class PaymeWebHookAPIView(views.APIView):
66
66
  "CreateTransaction": self.create_transaction,
67
67
  "CheckTransaction": self.check_transaction,
68
68
  "CheckPerformTransaction": self.check_perform_transaction,
69
+ "SetFiscalData": self.set_fiscal_data,
69
70
  }
70
71
 
71
72
  try:
@@ -300,6 +301,33 @@ class PaymeWebHookAPIView(views.APIView):
300
301
 
301
302
  return result.as_resp()
302
303
 
304
+ @handle_exceptions
305
+ def set_fiscal_data(self, params):
306
+ """
307
+ Set fiscal data for the given transaction.
308
+ """
309
+ transaction = PaymeTransactions.get_by_transaction_id(transaction_id=params["id"])
310
+
311
+ fiscal_data = params.get("fiscal_data")
312
+ if not fiscal_data:
313
+ raise exceptions.InvalidFiscalParams(
314
+ "Missing fiscal_data field in parameters."
315
+ )
316
+
317
+ fiscal_type = params.get("type")
318
+
319
+ if fiscal_type not in ("PERFORM", "CANCEL"):
320
+ raise exceptions.InvalidFiscalParams(
321
+ f"Invalid fiscal type. Expected 'PERFORM' or 'CANCEL', got: {fiscal_type}"
322
+ )
323
+
324
+ fiscal_data["type"] = fiscal_type
325
+ transaction.fiscal_data = fiscal_data
326
+ transaction.save()
327
+
328
+ result = response.SetFiscalData(success=True)
329
+ return result.as_resp()
330
+
303
331
  def _cancel_response(self, transaction):
304
332
  """
305
333
  Helper method to generate cancel transaction response.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: payme-pkg
3
- Version: 3.0.22
3
+ Version: 3.0.24
4
4
  Home-page: https://github.com/Muhammadali-Akbarov/payme-pkg
5
5
  Author: Muhammadali Akbarov
6
6
  Author-email: muhammadali17abc@gmail.com
@@ -89,6 +89,8 @@ PAYME_KEY = "your-payme-key"
89
89
  PAYME_ACCOUNT_FIELD = "id"
90
90
  PAYME_ACCOUNT_MODEL = "clients.models.Client"
91
91
  PAYME_ONE_TIME_PAYMENT = False
92
+
93
+ PAYME_DISABLE_ADMIN = False (optionally configuration if you want to disable change to True)
92
94
  ```
93
95
 
94
96
  Create a new View that about handling call backs
@@ -1,11 +1,11 @@
1
1
  payme/__init__.py,sha256=dzLIyA9kQl0sO6z9nHkZDTjkfiI1BepdifKtJbjX2Cw,46
2
- payme/admin.py,sha256=QW93VTNRZ3qr2eMySX0odyQDmBXJDMXVPCzJPLH78GI,468
2
+ payme/admin.py,sha256=k4_kAX6k8993aQo_7xokIc7InUVw4LGZT5ROn-C9EYU,561
3
3
  payme/apps.py,sha256=HHCY4zUNKPcjz25z0MahZcks0lsAxTGPS0Ml3U4DhZc,142
4
4
  payme/const.py,sha256=azndfKR53fe7mDfGW82Q-kwWdMu3x4S1upKc4gkYdlA,214
5
- payme/models.py,sha256=C0-dbXEpzZBx1-GsdBXwKQt7gJ6AvgPO6l-3VljfNtw,4130
5
+ payme/models.py,sha256=nOVmknNjQkBos7w069ddAp_wTBj14UssdTgO8w8sTdI,4179
6
6
  payme/urls.py,sha256=_oUOwxW1Suc5TUmnj--lySYbotRg4yTDkDLJU20CGjE,145
7
7
  payme/util.py,sha256=UFb4cEnaufS_hh9C_0z079CSgJGivYjIgOl2iAFrBMs,625
8
- payme/views.py,sha256=AYWXP9zJGcLkTM91RIiL6Ou4RHqLph3NyYIlzPAN3fU,11939
8
+ payme/views.py,sha256=gSQgctinjjAWhEO-kCIF4Jn01yapzHRi2ovtkc6JgJw,12873
9
9
  payme/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  payme/classes/cards.py,sha256=dr3SQdKAhfQmECtwHYW2nmx8wXaNYQFkg5uQU9z8vs4,7624
11
11
  payme/classes/client.py,sha256=Fjck3vSRh8-NQ8HnxwytCn_qZm6UfwMKCBYDHtUSJAs,864
@@ -14,17 +14,19 @@ payme/classes/initializer.py,sha256=TWJnlJTXefROMleIvJeT64xjIVWQU-LIXai8TZ_M7nw,
14
14
  payme/classes/receipts.py,sha256=KU4qyGHWZpWW88SjmmTD_N2Tz8pWOCvBbOPnw5tcS3Y,10094
15
15
  payme/exceptions/__init__.py,sha256=HoBFnDA3eW_xWZiFlonJK4vhBDTsuik91tvgzXTy8KA,94
16
16
  payme/exceptions/general.py,sha256=-rkzvuLi6VoITMLrszrP7c-gM8X6lM8AWttd770KSJc,7679
17
- payme/exceptions/webhook.py,sha256=f0J-fmCW_wpgsTmjGAOtyoZjIOoFpbQwkh_7cZUZkv0,3046
17
+ payme/exceptions/webhook.py,sha256=hiX3CEjlPsFkliJm7SNM3XImU1IBscPhiwsnJJqhku4,3843
18
18
  payme/migrations/0001_initial.py,sha256=jdtGB6bN-Za6N9XU8IuWsa5FbonGIRH5ro9xHwT7JmU,2128
19
+ payme/migrations/0002_paymetransactions_fiscal_data.py,sha256=z-gxPP3IgN-XNPx6DEZUQ4E1XZceVnnpvUTcSkcv70c,395
20
+ payme/migrations/0003_alter_paymetransactions_fiscal_data.py,sha256=Ish4Seup9pdEM0g4q4RQKrvUOWB2DXPN0RmIScKI2IQ,410
19
21
  payme/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
22
  payme/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
23
  payme/types/request/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
24
  payme/types/response/__init__.py,sha256=GAj5pjZ9oIO67T6YMiPd1fhTIvGrPfTv96tykfeChQc,81
23
25
  payme/types/response/cards.py,sha256=ilXFDUOPNabVsrQN1KWEzDiL6cDxdVvCbfEl6jCzGpU,1997
24
26
  payme/types/response/receipts.py,sha256=TlZeJyymRVHIorg0kbUaogy6MZxN1oq2jHGVRUnlY5A,4070
25
- payme/types/response/webhook.py,sha256=Br6Gr_-h7sCmOc3ag7H5yBryB8j-bm2mrt39Cy_Fy2E,2918
26
- payme_pkg-3.0.22.dist-info/LICENSE.txt,sha256=75dBVYmbzWUhwtaB1MSZfj-M-PGaMmeT9UVPli2-ZJ0,1086
27
- payme_pkg-3.0.22.dist-info/METADATA,sha256=c5D9qqGVK_qD6SPkvlpxEDePViDZVE0zK0S09KS1bGo,5278
28
- payme_pkg-3.0.22.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
29
- payme_pkg-3.0.22.dist-info/top_level.txt,sha256=8mN-hGAa38pWbhrKHFs9CZywPCdidhMuwPKwuFJa0qw,6
30
- payme_pkg-3.0.22.dist-info/RECORD,,
27
+ payme/types/response/webhook.py,sha256=9tw_QsKNAUqgZLwL7Pg0SIVAry0BlxlWOu8BDmKewzc,3034
28
+ payme_pkg-3.0.24.dist-info/LICENSE.txt,sha256=75dBVYmbzWUhwtaB1MSZfj-M-PGaMmeT9UVPli2-ZJ0,1086
29
+ payme_pkg-3.0.24.dist-info/METADATA,sha256=5M5dOOlQtVeu9ZFGxxpAL2zuHWzvWm4TWC4XSXQuUoQ,5372
30
+ payme_pkg-3.0.24.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
31
+ payme_pkg-3.0.24.dist-info/top_level.txt,sha256=8mN-hGAa38pWbhrKHFs9CZywPCdidhMuwPKwuFJa0qw,6
32
+ payme_pkg-3.0.24.dist-info/RECORD,,