payme-pkg 3.0.19__py3-none-any.whl → 3.0.21__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,6 +1,5 @@
1
1
  from django.contrib import admin
2
2
 
3
-
4
3
  from payme.models import PaymeTransactions
5
4
 
6
5
 
@@ -10,7 +9,7 @@ class PaymeTransactionsUI(admin.ModelAdmin):
10
9
  """
11
10
  list_display = ('id', 'state', 'cancel_reason', 'created_at')
12
11
  list_filter = ('state', 'cancel_reason', 'created_at')
13
- search_fields = ('transaction_id', 'account__id')
12
+ search_fields = ('transaction_id', 'account_id')
14
13
  ordering = ('-created_at',)
15
14
 
16
15
 
payme/classes/client.py CHANGED
@@ -26,5 +26,5 @@ class Payme:
26
26
  url = Networks.TEST_NET.value
27
27
 
28
28
  self.cards = Cards(url=url, payme_id=payme_id)
29
- self.initializer = Initializer(payme_id=payme_id, fallback_id=fallback_id)
29
+ self.initializer = Initializer(payme_id=payme_id, fallback_id=fallback_id, is_test_mode=is_test_mode)
30
30
  self.receipts = Receipts(url=url, payme_id=payme_id, payme_key=payme_key) # noqa
@@ -13,10 +13,10 @@ class Initializer:
13
13
  The Payme ID associated with your account
14
14
  """
15
15
 
16
- def __init__(self, payme_id: str = None, fallback_id: str = None):
16
+ def __init__(self, payme_id: str = None, fallback_id: str = None, is_test_mode: bool = False):
17
17
  self.payme_id = payme_id
18
18
  self.fallback_id = fallback_id
19
-
19
+ self.is_test_mode = is_test_mode
20
20
 
21
21
  def generate_pay_link(
22
22
  self,
@@ -56,6 +56,10 @@ class Initializer:
56
56
  f'm={self.payme_id};ac.{settings.PAYME_ACCOUNT_FIELD}={id};a={amount};c={return_url}'
57
57
  )
58
58
  params = base64.b64encode(params.encode("utf-8")).decode("utf-8")
59
+
60
+ if self.is_test_mode is True:
61
+ return f"https://test.paycom.uz/{params}"
62
+
59
63
  return f"https://checkout.paycom.uz/{params}"
60
64
 
61
65
  def generate_fallback_link(self, form_fields: dict = None):
@@ -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
+ ]
payme/models.py CHANGED
@@ -4,13 +4,8 @@ It logs any significant modifications to payment transactions such as amount, st
4
4
  allowing for a detailed historical record of each transaction's state over time.
5
5
  """
6
6
  from django.db import models
7
- from django.conf import settings
8
7
  from django.utils import timezone
9
8
 
10
- from django.utils.module_loading import import_string
11
-
12
- AccountModel = import_string(settings.PAYME_ACCOUNT_MODEL)
13
-
14
9
 
15
10
  class PaymeTransactions(models.Model):
16
11
  """
@@ -31,11 +26,7 @@ class PaymeTransactions(models.Model):
31
26
  ]
32
27
 
33
28
  transaction_id = models.CharField(max_length=50)
34
- account = models.ForeignKey(
35
- AccountModel,
36
- related_name="payme_transactions",
37
- on_delete=models.CASCADE
38
- )
29
+ account_id = models.BigIntegerField(null=False)
39
30
  amount = models.DecimalField(max_digits=10, decimal_places=2)
40
31
  state = models.IntegerField(choices=STATE, default=CREATED)
41
32
  cancel_reason = models.IntegerField(null=True, blank=True)
@@ -57,7 +48,7 @@ class PaymeTransactions(models.Model):
57
48
  """
58
49
  String representation of the PaymentTransaction model.
59
50
  """
60
- return f"Payme Transaction #{self.transaction_id} Account: {self.account} - {self.state}"
51
+ return f"Payme Transaction #{self.transaction_id} Account: {self.account_id} - {self.state}"
61
52
 
