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

@@ -20,17 +20,17 @@ class PaymentGateway(Enum):
20
20
 
21
21
  class PaymeEndpoints:
22
22
  """Payme API endpoints."""
23
- RECEIPTS_CREATE = "receipts/create"
24
- RECEIPTS_PAY = "receipts/pay"
25
- RECEIPTS_SEND = "receipts/send"
26
- RECEIPTS_CHECK = "receipts/check"
27
- RECEIPTS_CANCEL = "receipts/cancel"
28
- RECEIPTS_GET = "receipts/get"
29
- CARDS_CREATE = "cards/create"
30
- CARDS_VERIFY = "cards/verify"
31
- CARDS_CHECK = "cards/check"
32
- CARDS_REMOVE = "cards/remove"
33
- CARDS_GET_VERIFY_CODE = "cards/get_verify_code"
23
+ RECEIPTS_CREATE = "receipts.create"
24
+ RECEIPTS_PAY = "receipts.pay"
25
+ RECEIPTS_SEND = "receipts.send"
26
+ RECEIPTS_CHECK = "receipts.check"
27
+ RECEIPTS_CANCEL = "receipts.cancel"
28
+ RECEIPTS_GET = "receipts.get"
29
+ CARDS_CREATE = "cards.create"
30
+ CARDS_VERIFY = "cards.verify"
31
+ CARDS_CHECK = "cards.check"
32
+ CARDS_REMOVE = "cards.remove"
33
+ CARDS_GET_VERIFY_CODE = "cards.get_verify_code"
34
34
 
35
35
 
36
36
  class PaymeNetworks:
@@ -204,3 +204,72 @@ class ClickGateway(BasePaymentGateway):
204
204
  'cancelled_at': cancel_data.get('cancelled_at'),
205
205
  'raw_response': cancel_data
206
206
  }
207
+
208
+ @handle_exceptions
209
+ def card_token_request(
210
+ self,
211
+ card_number: str,
212
+ expire_date: str,
213
+ temporary: int = 0
214
+ ) -> Dict[str, Any]:
215
+ """
216
+ Request a card token for card payment.
217
+
218
+ Args:
219
+ card_number: Card number (e.g., "5614681005030279")
220
+ expire_date: Card expiration date (e.g., "0330" for March 2030)
221
+ temporary: Whether the token is temporary (0 or 1)
222
+
223
+ Returns:
224
+ Dict containing card token and related information
225
+ """
226
+ return self.merchant_api.card_token_request(
227
+ card_number=card_number,
228
+ expire_date=expire_date,
229
+ temporary=temporary
230
+ )
231
+
232
+ @handle_exceptions
233
+ def card_token_verify(
234
+ self,
235
+ card_token: str,
236
+ sms_code: Union[int, str]
237
+ ) -> Dict[str, Any]:
238
+ """
239
+ Verify a card token with SMS code.
240
+
241
+ Args:
242
+ card_token: Card token from card_token_request
243
+ sms_code: SMS code sent to the card holder
244
+
245
+ Returns:
246
+ Dict containing verification status and card information
247
+ """
248
+ return self.merchant_api.card_token_verify(
249
+ card_token=card_token,
250
+ sms_code=sms_code
251
+ )
252
+
253
+ @handle_exceptions
254
+ def card_token_payment(
255
+ self,
256
+ card_token: str,
257
+ amount: Union[int, float],
258
+ transaction_parameter: str
259
+ ) -> Dict[str, Any]:
260
+ """
261
+ Make a payment using a verified card token.
262
+
263
+ Args:
264
+ card_token: Verified card token
265
+ amount: Payment amount in som
266
+ transaction_parameter: Unique transaction parameter
267
+
268
+ Returns:
269
+ Dict containing payment status and payment ID
270
+ """
271
+ return self.merchant_api.card_token_payment(
272
+ card_token=card_token,
273
+ amount=amount,
274
+ transaction_parameter=transaction_parameter
275
+ )
@@ -263,3 +263,105 @@ class ClickMerchantApi:
263
263
  )
