paytechuz 0.3.0__py3-none-any.whl → 0.3.2__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.
- paytechuz/__init__.py +1 -2
- paytechuz/integrations/django/models.py +6 -0
- paytechuz/integrations/django/webhooks.py +8 -2
- {paytechuz-0.3.0.dist-info → paytechuz-0.3.2.dist-info}/METADATA +1 -93
- {paytechuz-0.3.0.dist-info → paytechuz-0.3.2.dist-info}/RECORD +7 -7
- {paytechuz-0.3.0.dist-info → paytechuz-0.3.2.dist-info}/WHEEL +0 -0
- {paytechuz-0.3.0.dist-info → paytechuz-0.3.2.dist-info}/top_level.txt +0 -0
paytechuz/__init__.py
CHANGED
|
@@ -4,9 +4,8 @@ PayTechUZ - Unified payment library for Uzbekistan payment systems.
|
|
|
4
4
|
This library provides a unified interface for working with Payme, Click, and Atmos
|
|
5
5
|
payment systems in Uzbekistan. It supports Django, Flask, and FastAPI.
|
|
6
6
|
"""
|
|
7
|
-
from typing import Any
|
|
8
7
|
|
|
9
|
-
__version__ = '0.3.
|
|
8
|
+
__version__ = '0.3.2'
|
|
10
9
|
|
|
11
10
|
# Import framework integrations - these imports are used to check availability
|
|
12
11
|
# of frameworks, not for direct usage
|
|
@@ -73,6 +73,12 @@ class PaymentTransaction(models.Model):
|
|
|
73
73
|
self.save()
|
|
74
74
|
return self
|
|
75
75
|
|
|
76
|
+
def mark_as_cancelled_during_init(self, reason):
|
|
77
|
+
self.state = self.CANCELLED_DURING_INIT
|
|
78
|
+
self.cancelled_at = timezone.now()
|
|
79
|
+
self.reason = reason
|
|
80
|
+
self.save()
|
|
81
|
+
|
|
76
82
|
def mark_as_cancelled(self, reason=None):
|
|
77
83
|
"""
|
|
78
84
|
Mark the transaction as cancelled.
|
|
@@ -434,13 +434,19 @@ class PaymeWebhook(View):
|
|
|
434
434
|
f"Transaction {transaction_id} not found"
|
|
435
435
|
) from None
|
|
436
436
|
|
|
437
|
+
print(transaction.state, reason)
|
|
438
|
+
|
|
437
439
|
# Check if transaction is already cancelled
|
|
438
440
|
if transaction.state == PaymentTransaction.CANCELLED:
|
|
439
441
|
# If transaction is already cancelled, return the existing data
|
|
440
442
|
return self._cancel_response(transaction)
|
|
441
443
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
+
if transaction.state == PaymentTransaction.INITIATING:
|
|
445
|
+
transaction.mark_as_cancelled_during_init(reason=reason)
|
|
446
|
+
|
|
447
|
+
else:
|
|
448
|
+
# Use the mark_as_cancelled method to properly store the reason
|
|
449
|
+
transaction.mark_as_cancelled(reason=reason)
|
|
444
450
|
|
|
445
451
|
# Call the event method
|
|
446
452
|
self.cancelled_payment(params, transaction)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: paytechuz
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Unified Python package for Uzbekistan payment gateways (Payme, Click, Atmos)
|
|
5
5
|
Home-page: https://github.com/Muhammadali-Akbarov/paytechuz
|
|
6
6
|
Author: Muhammadali Akbarov
|
|
@@ -119,98 +119,6 @@ if status['status'] == 'pending':
|
|
|
119
119
|
print(f"Cancellation status: {cancel_result['status']}")
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
### Complete Atmos Integration Example
|
|
123
|
-
|
|
124
|
-
```python
|
|
125
|
-
from paytechuz.gateways.atmos import AtmosGateway
|
|
126
|
-
from paytechuz.gateways.atmos.webhook import AtmosWebhookHandler
|
|
127
|
-
|
|
128
|
-
# 1. Initialize Atmos Gateway
|
|
129
|
-
atmos = AtmosGateway(
|
|
130
|
-
consumer_key="your_consumer_key",
|
|
131
|
-
consumer_secret="your_consumer_secret",
|
|
132
|
-
store_id="your_store_id",
|
|
133
|
-
terminal_id="your_terminal_id", # optional
|
|
134
|
-
is_test_mode=True
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
# 2. Create payment
|
|
138
|
-
def create_atmos_payment(order_id, amount):
|
|
139
|
-
try:
|
|
140
|
-
payment = atmos.create_payment(
|
|
141
|
-
account_id=order_id,
|
|
142
|
-
amount=amount
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
print(f"✅ Payment created successfully!")
|
|
146
|
-
print(f"Transaction ID: {payment['transaction_id']}")
|
|
147
|
-
print(f"Payment URL: {payment['payment_url']}")
|
|
148
|
-
print(f"Redirect user to: {payment['payment_url']}")
|
|
149
|
-
|
|
150
|
-
return payment
|
|
151
|
-
|
|
152
|
-
except Exception as e:
|
|
153
|
-
print(f"❌ Payment creation failed: {e}")
|
|
154
|
-
return None
|
|
155
|
-
|
|
156
|
-
# 3. Check payment status
|
|
157
|
-
def check_atmos_payment(transaction_id):
|
|
158
|
-
try:
|
|
159
|
-
status = atmos.check_payment(transaction_id)
|
|
160
|
-
|
|
161
|
-
print(f"Transaction ID: {status['transaction_id']}")
|
|
162
|
-
print(f"Status: {status['status']}")
|
|
163
|
-
|
|
164
|
-
return status
|
|
165
|
-
|
|
166
|
-
except Exception as e:
|
|
167
|
-
print(f"❌ Status check failed: {e}")
|
|
168
|
-
return None
|
|
169
|
-
|
|
170
|
-
# 4. Handle webhook (for web frameworks)
|
|
171
|
-
def handle_atmos_webhook(webhook_data):
|
|
172
|
-
webhook_handler = AtmosWebhookHandler(api_key="your_atmos_api_key")
|
|
173
|
-
|
|
174
|
-
try:
|
|
175
|
-
response = webhook_handler.handle_webhook(webhook_data)
|
|
176
|
-
|
|
177
|
-
if response['status'] == 1:
|
|
178
|
-
# Payment successful
|
|
179
|
-
transaction_id = webhook_data.get('transaction_id')
|
|
180
|
-
amount = webhook_data.get('amount')
|
|
181
|
-
invoice = webhook_data.get('invoice')
|
|
182
|
-
|
|
183
|
-
print(f"✅ Payment successful!")
|
|
184
|
-
print(f"Transaction ID: {transaction_id}")
|
|
185
|
-
print(f"Order ID: {invoice}")
|
|
186
|
-
print(f"Amount: {amount}")
|
|
187
|
-
|
|
188
|
-
# Update your order status here
|
|
189
|
-
# update_order_status(invoice, 'paid')
|
|
190
|
-
|
|
191
|
-
return response
|
|
192
|
-
|
|
193
|
-
except Exception as e:
|
|
194
|
-
print(f"❌ Webhook processing failed: {e}")
|
|
195
|
-
return {
|
|
196
|
-
'status': 0,
|
|
197
|
-
'message': f'Error: {str(e)}'
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
# Usage example
|
|
201
|
-
if __name__ == "__main__":
|
|
202
|
-
# Create payment
|
|
203
|
-
payment = create_atmos_payment("order_12345", 50000) # 500.00 UZS
|
|
204
|
-
|
|
205
|
-
if payment:
|
|
206
|
-
# Check status after some time
|
|
207
|
-
import time
|
|
208
|
-
time.sleep(5) # Wait 5 seconds
|
|
209
|
-
|
|
210
|
-
status = check_atmos_payment(payment['transaction_id'])
|
|
211
|
-
print(f"Current status: {status['status'] if status else 'Unknown'}")
|
|
212
|
-
```
|
|
213
|
-
|
|
214
122
|
### Django Integration
|
|
215
123
|
|
|
216
124
|
1. Create Order model:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
paytechuz/__init__.py,sha256=
|
|
1
|
+
paytechuz/__init__.py,sha256=uWgnlJCeEyLr6Nl54y8yVKo0nzvzjsJ6nfwcc1Kdbx8,1916
|
|
2
2
|
paytechuz/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
paytechuz/core/base.py,sha256=Es6eEGNgDjQJe-kEJVAHSAh8AWbgtIuQMm0xn7qfjl4,2549
|
|
4
4
|
paytechuz/core/constants.py,sha256=hzCy5Kc8HVSDhXxNgObbJ2e9SYcXTYL3qky_q0tlpHU,2305
|
|
@@ -23,10 +23,10 @@ paytechuz/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
|
23
23
|
paytechuz/integrations/django/__init__.py,sha256=fNs4c2IWpCe78-_Yvgz59TdKbHiYRYDkLR33QOBf-Ok,356
|
|
24
24
|
paytechuz/integrations/django/admin.py,sha256=6fs6GiKcdc-hGlLxJ0BthY7TFo_2RVVJRhQwhxMroCY,2664
|
|
25
25
|
paytechuz/integrations/django/apps.py,sha256=Q9wG2osL7_Ip2BcAkq7lmmhu4UKJAg6UtSsSq_RgHlc,640
|
|
26
|
-
paytechuz/integrations/django/models.py,sha256=
|
|
26
|
+
paytechuz/integrations/django/models.py,sha256=ze-yzGBYN3sAXFClT6xjEzRN3ihepPVPDcm_qgdvM40,5936
|
|
27
27
|
paytechuz/integrations/django/signals.py,sha256=VtNYEAnu13wi9PqadEaCU9LY_k2tY26AS4bnPIAqw7M,1319
|
|
28
28
|
paytechuz/integrations/django/views.py,sha256=KFiuMcr4BtMbzbrW_RbIkv0-Fk214WIWWwaStscArzs,4149
|
|
29
|
-
paytechuz/integrations/django/webhooks.py,sha256=
|
|
29
|
+
paytechuz/integrations/django/webhooks.py,sha256=7cEDnlFoMIwInjor2ob7qEtgSpzXm1rgbQTobHY3zac,36843
|
|
30
30
|
paytechuz/integrations/django/migrations/0001_initial.py,sha256=SWHIUuwq91crzaxa9v1UK0kay8CxsjUo6t4bqg7j0Gw,1896
|
|
31
31
|
paytechuz/integrations/django/migrations/0002_alter_paymenttransaction_gateway.py,sha256=XiZx5urgfhXxra3W_KWksQ1LbaDOs3sjPn4w0T2cW50,457
|
|
32
32
|
paytechuz/integrations/django/migrations/__init__.py,sha256=KLQ5NdjOMLDS21-u3b_g08G1MjPMMhG95XI_N8m4FSo,41
|
|
@@ -34,7 +34,7 @@ paytechuz/integrations/fastapi/__init__.py,sha256=DLnhAZQZf2ghu8BuFFfE7FzbNKWQQ2
|
|
|
34
34
|
paytechuz/integrations/fastapi/models.py,sha256=9IqrsndIVuIDwDbijZ89biJxEWQASXRBfWVShxgerAc,5113
|
|
35
35
|
paytechuz/integrations/fastapi/routes.py,sha256=t8zbqhMZsaJmEvMDgmF-NoRmbqksfX_AvIrx-3kCjg8,37845
|
|
36
36
|
paytechuz/integrations/fastapi/schemas.py,sha256=PgRqviJiD4-u3_CIkUOX8R7L8Yqn8L44WLte7968G0E,3887
|
|
37
|
-
paytechuz-0.3.
|
|
38
|
-
paytechuz-0.3.
|
|
39
|
-
paytechuz-0.3.
|
|
40
|
-
paytechuz-0.3.
|
|
37
|
+
paytechuz-0.3.2.dist-info/METADATA,sha256=_FSKa283Yfh2Do-6ypaWsCoePSt0kHTwdmNvQEv4_rQ,13096
|
|
38
|
+
paytechuz-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
39
|
+
paytechuz-0.3.2.dist-info/top_level.txt,sha256=oloyKGNVj9Z2h3wpKG5yPyTlpdpWW0-CWr-j-asCWBc,10
|
|
40
|
+
paytechuz-0.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|