paytechuz 0.1.4__py3-none-any.whl → 0.2.0__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.

Files changed (40) hide show
  1. paytechuz/__init__.py +57 -0
  2. {core → paytechuz/core}/http.py +1 -1
  3. {core → paytechuz/core}/utils.py +1 -1
  4. paytechuz/gateways/click/__init__.py +2 -0
  5. {gateways → paytechuz/gateways}/click/client.py +8 -7
  6. paytechuz/gateways/payme/__init__.py +2 -0
  7. {gateways → paytechuz/gateways}/payme/client.py +2 -2
  8. {paytechuz-0.1.4.dist-info → paytechuz-0.2.0.dist-info}/METADATA +20 -9
  9. paytechuz-0.2.0.dist-info/RECORD +36 -0
  10. paytechuz-0.2.0.dist-info/top_level.txt +1 -0
  11. gateways/payme/__init__.py +0 -0
  12. integrations/__init__.py +0 -0
  13. paytechuz-0.1.4.dist-info/RECORD +0 -35
  14. paytechuz-0.1.4.dist-info/top_level.txt +0 -3
  15. {core → paytechuz/core}/__init__.py +0 -0
  16. {core → paytechuz/core}/base.py +0 -0
  17. {core → paytechuz/core}/constants.py +0 -0
  18. {core → paytechuz/core}/exceptions.py +0 -0
  19. {core → paytechuz/core}/payme/errors.py +0 -0
  20. {gateways → paytechuz/gateways}/__init__.py +0 -0
  21. {gateways → paytechuz/gateways}/click/merchant.py +0 -0
  22. {gateways → paytechuz/gateways}/click/webhook.py +0 -0
  23. {gateways → paytechuz/gateways}/payme/cards.py +0 -0
  24. {gateways → paytechuz/gateways}/payme/receipts.py +0 -0
  25. {gateways → paytechuz/gateways}/payme/webhook.py +0 -0
  26. {gateways/click → paytechuz/integrations}/__init__.py +0 -0
  27. {integrations → paytechuz/integrations}/django/__init__.py +0 -0
  28. {integrations → paytechuz/integrations}/django/admin.py +0 -0
  29. {integrations → paytechuz/integrations}/django/apps.py +0 -0
  30. {integrations → paytechuz/integrations}/django/migrations/0001_initial.py +0 -0
  31. {integrations → paytechuz/integrations}/django/migrations/__init__.py +0 -0
  32. {integrations → paytechuz/integrations}/django/models.py +0 -0
  33. {integrations → paytechuz/integrations}/django/signals.py +0 -0
  34. {integrations → paytechuz/integrations}/django/views.py +0 -0
  35. {integrations → paytechuz/integrations}/django/webhooks.py +0 -0
  36. {integrations → paytechuz/integrations}/fastapi/__init__.py +0 -0
  37. {integrations → paytechuz/integrations}/fastapi/models.py +0 -0
  38. {integrations → paytechuz/integrations}/fastapi/routes.py +0 -0
  39. {integrations → paytechuz/integrations}/fastapi/schemas.py +0 -0
  40. {paytechuz-0.1.4.dist-info → paytechuz-0.2.0.dist-info}/WHEEL +0 -0
paytechuz/__init__.py ADDED
@@ -0,0 +1,57 @@
1
+ """
2
+ PayTechUZ - Unified payment library for Uzbekistan payment systems.
3
+
4
+ This library provides a unified interface for working with Payme and Click
5
+ payment systems in Uzbekistan. It supports Django, Flask, and FastAPI.
6
+ """
7
+ from typing import Any
8
+
9
+ __version__ = '0.2.0-beta'
10
+
11
+ # Import framework integrations - these imports are used to check availability
12
+ # of frameworks, not for direct usage
13
+ try:
14
+ import django # noqa: F401 - Used for availability check
15
+ HAS_DJANGO = True
16
+ except ImportError:
17
+ HAS_DJANGO = False
18
+
19
+ try:
20
+ import fastapi # noqa: F401 - Used for availability check
21
+ HAS_FASTAPI = True
22
+ except ImportError:
23
+ HAS_FASTAPI = False
24
+
25
+ try:
26
+ import flask # noqa: F401 - Used for availability check
27
+ HAS_FLASK = True
28
+ except ImportError:
29
+ HAS_FLASK = False
30
+
31
+ from paytechuz.core.base import BasePaymentGateway # noqa: E402
32
+ from paytechuz.gateways.payme.client import PaymeGateway # noqa: E402
33
+ from paytechuz.gateways.click.client import ClickGateway # noqa: E402
34
+ from paytechuz.core.constants import PaymentGateway # noqa: E402
35
+
36
+
37
+ def create_gateway(gateway_type: str, **kwargs) -> BasePaymentGateway:
38
+ """
39
+ Create a payment gateway instance.
40
+
41
+ Args:
42
+ gateway_type: Type of gateway ('payme' or 'click')
43
+ **kwargs: Gateway-specific configuration
44
+
45
+ Returns:
46
+ Payment gateway instance
47
+
48
+ Raises:
49
+ ValueError: If the gateway type is not supported
50
+ ImportError: If the required gateway module is not available
51
+ """
52
+ if gateway_type.lower() == PaymentGateway.PAYME.value:
53
+ return PaymeGateway(**kwargs)
54
+ if gateway_type.lower() == PaymentGateway.CLICK.value:
55
+ return ClickGateway(**kwargs)
56
+
57
+ raise ValueError(f"Unsupported gateway type: {gateway_type}")
@@ -8,7 +8,7 @@ from typing import Dict, Any, Optional, Union, List
8
8
  import requests