264
264
 
265
265
  return response
266
+
267
+ @handle_exceptions
268
+ def card_token_request(
269
+ self,
270
+ card_number: str,
271
+ expire_date: str,
272
+ temporary: int = 0
273
+ ) -> Dict[str, Any]:
274
+ """
275
+ Request a card token for card payment.
276
+
277
+ Args:
278
+ card_number: Card number (e.g., "5614681005030279")
279
+ expire_date: Card expiration date (e.g., "0330" for March 2030)
280
+ temporary: Whether the token is temporary (0 or 1)
281
+
282
+ Returns:
283
+ Dict containing card token and related information
284
+ """
285
+ data = {
286
+ "service_id": self.service_id,
287
+ "card_number": card_number,
288
+ "expire_date": expire_date,
289
+ "temporary": temporary
290
+ }
291
+
292
+ if self.secret_key:
293
+ data["sign"] = self._generate_signature(data)
294
+
295
+ response = self.http_client.post(
296
+ endpoint=f"{ClickEndpoints.MERCHANT_API}/card_token/request",
297
+ json_data=data
298
+ )
299
+
300
+ return response
301
+
302
+ @handle_exceptions
303
+ def card_token_verify(
304
+ self,
305
+ card_token: str,
306
+ sms_code: Union[int, str]
307
+ ) -> Dict[str, Any]:
308
+ """
309
+ Verify a card token with SMS code.
310
+
311
+ Args:
312
+ card_token: Card token from card_token_request
313
+ sms_code: SMS code sent to the card holder
314
+
315
+ Returns:
316
+ Dict containing verification status and card information
317
+ """
318
+ data = {
319
+ "service_id": self.service_id,
320
+ "card_token": card_token,
321
+ "sms_code": int(sms_code)
322
+ }
323
+
324
+ if self.secret_key:
325
+ data["sign"] = self._generate_signature(data)
326
+
327
+ response = self.http_client.post(
328
+ endpoint=f"{ClickEndpoints.MERCHANT_API}/card_token/verify",
329
+ json_data=data
330
+ )
331
+
332
+ return response
333
+
334
+ @handle_exceptions
335
+ def card_token_payment(
336
+ self,
337
+ card_token: str,
338
+ amount: Union[int, float],
339
+ transaction_parameter: str
340
+ ) -> Dict[str, Any]:
341
+ """
342
+ Make a payment using a verified card token.
343
+
344
+ Args:
345
+ card_token: Verified card token
346
+ amount: Payment amount in som
347
+ transaction_parameter: Unique transaction parameter
348
+
349
+ Returns:
350
+ Dict containing payment status and payment ID
351
+ """
352
+ data = {
353
+ "service_id": self.service_id,
354
+ "card_token": card_token,
355
+ "amount": float(amount),
356
+ "transaction_parameter": transaction_parameter
357
+ }
358
+
359
+ if self.secret_key:
360
+ data["sign"] = self._generate_signature(data)
361
+
362
+ response = self.http_client.post(
363
+ endpoint=f"{ClickEndpoints.MERCHANT_API}/card_token/payment",
364
+ json_data=data
365
+ )
366
+
367
+ return response
@@ -30,6 +30,22 @@ class PaymeCards:
30
30
  self.http_client = http_client
31
31
  self.payme_id = payme_id
32
32
 
33
+ def _get_auth_headers(self, language: str = 'uz') -> Dict[str, str]:
34
+ """
35
+ Get authentication headers for Payme API.
36
+
37
+ Args:
38
+ language: Language code (uz, ru, en)
39
+
40
+ Returns:
41
+ Dict containing authentication headers
42
+ """
43
+ headers = {
44
+ "Accept-Language": language,
45
+ "X-Auth": self.payme_id
46
+ }
47
+ return headers
48
+
33
49
  @handle_exceptions
34
50
  def create(
35
51
  self,
@@ -58,23 +74,24 @@ class PaymeCards:
58
74
 
59
75
  # Prepare request data
60
76
  data = {
77
+ "jsonrpc": "2.0",
61
78
  "method": PaymeEndpoints.CARDS_CREATE,
62
79
  "params": {
63
80
  "card": {
64
81
  "number": card_number,
65
82
  "expire": expire_date
66
83
  },
67
- "save": save,
68
- "merchant_id": self.payme_id
69
- }
84
+ "save": save
85
+ },
86
+ "id": 1
70
87
  }
71
88
 
72
89
  # Add optional parameters
73
90
  if phone:
74
91
  data["params"]["phone"] = phone
75
92
 
76
- # Add language header
77
- headers = {"Accept-Language": language}
93
+ # Get authentication headers
94
+ headers = self._get_auth_headers(language)
78
95
 
79
96
  # Make request
80
97
  response = self.http_client.post(
@@ -109,15 +126,17 @@ class PaymeCards:
109
126
 
110
127
  # Prepare request data
111
128
  data = {
129
+ "jsonrpc": "2.0",
112
130
  "method": PaymeEndpoints.CARDS_VERIFY,
113
131
  "params": {
114
132
  "token": token,
115
133
  "code": code
116
- }
134
+ },
135
+ "id": 1
117
136
  }
118
137
 
119
- # Add language header
120
- headers = {"Accept-Language": language}
138
+ # Get authentication headers
139
+ headers = self._get_auth_headers(language)
121
140
 
122
141
  # Make request
123
142
  response = self.http_client.post(
@@ -141,16 +160,22 @@ class PaymeCards:
141
160
  """
142
161
  # Prepare request data
143
162
  data = {
163
+ "jsonrpc": "2.0",
144
164
  "method": PaymeEndpoints.CARDS_CHECK,
145
165
  "params": {
146
166
  "token": token
147
- }
167
+ },
168
+ "id": 1
148
169
  }
149
170
 
171
+ # Get authentication headers
172
+ headers = self._get_auth_headers()
173
+
150
174
  # Make request
151
175
  response = self.http_client.post(
152
176
  endpoint="",
153
- json_data=data
177
+ json_data=data,
178
+ headers=headers
154
179
  )
155
180
 
156
181
  return response
@@ -168,16 +193,22 @@ class PaymeCards:
168
193
  """
169
194
  # Prepare request data
170
195
  data = {
196
+ "jsonrpc": "2.0",
171
197
  "method": PaymeEndpoints.CARDS_REMOVE,
172
198
  "params": {
173
199
  "token": token
174
- }
200
+ },
201
+ "id": 1
175
202
  }
176
203
 
204
+ # Get authentication headers
205
+ headers = self._get_auth_headers()
206
+
177
207
  # Make request
178
208
  response = self.http_client.post(
179
209
  endpoint="",
180
- json_data=data
210
+ json_data=data,
211
+ headers=headers
181
212
  )
182
213
 
183
214
  return response
@@ -204,14 +235,16 @@ class PaymeCards:
204
235
 
205
236
  # Prepare request data
206
237
  data = {
238
+ "jsonrpc": "2.0",
207
239
  "method": PaymeEndpoints.CARDS_GET_VERIFY_CODE,
208
240
  "params": {
209
241
  "token": token
210
- }
242
+ },
243
+ "id": 1
211
244
  }
212
245
 
213
- # Add language header
214
- headers = {"Accept-Language": language}
246
+ # Get authentication headers
247
+ headers = self._get_auth_headers(language)
215
248
 
216
249
  # Make request
217
250
  response = self.http_client.post(
@@ -48,11 +48,10 @@ class PaymeReceipts:
48
48
  Returns:
49
49
  Dict containing authentication headers
50
50
  """
51
- headers = {"Accept-Language": language}
52
-
53
- if self.payme_key:
54
- auth = generate_basic_auth(self.payme_id, self.payme_key)
55
- headers["Authorization"] = auth
51
+ headers = {
52
+ "Accept-Language": language,
53
+ "X-Auth": f"{self.payme_id}:{self.payme_key}"
54
+ }
56
55
 
57
56
  return headers
58
57
 
@@ -94,14 +93,15 @@ class PaymeReceipts:
94
93
 
95
94
  # Prepare request data
96
95
  data = {
96
+ "jsonrpc": "2.0",
97
97
  "method": PaymeEndpoints.RECEIPTS_CREATE,
98
98
  "params": {
99
99
  "amount": amount,
100
100
  "account": account,
101
101
  "description": description,
102
- "detail": detail,
103
- "merchant_id": self.payme_id
104
- }
102
+ "detail": detail
103
+ },
104
+ "id": 1
105
105
  }
106
106
 
107
107
  # Add optional parameters
@@ -156,11 +156,13 @@ class PaymeReceipts:
156
156
 
157
157
  # Prepare request data
158
158
  data = {
159
+ "jsonrpc": "2.0",
159
160
  "method": PaymeEndpoints.RECEIPTS_PAY,
160
161
  "params": {
161
162
  "id": receipt_id,
162
163
  "token": token
163
- }
164
+ },
165
+ "id": 1
164
166
  }
165
167
 
166
168
  # Get authentication headers
@@ -199,11 +201,13 @@ class PaymeReceipts:
199
201
 
200
202
  # Prepare request data
201
203
  data = {
204
+ "jsonrpc": "2.0",
202
205
  "method": PaymeEndpoints.RECEIPTS_SEND,
203
206
  "params": {
204
207
  "id": receipt_id,
205
208
  "phone": phone
206
- }
209
+ },
210
+ "id": 1
207
211
  }
208
212
 
209
213
  # Get authentication headers
@@ -236,10 +240,12 @@ class PaymeReceipts:
236
240
 
237
241
  # Prepare request data
238
242
  data = {
243
+ "jsonrpc": "2.0",
239
244
  "method": PaymeEndpoints.RECEIPTS_CHECK,
240
245
  "params": {
241
246
  "id": receipt_id
242
- }
247
+ },
248
+ "id": 1
243
249
  }
244
250
 
245
251
  # Get authentication headers
@@ -278,10 +284,12 @@ class PaymeReceipts:
278
284
 
279
285
  # Prepare request data
280
286
  data = {
287
+ "jsonrpc": "2.0",
281
288
  "method": PaymeEndpoints.RECEIPTS_CANCEL,
282
289
  "params": {
283
290
  "id": receipt_id
284
- }
291
+ },
292
+ "id": 1
285
293
  }
286
294
 
287
295
  # Add reason if provided
@@ -318,10 +326,12 @@ class PaymeReceipts:
318
326
 
319
327
  # Prepare request data
320
328
  data = {
329
+ "jsonrpc": "2.0",
321
330
  "method": PaymeEndpoints.RECEIPTS_GET,
322
331
  "params": {
323
332
  "id": receipt_id
324
- }
333
+ },
334
+ "id": 1
325
335
  }
326
336
 
327
337
  # Get authentication headers
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: paytechuz
3
- Version: 0.3.3
3
+ Version: 0.3.5
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
@@ -1,7 +1,7 @@
1
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
- paytechuz/core/constants.py,sha256=hzCy5Kc8HVSDhXxNgObbJ2e9SYcXTYL3qky_q0tlpHU,2305
4
+ paytechuz/core/constants.py,sha256=uju3BNtDln-m04X1MhZsdIc26dHkZ2Tyb3Kfl00Btj8,2305
5
5
  paytechuz/core/exceptions.py,sha256=XMJkqiponTkvhjoh3S2iFNuU3UbBdFW4130kd0hpudg,5489
6
6
  paytechuz/core/http.py,sha256=1PFv_Fo62GtfyYKUK2nsT4AaeQNuMgZlFUFL1q9p2MI,7672
7
7
  paytechuz/core/utils.py,sha256=EbNtDweR1ABOtCu4D6cYlolM0t_fbiE3gNoc_qfcKKA,4704
@@ -11,13 +11,13 @@ paytechuz/gateways/atmos/__init__.py,sha256=piVcHu32K-D8I0Kr6bSXXrdtny2S5TY0hxMb
11
11
  paytechuz/gateways/atmos/client.py,sha256=Llo4utBVYPq1a3eLQaCtOMIzXooRhati3Eh2o6qbVdE,6212
12
12
  paytechuz/gateways/atmos/webhook.py,sha256=bqMHipJ_GowGYuxVaZd2f8bSEzSNHavdsvpGpsqy96s,2989
13
13
  paytechuz/gateways/click/__init__.py,sha256=35RPIrZYHgMWDzxjQkJMZYjzHDa8cY_BqQztCdZZmBM,90
14
- paytechuz/gateways/click/client.py,sha256=NwsPGfXacO0tWvZCA0V9KZ9XhFV7AnyHBmtxsWAvci8,6736
15
- paytechuz/gateways/click/merchant.py,sha256=tvHUwNr_eiDz_ED4-m2GNBh_LXN0b5lwtq1jw1e0zAQ,7191
14
+ paytechuz/gateways/click/client.py,sha256=kfivz_GA6YigE1ZE9sw3iqpcvM0kZ2m0bnyXKWP5tvs,8688
15
+ paytechuz/gateways/click/merchant.py,sha256=b9_jvwR0qbnPgVfNj_LenupxFTG0iA7e-tpQfJgw5nw,9998
16
16
  paytechuz/gateways/click/webhook.py,sha256=rph-NmjjnBKMW4rcxQTXrHHdK-uMrU39kXnbqK56leo,7936
17
17
  paytechuz/gateways/payme/__init__.py,sha256=KcVkYvAEblL4ASVAOrUofRBwywAkTZIgRXoBaCbYtv8,90
18
- paytechuz/gateways/payme/cards.py,sha256=iyitnAIQ_BUNmF273ErSLe3GOs5LYp3pWHxdb_FtOzs,5421
18
+ paytechuz/gateways/payme/cards.py,sha256=JociR-Y405fUxiqP96WSLJMu45bc_oa5YszxenchHDc,6291
19
19
  paytechuz/gateways/payme/client.py,sha256=fmFHbgWX0UG7246JgA8tWougzAbw75QTWC9mw_TgvZI,7808
20
- paytechuz/gateways/payme/receipts.py,sha256=DFIoD2EW65sStgeNP75GrUCcuvn7H7PPc415pw4S79g,8905
20
+ paytechuz/gateways/payme/receipts.py,sha256=YtQufqLN7A8SYY4qnIpYe32tQU9BcbF81NTpNKnzYp0,9104
21
21
  paytechuz/gateways/payme/webhook.py,sha256=-0O8vzMtiu4U8FWFKDA6EfyoX4NEGqcEq-T0yNtVhM4,12374
22
22
  paytechuz/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  paytechuz/integrations/django/__init__.py,sha256=fNs4c2IWpCe78-_Yvgz59TdKbHiYRYDkLR33QOBf-Ok,356
@@ -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.3.dist-info/METADATA,sha256=HxBgF8UNDby8T-ladhLbeT5PCz2WqaoFSncS8frdt9Q,13096
38
- paytechuz-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
39
- paytechuz-0.3.3.dist-info/top_level.txt,sha256=oloyKGNVj9Z2h3wpKG5yPyTlpdpWW0-CWr-j-asCWBc,10
40
- paytechuz-0.3.3.dist-info/RECORD,,
37
+ paytechuz-0.3.5.dist-info/METADATA,sha256=3v6I13IAz9EKUKK-ceZrsfSiL1M8Cw6Q8g-8KK0S3vI,13096
38
+ paytechuz-0.3.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
39
+ paytechuz-0.3.5.dist-info/top_level.txt,sha256=oloyKGNVj9Z2h3wpKG5yPyTlpdpWW0-CWr-j-asCWBc,10
40
+ paytechuz-0.3.5.dist-info/RECORD,,