paytechuz 0.2.20__py3-none-any.whl → 0.2.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 paytechuz might be problematic. Click here for more details.

@@ -989,42 +989,47 @@ class ClickWebhookHandler:
989
989
  """
990
990
  Check authentication using signature.
991
991
  """
992
- if str(params.get('service_id')) != self.service_id:
992
+ if not all([self.service_id, self.secret_key]):
993
993
  raise HTTPException(
994
994
  status_code=status.HTTP_401_UNAUTHORIZED,
995
- detail="Invalid service ID"
995
+ detail="Missing required settings: service_id or secret_key"
996
996
  )
997
997
 
998
- # Check signature if secret key is provided
999
- if self.secret_key:
1000
- sign_string = params.get('sign_string')
1001
- sign_time = params.get('sign_time')
998
+ if str(params.get("service_id")) != self.service_id:
999
+ raise HTTPException(
1000
+ status_code=status.HTTP_401_UNAUTHORIZED,
1001
+ detail="Invalid service ID"
1002
+ )
1002
1003
 
1003
- if not sign_string or not sign_time:
1004
- raise HTTPException(
1005
- status_code=status.HTTP_401_UNAUTHORIZED,
1006
- detail="Missing signature parameters"
1007
- )
1004
+ sign_string = params.get("sign_string")
1005
+ sign_time = params.get("sign_time")
1008
1006
 
1009
- # Create string to sign
1010
- to_sign = (
1011
- f"{params.get('click_trans_id')}"
1012
- f"{params.get('service_id')}"
1013
- f"{self.secret_key}"
1014
- f"{params.get('merchant_trans_id')}"
1015
- f"{params.get('amount')}"
1016
- f"{params.get('action')}"
1017
- f"{sign_time}"
1007
+ if not sign_string or not sign_time:
1008
+ raise HTTPException(
1009
+ status_code=status.HTTP_401_UNAUTHORIZED,
1010
+ detail="Missing signature parameters"
1018
1011
  )
1019
1012
 
1020
- # Generate signature
1021
- signature = hashlib.md5(to_sign.encode('utf-8')).hexdigest()
1013
+ # Prepare signature components
1014
+ text_parts = [
1015
+ str(params.get("click_trans_id") or ""),
1016
+ str(params.get("service_id") or ""),
1017
+ str(self.secret_key or ""),
1018
+ str(params.get("merchant_trans_id") or ""),
1019
+ str(params.get("merchant_prepare_id") or ""),
1020
+ str(params.get("amount") or ""),
1021
+ str(params.get("action") or ""),
1022
+ str(sign_time)
1023
+ ]
1024
+
1025
+ # Calculate hash
1026
+ calculated_hash = hashlib.md5("".join(text_parts).encode("utf-8")).hexdigest()
1022
1027
 
1023
- if signature != sign_string:
1024
- raise HTTPException(
1025
- status_code=status.HTTP_401_UNAUTHORIZED,
1026
- detail="Invalid signature"
1027
- )
1028
+ if calculated_hash != sign_string:
1029
+ raise HTTPException(
1030
+ status_code=status.HTTP_401_UNAUTHORIZED,
1031
+ detail="Invalid signature"
1032
+ )
1028
1033
 
1029
1034
  def _find_account(self, merchant_trans_id: str) -> Any:
1030
1035
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: paytechuz
3
- Version: 0.2.20
3
+ Version: 0.2.21
4
4
  Summary: Unified Python package for Uzbekistan payment gateways
5
5
  Home-page: https://github.com/Muhammadali-Akbarov/paytechuz
6
6
  Author: Muhammadali Akbarov
@@ -59,9 +59,9 @@ paytechuz/integrations/django/migrations/0001_initial.py,sha256=SWHIUuwq91crzaxa
59
59
  paytechuz/integrations/django/migrations/__init__.py,sha256=KLQ5NdjOMLDS21-u3b_g08G1MjPMMhG95XI_N8m4FSo,41
60
60
  paytechuz/integrations/fastapi/__init__.py,sha256=DLnhAZQZf2ghu8BuFFfE7FzbNKWQQ2SLG8qxldRuwR4,565
61
61
  paytechuz/integrations/fastapi/models.py,sha256=9IqrsndIVuIDwDbijZ89biJxEWQASXRBfWVShxgerAc,5113
62
- paytechuz/integrations/fastapi/routes.py,sha256=61jsHsgGJZ_-ISfG2J1MSOCqIOLQ18C1boc9MVddkvg,37652
62
+ paytechuz/integrations/fastapi/routes.py,sha256=t8zbqhMZsaJmEvMDgmF-NoRmbqksfX_AvIrx-3kCjg8,37845
63
63
  paytechuz/integrations/fastapi/schemas.py,sha256=PgRqviJiD4-u3_CIkUOX8R7L8Yqn8L44WLte7968G0E,3887
64
- paytechuz-0.2.20.dist-info/METADATA,sha256=_MGqOZihEdgBfy_F3IWzM5uSbYS6KMiNJHaqIQH1Bkk,11464
65
- paytechuz-0.2.20.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
66
- paytechuz-0.2.20.dist-info/top_level.txt,sha256=v03IobsNVIGSgCareObqCsEwLgXOpwBvBTWy3y8-G_M,37
67
- paytechuz-0.2.20.dist-info/RECORD,,
64
+ paytechuz-0.2.21.dist-info/METADATA,sha256=dHA9NdyvhNtzp8F0V7gmF8KC75OauwM_Yyy9cd8PRjw,11464
65
+ paytechuz-0.2.21.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
66
+ paytechuz-0.2.21.dist-info/top_level.txt,sha256=v03IobsNVIGSgCareObqCsEwLgXOpwBvBTWy3y8-G_M,37
67
+ paytechuz-0.2.21.dist-info/RECORD,,