9
9
  from requests.exceptions import RequestException, Timeout, ConnectionError
10
10
 
11
- from paytechuz.core.exceptions import (
11
+ from .exceptions import (
12
12
  ExternalServiceError,
13
13
  TimeoutError as PaymentTimeoutError,
14
14
  InternalServiceError
@@ -157,7 +157,7 @@ def handle_exceptions(func):
157
157
  Returns:
158
158
  Decorated function
159
159
  """
160
- from paytechuz.core.exceptions import (
160
+ from .exceptions import (
161
161
  InternalServiceError,
162
162
  exception_whitelist
163
163
  )
@@ -0,0 +1,2 @@
1
+ """Click payment gateway implementation."""
2
+ from .client import ClickGateway # noqa: F401
@@ -8,16 +8,17 @@ from paytechuz.core.base import BasePaymentGateway
8
8
  from paytechuz.core.http import HttpClient
9
9
  from paytechuz.core.constants import ClickNetworks
10
10
  from paytechuz.core.utils import format_amount, handle_exceptions
11
- from paytechuz.gateways.click.merchant import ClickMerchantApi
11
+ from .merchant import ClickMerchantApi
12
12
 
13
13
  logger = logging.getLogger(__name__)
14
14
 
15
+
15
16
  class ClickGateway(BasePaymentGateway):
16
17
  """
17
18
  Click payment gateway implementation.
18
19
 
19
20
  This class provides methods for interacting with the Click payment gateway,
20
- including creating payments, checking payment status, and canceling payments.
21
+ including creating payments, checking payment status, and canceling payments. # noqa
21
22
  """
22
23
 
23
24
  def __init__(
@@ -45,7 +46,7 @@ class ClickGateway(BasePaymentGateway):
45
46
  self.secret_key = secret_key
46
47
 
47
48
  # Set the API URL based on the environment
48
- url = ClickNetworks.TEST_NET if is_test_mode else ClickNetworks.PROD_NET
49
+ url = ClickNetworks.TEST_NET if is_test_mode else ClickNetworks.PROD_NET # noqa
49
50
 
50
51
  # Initialize HTTP client
51
52
  self.http_client = HttpClient(base_url=url)
@@ -80,13 +81,13 @@ class ClickGateway(BasePaymentGateway):
80
81
  - email: Customer email
81
82
 
82
83
  Returns:
83
- Dict containing payment details including transaction ID and payment URL
84
+ Dict containing payment details including transaction ID and payment URL # noqa
84
85
  """
85
86
  # Format amount to tiyin (1 som = 100 tiyin)
86
87
  amount_tiyin = format_amount(amount)
87
88
 
88
89
  # Extract additional parameters
89
- description = kwargs.get('description', f'Payment for account {account_id}')
90
+ description = kwargs.get('description', f'Payment for account {account_id}') # noqa
90
91
  return_url = kwargs.get('return_url')
91
92
  callback_url = kwargs.get('callback_url')
92
93
  # These parameters are not used in the URL but are available in the API
@@ -138,7 +139,7 @@ class ClickGateway(BasePaymentGateway):
138
139
  # Format: click_account_id_amount
139
140
  parts = transaction_id.split('_')
140
141
  if len(parts) < 3 or parts[0] != 'click':
141
- raise ValueError(f"Invalid transaction ID format: {transaction_id}")
142
+ raise ValueError(f"Invalid transaction ID format: {transaction_id}") # noqa
142
143
 
143
144
  account_id = parts[1]
144
145
 
@@ -187,7 +188,7 @@ class ClickGateway(BasePaymentGateway):
187
188
  # Format: click_account_id_amount
188
189
  parts = transaction_id.split('_')
189
190
  if len(parts) < 3 or parts[0] != 'click':
190
- raise ValueError(f"Invalid transaction ID format: {transaction_id}")
191
+ raise ValueError(f"Invalid transaction ID format: {transaction_id}") # noqa
191
192
 
192
193
  account_id = parts[1]
193
194
 
@@ -0,0 +1,2 @@
1
+ """Payme payment gateway implementation."""
2
+ from .client import PaymeGateway # noqa: F401
@@ -9,8 +9,8 @@ from paytechuz.core.base import BasePaymentGateway
9
9
  from paytechuz.core.http import HttpClient
10
10
  from paytechuz.core.constants import PaymeNetworks
11
11
  from paytechuz.core.utils import format_amount, handle_exceptions
12
- from paytechuz.gateways.payme.cards import PaymeCards
13
- from paytechuz.gateways.payme.receipts import PaymeReceipts
12
+ from .cards import PaymeCards
13
+ from .receipts import PaymeReceipts
14
14
 
15
15
  logger = logging.getLogger(__name__)
16
16
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: paytechuz
3
- Version: 0.1.4
3
+ Version: 0.2.0
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
@@ -41,23 +41,34 @@ pip install paytechuz[fastapi]
41
41
  ### Generate Payment Links
42
42
 
43
43
  ```python
44
- from paytechuz.gateways.payme import PaymeGateway
45
- from paytechuz.gateways.click import ClickGateway
44
+ from paytechuz import create_gateway, PaymentGateway
46
45
 
47
46
  # Initialize gateways
48
- payme = PaymeGateway()
49
- click = ClickGateway()
47
+ payme = create_gateway(PaymentGateway.PAYME.value,
48
+ payme_id="your_payme_id",
49
+ payme_key="your_payme_key",
50
+ is_test_mode=True
51
+ )
52
+
53
+ click = create_gateway(PaymentGateway.CLICK.value,
54
+ service_id="your_service_id",
55
+ merchant_id="your_merchant_id",
56
+ merchant_user_id="your_merchant_user_id",
57
+ secret_key="your_secret_key",
58
+ is_test_mode=True
59
+ )
50
60
 
51
61
  # Generate payment links
52
- payme_link = payme.generate_payment_link(
62
+ payme_link = payme.create_payment(
53
63
  id="order_123",
54
64
  amount=150000, # amount in UZS
55
65
  return_url="https://example.com/return"
56
66
  )
57
67
 
58
- click_link = click.generate_payment_link(
59
- id="order_123",
68
+ click_link = click.create_payment(
60
69
  amount=150000, # amount in UZS
70
+ account_id="order_123",
71
+ description="Test payment",
61
72
  return_url="https://example.com/return"
62
73
  )
63
74
  ```
@@ -99,7 +110,7 @@ class PaymeWebhookView(PaymeWebhookView):
99
110
  order = Order.objects.get(id=transaction.account_id)
100
111
  order.status = 'paid'
101
112
  order.save()
102
-
113
+
103
114
  def cancelled_payment(self, params, transaction):
104
115
  order = Order.objects.get(id=transaction.account_id)
105
116
  order.status = 'cancelled'
@@ -0,0 +1,36 @@
1
+ paytechuz/__init__.py,sha256=N7ORpNWx0QjT5ShnYNJXj5ph-EXTQN3629vzFOwNaUE,1758
2
+ paytechuz/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ paytechuz/core/base.py,sha256=pW_0QrlyX0F8XVToeeDEI78ygAF2IgvvvyUGYMHH9bs,2565
4
+ paytechuz/core/constants.py,sha256=P2zeZ_cfZIttdC1vqkpIngkfRFh6loWzJYEgzQb5cKA,1660
5
+ paytechuz/core/exceptions.py,sha256=XMJkqiponTkvhjoh3S2iFNuU3UbBdFW4130kd0hpudg,5489
6
+ paytechuz/core/http.py,sha256=1PFv_Fo62GtfyYKUK2nsT4AaeQNuMgZlFUFL1q9p2MI,7672
7
+ paytechuz/core/utils.py,sha256=EbNtDweR1ABOtCu4D6cYlolM0t_fbiE3gNoc_qfcKKA,4704
8
+ paytechuz/core/payme/errors.py,sha256=CZE62MbYDMsRfNIX23Syt6of_tPMMGLnXhYMii4hw3A,542
9
+ paytechuz/gateways/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ paytechuz/gateways/click/__init__.py,sha256=35RPIrZYHgMWDzxjQkJMZYjzHDa8cY_BqQztCdZZmBM,90
11
+ paytechuz/gateways/click/client.py,sha256=NC9bHP2A_9ZagE1G4OBrckvefLhyALzs76tzKoc6x8U,6682
12
+ paytechuz/gateways/click/merchant.py,sha256=vJ_DivA1KfRT5p3sfA5yZGMYXoUmVbAM7QHvaXr6VCU,7254
13
+ paytechuz/gateways/click/webhook.py,sha256=rph-NmjjnBKMW4rcxQTXrHHdK-uMrU39kXnbqK56leo,7936
14
+ paytechuz/gateways/payme/__init__.py,sha256=KcVkYvAEblL4ASVAOrUofRBwywAkTZIgRXoBaCbYtv8,90
15
+ paytechuz/gateways/payme/cards.py,sha256=aL6su_ZTCBPU8qmrz2Jcw_Wn7Zf9RwIu8k10o4AWFTs,5420
16
+ paytechuz/gateways/payme/client.py,sha256=TitVYANv3S5VmD4ztShY0mRv4EbVLMvTiBeKJnvOzwI,7807
17
+ paytechuz/gateways/payme/receipts.py,sha256=DdrZMPeDvQmGyqAEOTmtUorfcIVVb3t2tg31l7TXqHo,8904
18
+ paytechuz/gateways/payme/webhook.py,sha256=-0O8vzMtiu4U8FWFKDA6EfyoX4NEGqcEq-T0yNtVhM4,12374
19
+ paytechuz/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ paytechuz/integrations/django/__init__.py,sha256=YDgD1Ux1E3CJxQMT-9tulhXmuLOEaUSv320LeaVgJ00,116
21
+ paytechuz/integrations/django/admin.py,sha256=6fs6GiKcdc-hGlLxJ0BthY7TFo_2RVVJRhQwhxMroCY,2664
22
+ paytechuz/integrations/django/apps.py,sha256=57svd2aqSuoASWMI3Jnh70ZXrYN1oQ8EnvLl_5LNyl0,473
23
+ paytechuz/integrations/django/models.py,sha256=83PjBnombavEjfPm2EcVFo2R5BO6VRIjp0MlNCp-fbg,5819
24
+ paytechuz/integrations/django/signals.py,sha256=VtNYEAnu13wi9PqadEaCU9LY_k2tY26AS4bnPIAqw7M,1319
25
+ paytechuz/integrations/django/views.py,sha256=nP2HRMx02tMbdv_KfDqIA5vQAwZ6TUuZazrZ2zoNfqQ,3029
26
+ paytechuz/integrations/django/webhooks.py,sha256=cP_Jc3VlyyvyzDbBd2yEVHikw60th1_-L9_vtsRfwgs,31335
27
+ paytechuz/integrations/django/migrations/0001_initial.py,sha256=YLDUp1w0V3Zvuz5TssQDrx3PlccduoHqdLD109Hg8Z4,2326
28
+ paytechuz/integrations/django/migrations/__init__.py,sha256=KLQ5NdjOMLDS21-u3b_g08G1MjPMMhG95XI_N8m4FSo,41
29
+ paytechuz/integrations/fastapi/__init__.py,sha256=DLnhAZQZf2ghu8BuFFfE7FzbNKWQQ2SLG8qxldRuwR4,565
30
+ paytechuz/integrations/fastapi/models.py,sha256=eWGUpiKufj47AK8Hld4A91jRDj0ZKQzAf95CyUozmvo,4638
31
+ paytechuz/integrations/fastapi/routes.py,sha256=D17QeyY4-aX6tCNmk5h3UiavukvVrE5e6JOFCy4t_n8,36629
32
+ paytechuz/integrations/fastapi/schemas.py,sha256=CkNohj22mQQje8Pu_IkTQwUPAoYHNOKXlGjqaRX_SGQ,3784
33
+ paytechuz-0.2.0.dist-info/METADATA,sha256=PLlxhhK3dKrjJKzHb8KJONhgJdKKWiSC43Ud1mQ-ht0,4149
34
+ paytechuz-0.2.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
35
+ paytechuz-0.2.0.dist-info/top_level.txt,sha256=oloyKGNVj9Z2h3wpKG5yPyTlpdpWW0-CWr-j-asCWBc,10
36
+ paytechuz-0.2.0.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ paytechuz
File without changes
integrations/__init__.py DELETED
File without changes
@@ -1,35 +0,0 @@
1
- core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- core/base.py,sha256=pW_0QrlyX0F8XVToeeDEI78ygAF2IgvvvyUGYMHH9bs,2565
3
- core/constants.py,sha256=P2zeZ_cfZIttdC1vqkpIngkfRFh6loWzJYEgzQb5cKA,1660
4
- core/exceptions.py,sha256=XMJkqiponTkvhjoh3S2iFNuU3UbBdFW4130kd0hpudg,5489
5
- core/http.py,sha256=qmLR6ujxmIPjwoTS4vvKRIvDnNcpl84sS1HmVB890b0,7686
6
- core/utils.py,sha256=ETHMzwu7_dirc-QfBUjpSTQmyS6_vBiNq97Dq9CNZto,4718
7
- core/payme/errors.py,sha256=CZE62MbYDMsRfNIX23Syt6of_tPMMGLnXhYMii4hw3A,542
8
- gateways/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- gateways/click/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- gateways/click/client.py,sha256=XTri3iogq4_MgvZehBK2CScVCMubvg1GNXV9whGAS6I,6663
11
- gateways/click/merchant.py,sha256=vJ_DivA1KfRT5p3sfA5yZGMYXoUmVbAM7QHvaXr6VCU,7254
12
- gateways/click/webhook.py,sha256=rph-NmjjnBKMW4rcxQTXrHHdK-uMrU39kXnbqK56leo,7936
13
- gateways/payme/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- gateways/payme/cards.py,sha256=aL6su_ZTCBPU8qmrz2Jcw_Wn7Zf9RwIu8k10o4AWFTs,5420
15
- gateways/payme/client.py,sha256=B4jxjX_7J_uR-NP8-B6wO_VrnwO_RRh1ATiKsO4ZinM,7855
16
- gateways/payme/receipts.py,sha256=DdrZMPeDvQmGyqAEOTmtUorfcIVVb3t2tg31l7TXqHo,8904
17
- gateways/payme/webhook.py,sha256=-0O8vzMtiu4U8FWFKDA6EfyoX4NEGqcEq-T0yNtVhM4,12374
18
- integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- integrations/django/__init__.py,sha256=YDgD1Ux1E3CJxQMT-9tulhXmuLOEaUSv320LeaVgJ00,116
20
- integrations/django/admin.py,sha256=6fs6GiKcdc-hGlLxJ0BthY7TFo_2RVVJRhQwhxMroCY,2664
21
- integrations/django/apps.py,sha256=57svd2aqSuoASWMI3Jnh70ZXrYN1oQ8EnvLl_5LNyl0,473
22
- integrations/django/models.py,sha256=83PjBnombavEjfPm2EcVFo2R5BO6VRIjp0MlNCp-fbg,5819
23
- integrations/django/signals.py,sha256=VtNYEAnu13wi9PqadEaCU9LY_k2tY26AS4bnPIAqw7M,1319
24
- integrations/django/views.py,sha256=nP2HRMx02tMbdv_KfDqIA5vQAwZ6TUuZazrZ2zoNfqQ,3029
25
- integrations/django/webhooks.py,sha256=cP_Jc3VlyyvyzDbBd2yEVHikw60th1_-L9_vtsRfwgs,31335
26
- integrations/django/migrations/0001_initial.py,sha256=YLDUp1w0V3Zvuz5TssQDrx3PlccduoHqdLD109Hg8Z4,2326
27
- integrations/django/migrations/__init__.py,sha256=KLQ5NdjOMLDS21-u3b_g08G1MjPMMhG95XI_N8m4FSo,41
28
- integrations/fastapi/__init__.py,sha256=DLnhAZQZf2ghu8BuFFfE7FzbNKWQQ2SLG8qxldRuwR4,565
29
- integrations/fastapi/models.py,sha256=eWGUpiKufj47AK8Hld4A91jRDj0ZKQzAf95CyUozmvo,4638
30
- integrations/fastapi/routes.py,sha256=D17QeyY4-aX6tCNmk5h3UiavukvVrE5e6JOFCy4t_n8,36629
31
- integrations/fastapi/schemas.py,sha256=CkNohj22mQQje8Pu_IkTQwUPAoYHNOKXlGjqaRX_SGQ,3784
32
- paytechuz-0.1.4.dist-info/METADATA,sha256=4QSapmW-hD_4AJm0rE-OvnXIhRRgsePVnsX6UKczfh4,3861
33
- paytechuz-0.1.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
34
- paytechuz-0.1.4.dist-info/top_level.txt,sha256=tfgxeqY7QDfOFb07FwoMkscdgKV9VIbJLnJnh2FNjRM,27
35
- paytechuz-0.1.4.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- core
2
- gateways
3
- integrations
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes