xync-client 0.0.133__py3-none-any.whl → 0.0.134__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 xync-client might be problematic. Click here for more details.
- xync_client/Pms/Payeer/__init__.py +92 -9
- {xync_client-0.0.133.dist-info → xync_client-0.0.134.dist-info}/METADATA +1 -1
- {xync_client-0.0.133.dist-info → xync_client-0.0.134.dist-info}/RECORD +5 -5
- {xync_client-0.0.133.dist-info → xync_client-0.0.134.dist-info}/WHEEL +0 -0
- {xync_client-0.0.133.dist-info → xync_client-0.0.134.dist-info}/top_level.txt +0 -0
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from asyncio import run
|
|
3
|
+
from base64 import b64encode
|
|
3
4
|
from datetime import datetime
|
|
4
5
|
from decimal import Decimal
|
|
5
6
|
from enum import StrEnum
|
|
7
|
+
from hashlib import sha256
|
|
8
|
+
from json import dumps
|
|
6
9
|
from math import ceil
|
|
10
|
+
from os import urandom
|
|
7
11
|
from time import sleep
|
|
12
|
+
from urllib.parse import urlencode
|
|
8
13
|
|
|
9
14
|
from asyncpg.pgproto.pgproto import timedelta
|
|
15
|
+
from cryptography.hazmat.primitives import padding
|
|
16
|
+
from cryptography.hazmat.primitives.ciphers import Cipher
|
|
17
|
+
from cryptography.hazmat.primitives.ciphers.algorithms import AES
|
|
18
|
+
from cryptography.hazmat.primitives.ciphers.modes import CBC
|
|
10
19
|
from payeer_api import PayeerAPI
|
|
11
20
|
from playwright.async_api import async_playwright, Playwright, Error
|
|
12
21
|
from playwright._impl._errors import TimeoutError
|
|
22
|
+
from xync_schema.models import TopUp, TopUpAble
|
|
13
23
|
|
|
14
24
|
from xync_client.loader import TORM
|
|
15
25
|
|
|
@@ -17,6 +27,34 @@ from xync_client.Abc.PmAgent import PmAgentClient
|
|
|
17
27
|
from xync_client.Pms.Payeer.login import login
|
|
18
28
|
|
|
19
29
|
|
|
30
|
+
def encrypt_data(data: dict, md5digest: bytes):
|
|
31
|
+
# Convert data to JSON string (equivalent to json_encode)
|
|
32
|
+
bdata = dumps(data).encode()
|
|
33
|
+
|
|
34
|
+
# Generate random IV (16 bytes for AES)
|
|
35
|
+
iv = urandom(16)
|
|
36
|
+
|
|
37
|
+
# Pad or truncate key to 32 bytes
|
|
38
|
+
if len(md5digest) < 32:
|
|
39
|
+
md5digest = md5digest.ljust(32, b"\0") # Pad with null bytes
|
|
40
|
+
elif len(md5digest) > 32:
|
|
41
|
+
md5digest = md5digest[:32] # Truncate to 32 bytes
|
|
42
|
+
|
|
43
|
+
# Apply PKCS7 padding
|
|
44
|
+
padder = padding.PKCS7(128).padder() # 128 bits = 16 bytes block size
|
|
45
|
+
padded_data = padder.update(bdata)
|
|
46
|
+
padded_data += padder.finalize()
|
|
47
|
+
|
|
48
|
+
# Create cipher
|
|
49
|
+
cipher = Cipher(AES(md5digest), CBC(iv))
|
|
50
|
+
encryptor = cipher.encryptor()
|
|
51
|
+
|
|
52
|
+
# Encrypt
|
|
53
|
+
ciphertext = encryptor.update(padded_data) + encryptor.finalize()
|
|
54
|
+
|
|
55
|
+
return iv + ciphertext
|
|
56
|
+
|
|
57
|
+
|
|
20
58
|
class Client(PmAgentClient):
|
|
21
59
|
class Pages(StrEnum):
|
|
22
60
|
_base = "https://payeer.com/en/"
|
|
@@ -39,6 +77,50 @@ class Client(PmAgentClient):
|
|
|
39
77
|
await self.page.context.add_cookies([cookie])
|
|
40
78
|
await self.page.goto(self.pages.SEND)
|
|
41
79
|
|
|
80
|
+
@staticmethod
|
|
81
|
+
def form_redirect(topup: TopUp) -> tuple[str, dict | None]:
|
|
82
|
+
m_shop = str(topup.topupable.auth["id"])
|
|
83
|
+
m_orderid = str(topup.id)
|
|
84
|
+
m_amount = str(topup.amount * 0.01)
|
|
85
|
+
m_curr = topup.cur.ticker
|
|
86
|
+
m_desc = b64encode(b"XyncPay top up").decode()
|
|
87
|
+
m_key = topup.topupable.auth["sec"]
|
|
88
|
+
data = [m_shop, m_orderid, m_amount, m_curr, m_desc]
|
|
89
|
+
|
|
90
|
+
# # additional
|
|
91
|
+
# m_params = {
|
|
92
|
+
# 'success_url': 'https://xync.net/topup?success=1',
|
|
93
|
+
# 'fail_url': 'https://xync.net/topup?success=0',
|
|
94
|
+
# 'status_url': 'https://xync.net/topup',
|
|
95
|
+
# 'reference': {'var1': '1'},
|
|
96
|
+
# }
|
|
97
|
+
#
|
|
98
|
+
# key = md5(m_orderid.to_bytes()).digest()
|
|
99
|
+
#
|
|
100
|
+
# base64url_encode(encrypt_data(params, key))
|
|
101
|
+
#
|
|
102
|
+
# data.append(m_params)
|
|
103
|
+
# # additional
|
|
104
|
+
|
|
105
|
+
data.append(m_key)
|
|
106
|
+
|
|
107
|
+
sign = sha256(":".join(data).encode()).hexdigest().upper()
|
|
108
|
+
|
|
109
|
+
params = {
|
|
110
|
+
"m_shop": m_shop,
|
|
111
|
+
"m_orderid": m_orderid,
|
|
112
|
+
"m_amount": m_amount,
|
|
113
|
+
"m_curr": m_curr,
|
|
114
|
+
"m_desc": m_desc,
|
|
115
|
+
"m_sign": sign,
|
|
116
|
+
# 'm_params': m_params,
|
|
117
|
+
# 'm_cipher_method': 'AES-256-CBC-IV',
|
|
118
|
+
"form[ps]": "2609",
|
|
119
|
+
"form[curr[2609]]": m_curr,
|
|
120
|
+
}
|
|
121
|
+
url = "https://payeer.com/merchant/?" + urlencode(params)
|
|
122
|
+
return url, None
|
|
123
|
+
|
|
42
124
|
async def send(self, dest: str, amount: int, cur: str) -> tuple[int, bytes, int] | int:
|
|
43
125
|
self.last_active = datetime.now()
|
|
44
126
|
page = self.page
|
|
@@ -125,17 +207,18 @@ async def main(uid: int):
|
|
|
125
207
|
playwright: Playwright = await async_playwright().start()
|
|
126
208
|
pyr = Client(uid)
|
|
127
209
|
try:
|
|
128
|
-
|
|
210
|
+
dest, amount, cur = "P79619335", 4, "RUB"
|
|
211
|
+
ta = await TopUpAble.get(pm__norm="payeer")
|
|
212
|
+
topup = await TopUp.create(amount=1001, cur_id=1, topupable=ta, user_id=1)
|
|
213
|
+
await topup.fetch_related("cur")
|
|
214
|
+
_url, _data = pyr.form_redirect(topup)
|
|
129
215
|
|
|
130
|
-
|
|
216
|
+
await pyr.start(playwright, False)
|
|
131
217
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
res = await pyr.send(dest, amount, cur)
|
|
135
|
-
res = await pyr.send(dest, 3, cur)
|
|
136
|
-
res = await pyr.send(dest, amount, cur)
|
|
218
|
+
_res = await pyr.send(dest, amount, cur)
|
|
219
|
+
_res = await pyr.send(dest, 3, cur)
|
|
137
220
|
|
|
138
|
-
res = pyr.check_in(
|
|
221
|
+
res = pyr.check_in(3, cur, datetime.now())
|
|
139
222
|
|
|
140
223
|
if len(res) > 1 and isinstance(res[1], bytes):
|
|
141
224
|
await pyr.bot.send(f"Transaction #{res[0]}", uid, photo=res[1])
|
|
@@ -152,4 +235,4 @@ async def main(uid: int):
|
|
|
152
235
|
|
|
153
236
|
|
|
154
237
|
if __name__ == "__main__":
|
|
155
|
-
run(main(
|
|
238
|
+
run(main(193017646))
|
|
@@ -72,7 +72,7 @@ xync_client/Pms/Alfa/state.json,sha256=MKE6vl-JsJO9PNCVqoQgBgYZTgYkHCas7USwl8QFt
|
|
|
72
72
|
xync_client/Pms/MTS/__init__.py,sha256=P_E7W46IZEk8RsEgl7H1xV3JplMT5l9vYQYTYyNbyQ8,2101
|
|
73
73
|
xync_client/Pms/Ozon/__init__.py,sha256=EvQZDSPv0fOT2hNCTP44nXHOIEQvP5bQf_7HVLiZc2I,4123
|
|
74
74
|
xync_client/Pms/Payeer/.gitignore,sha256=sWORdRp8ROppV2CsMEDJ3M_SokrNWCf8b1hlaNs64hg,12
|
|
75
|
-
xync_client/Pms/Payeer/__init__.py,sha256=
|
|
75
|
+
xync_client/Pms/Payeer/__init__.py,sha256=mhApHXUgeBQIEYgIAafMRGMEV_eFtXcnj9FAVQKp7Jo,8873
|
|
76
76
|
xync_client/Pms/Payeer/api.py,sha256=bb8qrlPYyWafel1VR-2nate6xBeRZAVciFJblHygfAs,549
|
|
77
77
|
xync_client/Pms/Payeer/login.py,sha256=W5FAA0reW5x2hSh8sBIWmR38VcYhwvrn1R64IAtWHVw,2921
|
|
78
78
|
xync_client/Pms/Sber/__init__.py,sha256=dxQfd9ZPhFTc_C4xrwaxrV6p0SijDCLNzBeUv3oQG38,4926
|
|
@@ -95,7 +95,7 @@ xync_client/TgWallet/order.py,sha256=BOmBx5WWfJv0-_-A8DcR-Xd8utqO_VTmSqSegm0cteQ
|
|
|
95
95
|
xync_client/TgWallet/pyd.py,sha256=Ys3E8b3RLuyQ26frWT0F0BorkNxVpxnd18tY4Gp9dik,5636
|
|
96
96
|
xync_client/TgWallet/pyro.py,sha256=2K7QWdo48k4MbbgQt90gdz_HiPck69Njm4xaMjIVgoo,1440
|
|
97
97
|
xync_client/TgWallet/web.py,sha256=kDcv9SKKQPe91mw1qJBpbuyKYCAmZdfdHJylHumLBVU,1608
|
|
98
|
-
xync_client-0.0.
|
|
99
|
-
xync_client-0.0.
|
|
100
|
-
xync_client-0.0.
|
|
101
|
-
xync_client-0.0.
|
|
98
|
+
xync_client-0.0.134.dist-info/METADATA,sha256=Sm8MPNOELx828d8yU1KeGQ8bm4kPqPMh6tXRffEIARQ,1037
|
|
99
|
+
xync_client-0.0.134.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
100
|
+
xync_client-0.0.134.dist-info/top_level.txt,sha256=bmYEVIIrD3v7yFwH-X15pEfRvzhuAdfsAZ2igvNI4O8,12
|
|
101
|
+
xync_client-0.0.134.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|