62
53
  @classmethod
63
54
  def get_by_transaction_id(cls, transaction_id):
payme/views.py CHANGED
@@ -1,17 +1,16 @@
1
1
  import base64
2
- import logging
3
2
  import binascii
3
+ import logging
4
4
  from decimal import Decimal
5
5
 
6
6
  from django.conf import settings
7
7
  from django.utils.module_loading import import_string
8
-
9
8
  from rest_framework import views
10
9
  from rest_framework.response import Response
11
10
 
12
11
  from payme import exceptions
13
- from payme.types import response
14
12
  from payme.models import PaymeTransactions
13
+ from payme.types import response
15
14
  from payme.util import time_to_payme, time_to_service
16
15
 
17
16
  logger = logging.getLogger(__name__)
@@ -169,13 +168,13 @@ class PaymeWebHookAPIView(views.APIView):
169
168
  defaults = {
170
169
  "amount": amount,
171
170
  "state": PaymeTransactions.INITIATING,
172
- "account": account,
171
+ "account_id": account.id,
173
172
  }
174
173
 
175
174
  # Handle already existing transaction with the same ID for one-time payments
176
175
  if settings.PAYME_ONE_TIME_PAYMENT:
177
176
  # Check for an existing transaction with a different transaction_id for the given account
178
- if PaymeTransactions.objects.filter(account=account).exclude(transaction_id=transaction_id).exists():
177
+ if PaymeTransactions.objects.filter(account_id=account.id).exclude(transaction_id=transaction_id).exists():
179
178
  message = f"Transaction {transaction_id} already exists (Payme)."
180
179
  logger.warning(message)
181
180
  raise exceptions.TransactionAlreadyExists(message)
@@ -290,7 +289,7 @@ class PaymeWebHookAPIView(views.APIView):
290
289
  "transaction": transaction.transaction_id,
291
290
  "amount": transaction.amount,
292
291
  "account": {
293
- settings.PAYME_ACCOUNT_FIELD: transaction.account.id
292
+ settings.PAYME_ACCOUNT_FIELD: transaction.account_id
294
293
  },
295
294
  "reason": transaction.cancel_reason,
296
295
  "state": transaction.state,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: payme-pkg
3
- Version: 3.0.19
3
+ Version: 3.0.21
4
4
  Home-page: https://github.com/Muhammadali-Akbarov/payme-pkg
5
5
  Author: Muhammadali Akbarov
6
6
  Author-email: muhammadali17abc@gmail.com
@@ -139,7 +139,7 @@ urlpatterns = [
139
139
 
140
140
  Run migrations
141
141
  ```shell
142
- python3 manage.py makemigrations && python manage.py migrate
142
+ python manage.py migrate
143
143
  ```
144
144
  🎉 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.
145
145
 
@@ -1,20 +1,21 @@
1
1
  payme/__init__.py,sha256=dzLIyA9kQl0sO6z9nHkZDTjkfiI1BepdifKtJbjX2Cw,46
2
- payme/admin.py,sha256=67uHZiZe2w2s0TE23PS2v-V3xXRaha6o9acjVmNIQbM,470
2
+ payme/admin.py,sha256=QW93VTNRZ3qr2eMySX0odyQDmBXJDMXVPCzJPLH78GI,468
3
3
  payme/apps.py,sha256=HHCY4zUNKPcjz25z0MahZcks0lsAxTGPS0Ml3U4DhZc,142
4
4
  payme/const.py,sha256=azndfKR53fe7mDfGW82Q-kwWdMu3x4S1upKc4gkYdlA,214
5
- payme/models.py,sha256=mT6sIeDOs-pKZ_b8Y9oafHBv5GruioJkpTqTGZ8AulA,4360
5
+ payme/models.py,sha256=C0-dbXEpzZBx1-GsdBXwKQt7gJ6AvgPO6l-3VljfNtw,4130
6
6
  payme/urls.py,sha256=_oUOwxW1Suc5TUmnj--lySYbotRg4yTDkDLJU20CGjE,145
7
7
  payme/util.py,sha256=UFb4cEnaufS_hh9C_0z079CSgJGivYjIgOl2iAFrBMs,625
8
- payme/views.py,sha256=A5_GxSFS1Hif2W1LAGP5YfnGazdaaqLXgFLEy2z0A7k,11928
8
+ payme/views.py,sha256=AYWXP9zJGcLkTM91RIiL6Ou4RHqLph3NyYIlzPAN3fU,11939
9
9
  payme/classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  payme/classes/cards.py,sha256=dr3SQdKAhfQmECtwHYW2nmx8wXaNYQFkg5uQU9z8vs4,7624
11
- payme/classes/client.py,sha256=_eMcSTiwMdwIe0aeccVav-43Uq7ORdH7idOuSTPjpcg,837
11
+ payme/classes/client.py,sha256=Fjck3vSRh8-NQ8HnxwytCn_qZm6UfwMKCBYDHtUSJAs,864
12
12
  payme/classes/http.py,sha256=OufMeHrj0jTomDJx_6go9GC1NtA6QpQCxIiM3ISy3Eo,3530
13
- payme/classes/initializer.py,sha256=FvzKp068JfSzHwcQ_w-eXYTomV5ggz7_p5zYBkAtBI4,2326
13
+ payme/classes/initializer.py,sha256=TWJnlJTXefROMleIvJeT64xjIVWQU-LIXai8TZ_M7nw,2488
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
17
  payme/exceptions/webhook.py,sha256=f0J-fmCW_wpgsTmjGAOtyoZjIOoFpbQwkh_7cZUZkv0,3046
18
+ payme/migrations/0001_initial.py,sha256=jdtGB6bN-Za6N9XU8IuWsa5FbonGIRH5ro9xHwT7JmU,2128
18
19
  payme/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
20
  payme/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
21
  payme/types/request/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -22,8 +23,8 @@ payme/types/response/__init__.py,sha256=GAj5pjZ9oIO67T6YMiPd1fhTIvGrPfTv96tykfeC
22
23
  payme/types/response/cards.py,sha256=ilXFDUOPNabVsrQN1KWEzDiL6cDxdVvCbfEl6jCzGpU,1997
23
24
  payme/types/response/receipts.py,sha256=TlZeJyymRVHIorg0kbUaogy6MZxN1oq2jHGVRUnlY5A,4070
24
25
  payme/types/response/webhook.py,sha256=Br6Gr_-h7sCmOc3ag7H5yBryB8j-bm2mrt39Cy_Fy2E,2918
25
- payme_pkg-3.0.19.dist-info/LICENSE.txt,sha256=75dBVYmbzWUhwtaB1MSZfj-M-PGaMmeT9UVPli2-ZJ0,1086
26
- payme_pkg-3.0.19.dist-info/METADATA,sha256=ufH7t3XvVaM7oLSFSHv_oXQ663wygOaOVD64eiOWDqY,5534
27
- payme_pkg-3.0.19.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
28
- payme_pkg-3.0.19.dist-info/top_level.txt,sha256=8mN-hGAa38pWbhrKHFs9CZywPCdidhMuwPKwuFJa0qw,6
29
- payme_pkg-3.0.19.dist-info/RECORD,,
26
+ payme_pkg-3.0.21.dist-info/LICENSE.txt,sha256=75dBVYmbzWUhwtaB1MSZfj-M-PGaMmeT9UVPli2-ZJ0,1086
27
+ payme_pkg-3.0.21.dist-info/METADATA,sha256=w4d4I6ZYrEGvAFxwJC0jMDSdkk05F-fQ0SWboGSxjoI,5498
28
+ payme_pkg-3.0.21.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
29
+ payme_pkg-3.0.21.dist-info/top_level.txt,sha256=8mN-hGAa38pWbhrKHFs9CZywPCdidhMuwPKwuFJa0qw,6
30
+ payme_pkg-3.0.21.dist-info/RECORD,,