xync-client 0.0.138__py3-none-any.whl → 0.0.139__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.

@@ -39,11 +39,6 @@ class PmAgentClient(metaclass=ABCMeta):
39
39
  self.bot = FileClient(TOKEN)
40
40
  await self.bot.start()
41
41
 
42
- self.agent = await PmAgent.get_or_none(**dct).prefetch_related("user__username__session")
43
- if not self.agent:
44
- await self.bot.send(f"No active users with agent for {self.norm}!", self.uid)
45
- raise Exception(f"No active users for {self.norm}!")
46
-
47
42
  self.browser = await pw.chromium.launch(channel="chromium-headless-shell", headless=not headed)
48
43
  context = await self.browser.new_context(storage_state=self.agent.state)
49
44
  self.page = await context.new_page()
@@ -59,6 +54,8 @@ class PmAgentClient(metaclass=ABCMeta):
59
54
  self._is_started = True
60
55
  return self
61
56
 
57
+ def get_topup(self, tid: str) -> dict: ...
58
+
62
59
  async def _idle(self): # todo: не мешать другим процессам, обновлять на другой вкладке?
63
60
  while (await User.get(username_id=self.uid)).status >= UserStatus.ACTIVE:
64
61
  await self.page.wait_for_timeout(30 * 1000)
@@ -90,5 +87,6 @@ class PmAgentClient(metaclass=ABCMeta):
90
87
  @abstractmethod # видео входа в аккаунт, и переход в историю поступлений за последние сутки (минимум)
91
88
  async def proof(self) -> bytes: ...
92
89
 
93
- def __init__(self, uid: int = None):
94
- self.uid = uid
90
+ def __init__(self, agent: PmAgent):
91
+ self.agent = agent
92
+ self.uid = agent.user.username_id
@@ -19,7 +19,7 @@ from cryptography.hazmat.primitives.ciphers.modes import CBC
19
19
  from payeer_api import PayeerAPI
20
20
  from playwright.async_api import async_playwright, Playwright, Error
21
21
  from playwright._impl._errors import TimeoutError
22
- from xync_schema.models import TopUp, TopUpAble
22
+ from xync_schema.models import TopUp, TopUpAble, PmAgent
23
23
 
24
24
  from xync_client.loader import TORM
25
25
 
@@ -65,11 +65,10 @@ class Client(PmAgentClient):
65
65
  pages: type(StrEnum) = Pages
66
66
  api: PayeerAPI
67
67
 
68
- async def start(self, pw: Playwright, headed: bool = False) -> "PmAgentClient":
69
- await super().start(pw, headed)
68
+ def __init__(self, agent: PmAgent):
69
+ super().__init__(agent)
70
70
  if api_id := self.agent.auth.get("api_id"):
71
71
  self.api = PayeerAPI(self.agent.auth["email"], api_id, self.agent.auth["api_sec"])
72
- return self
73
72
 
74
73
  async def _login(self):
75
74
  await login(self.agent)
@@ -121,6 +120,17 @@ class Client(PmAgentClient):
121
120
  url = "https://payeer.com/merchant/?" + urlencode(params)
122
121
  return url, None
123
122
 
123
+ def get_topup(self, tid: str) -> dict:
124
+ hi = self.api.get_history_info(tid)
125
+ ti = self.api.shop_order_info(hi["params"]["SHOP_ID"], hi["params"]["ORDER_ID"])["info"]
126
+ return ti["status"] == "execute" and {
127
+ "pmid": ti["id"],
128
+ "from_acc": hi["params"]["ACCOUNT_NUMBER"],
129
+ "oid": hi["params"]["ORDER_ID"],
130
+ "amount": int(float(ti["sumOut"]) * 100),
131
+ "ts": datetime.strptime(ti["dateCreate"], "%d.%m.%Y %H:%M:%S") - timedelta(hours=3),
132
+ }
133
+
124
134
  async def send(self, dest: str, amount: int, cur: str) -> tuple[int, bytes, int] | int:
125
135
  self.last_active = datetime.now()
126
136
  page = self.page
@@ -204,8 +214,13 @@ async def main(uid: int):
204
214
  from x_model import init_db
205
215
 
206
216
  _ = await init_db(TORM, True)
217
+ agent = await PmAgent.get_or_none(pm__norm="payeer", user__username_id=uid).prefetch_related(
218
+ "user__username__session", "pm"
219
+ )
220
+ if not agent:
221
+ raise Exception(f"No active user #{uid} with agent for volet!")
222
+ pyr = agent.client()
207
223
  playwright: Playwright = await async_playwright().start()
208
- pyr = Client(uid)
209
224
  try:
210
225
  dest, amount, cur = "P79619335", 4, "RUB"
211
226
  ta = await TopUpAble.get(pm__norm="payeer")
@@ -1,7 +1,9 @@
1
1
  import logging
2
2
  import re
3
3
  from asyncio import run, ensure_future
4
+ from decimal import Decimal
4
5
  from enum import StrEnum
6
+ from hashlib import sha256
5
7
  from typing import Literal
6
8
 
7
9
  from playwright.async_api import async_playwright, Page, Locator, Position, Playwright # , FloatRect
@@ -12,8 +14,9 @@ from playwright._impl._errors import TimeoutError
12
14
  from pyro_client.client.bot import BotClient
13
15
  from pyro_client.client.user import UserClient
14
16
  from xync_schema.enums import UserStatus
15
- from xync_schema.models import Cur, User, PmAgent, Cred, PmCur, Fiat
17
+ from xync_schema.models import Cur, User, PmAgent, Cred, PmCur, Fiat, TopUp
16
18
 
19
+ from xync_client.Abc.PmAgent import PmAgentClient
17
20
  from xync_client.Gmail import GmClient
18
21
  from xync_client.Pms.Volet.api import APIClient
19
22
  from xync_client.loader import TOKEN
@@ -57,7 +60,16 @@ def parse_transaction_info(text: str) -> dict[str, str] | None:
57
60
  return None
58
61
 
59
62
 
60
- class Client:
63
+ class Client(PmAgentClient):
64
+ async def _login(self):
65
+ pass
66
+
67
+ async def check_in(self, amount: int | Decimal | float, cur: str, tid: str | int = None) -> float | None:
68
+ pass
69
+
70
+ async def proof(self) -> bytes:
71
+ pass
72
+
61
73
  uid: int
62
74
  agent: PmAgent
63
75
  bot: UserClient
@@ -65,15 +77,50 @@ class Client:
65
77
  page: Page
66
78
  gmail: GmClient
67
79
 
68
- def __init__(self, uid: int):
69
- self.uid = uid
70
- self.gmail = GmClient(uid)
80
+ def __init__(self, agent: PmAgent):
81
+ super().__init__(agent)
82
+ self.gmail = GmClient(self.uid)
83
+ self.api = APIClient(self.agent.auth["api"], self.agent.auth["password"], self.agent.auth["login"])
84
+
85
+ @staticmethod
86
+ def form_redirect(topup: TopUp) -> tuple[str, dict | None]:
87
+ ac_account_email = topup.topupable.auth["ac_account_email"]
88
+ ac_sci_name = topup.topupable.auth["ac_sci_name"]
89
+ ac_order_id = str(topup.id)
90
+ ac_amount = "{0:.2f}".format(topup.amount * 0.01)
91
+ ac_currency = topup.cur.ticker
92
+ ac_comments = "XyncPay top up"
93
+ secret = topup.topupable.auth["secret"]
94
+ data = [ac_account_email, ac_sci_name, ac_amount, ac_currency, secret, ac_order_id]
95
+
96
+ ac_sign = sha256(":".join(data).encode()).hexdigest()
97
+
98
+ params = {
99
+ "ac_account_email": ac_account_email,
100
+ "ac_sci_name": ac_sci_name,
101
+ "ac_amount": ac_amount,
102
+ "ac_currency": ac_currency,
103
+ "ac_order_id": ac_order_id,
104
+ "ac_sign": ac_sign,
105
+ "ac_comments": ac_comments,
106
+ }
107
+ url = "https://account.volet.com/sci/"
108
+ return url, params
109
+
110
+ def get_topup(self, tid: str) -> dict:
111
+ t = self.api.check_by_id(tid)
112
+ return t["status"] == "COMPLETED" and {
113
+ "pmid": t["id"],
114
+ "from_acc": t["walletSrcId"],
115
+ "oid": t["orderId"],
116
+ "amount": int(t["amount"] * 100),
117
+ "ts": t["updatedTime"],
118
+ }
71
119
 
72
120
  async def start(self, pw: Playwright, headed: bool = False):
73
121
  self.agent = await PmAgent.get(
74
122
  user__username_id=self.uid, user__status__gte=UserStatus.PAY, pm__norm="volet"
75
123
  ).prefetch_related("user__gmail", "user__username__session")
76
- self.api = APIClient(self.agent.auth["api"], self.agent.auth["password"], self.agent.auth["login"])
77
124
  # await self.upd_balances()
78
125
  bot = await BotClient(TOKEN)
79
126
  self.bot = await UserClient(self.uid, bot)
@@ -223,7 +270,13 @@ async def _test():
223
270
  logging.basicConfig(level=logging.DEBUG)
224
271
  uid = 193017646
225
272
  playwright: Playwright = await async_playwright().start()
226
- va = Client(uid)
273
+ agent = await PmAgent.get_or_none(pm__norm="volet", user__username_id=uid).prefetch_related(
274
+ "user__username__session"
275
+ )
276
+ if not agent:
277
+ raise Exception(f"No active user #{uid} with agent for volet!")
278
+
279
+ va = agent.client()
227
280
  try:
228
281
  await va.start(playwright)
229
282
  await va.send("alena.artemeva25@gmail.com", 7.98)
@@ -9,6 +9,8 @@ from zeep.client import Client
9
9
 
10
10
  from xync_client.loader import TORM
11
11
 
12
+ period = 5
13
+
12
14
 
13
15
  class APIClient:
14
16
  wsdl = "https://wallet.advcash.com/wsm/merchantWebService?wsdl"
@@ -83,25 +85,26 @@ class APIClient:
83
85
  params.update(walletId=to)
84
86
  return self.make_request("sendMoney", params)
85
87
 
88
+ async def check_by_amount(self, amount: decimal, cur: str = "RUB", timeout: int = 5 * 60, past: int = 0):
89
+ hist: list = self.make_request("history", {"transactionDirection": "INCOMING", "count": 3, "from": 0})
90
+ if int(hist[0].amount) == int(amount):
91
+ return hist[0]
92
+ await sleep(period)
93
+ past += period
94
+ if past < timeout:
95
+ return await self.check_by_amount(amount, cur, timeout, past)
96
+ return False
86
97
 
87
- period = 5
88
-
89
-
90
- async def check_payment(cl: APIClient, amount: decimal, cur: str = "RUB", timeout: int = 5 * 60, past: int = 0):
91
- hist: list = cl.make_request("history", {"transactionDirection": "INCOMING", "count": 3, "from": 0})
92
- if int(hist[0].amount) == int(amount):
93
- return hist[0]
94
- await sleep(period)
95
- past += period
96
- if past < timeout:
97
- return await check_payment(cl, amount, cur, timeout, past)
98
- return False
98
+ def check_by_id(self, tid: str):
99
+ t: dict = self.make_request("findTransaction", tid)
100
+ return t
99
101
 
100
102
 
101
103
  async def main():
102
104
  _ = await init_db(TORM, True)
103
105
  cl = APIClient("main", "mixfixX98", "mixartemev@gmail.com")
104
- b = cl.get_balances()
106
+ # b = cl.get_balances()
107
+ b = cl.check_by_id("ce9a52be-8085-431e-8e6e-b0be427c6c55")
105
108
  cl.make_request("history", {"transactionDirection": "INCOMING", "count": 100, "from": 0})
106
109
  print(b)
107
110
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xync-client
3
- Version: 0.0.138
3
+ Version: 0.0.139
4
4
  Author-email: Mike Artemiev <mixartemev@gmail.com>
5
5
  Project-URL: Homepage, https://gitlab.com/XyncNet/client
6
6
  Project-URL: Repository, https://gitlab.com/XyncNet/client
@@ -10,7 +10,7 @@ xync_client/Abc/Ex.py,sha256=n41-XCjoIV-KpC_lK3jO049tQKbFmE0eDU3SDlgZTws,12986
10
10
  xync_client/Abc/Exception.py,sha256=Sts7RpP370NBdjaH_cyXDdHtjge8zXNUGWCrKw49Zyk,482
11
11
  xync_client/Abc/InAgent.py,sha256=svKGATUM0c9YIDDEVLc-NxpUNWqZoVr5PjxoxK64RKs,650
12
12
  xync_client/Abc/Order.py,sha256=7-FGIJu5z9aYi0A_eJV4F-cp_6Mz_izNpefexDQZvHw,2428
13
- xync_client/Abc/PmAgent.py,sha256=qrAlnAeGjoJ7E2S3qV28mKEHJuhadJRcshGDD_9Wb1o,4212
13
+ xync_client/Abc/PmAgent.py,sha256=bvBHzzfg5-X6-JSPS0WGC6d69Cr57GWlMFKBq7x1yJw,4024
14
14
  xync_client/Abc/xtype.py,sha256=o1JEzWmEXCPddtlqWZ6HRTZTKX6SAnvsztbASj21zOQ,2584
15
15
  xync_client/Binance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  xync_client/Binance/binance_async.py,sha256=LP2DZaHwkfsp_4Tjvetb-1ntjQtJfODF0OgZpoPx4KU,2688
@@ -72,14 +72,14 @@ 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=3Uzb4A_q34vPUOlSk1HoNVQWtPqq1ncRH7MK4BGQei0,8886
75
+ xync_client/Pms/Payeer/__init__.py,sha256=xN3L-IURWJ6oYXq85qu34u0OZEQOXkshgeEuMG29qg8,9584
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
79
79
  xync_client/Pms/Sber/utils.py,sha256=gIeJspwvoBbOBt-fjxwW4WDHPoL2Evs8LVufsjrFOfo,1870
80
80
  xync_client/Pms/Tinkoff/__init__.py,sha256=ZyLvBEUn-vh-85oPUUDS586AHgvx3c-mkQE3yBQtbw8,5580
81
- xync_client/Pms/Volet/__init__.py,sha256=afbWlAg1s5l4N2dIz5TaeTG-wFz-HIFwzRJQO1NzJAk,9500
82
- xync_client/Pms/Volet/api.py,sha256=uvXWTzmzD4v7re253Xd-ev68G3Iwh83Z0VutgUThRvU,3383
81
+ xync_client/Pms/Volet/__init__.py,sha256=fHS_0mvih0KRnczh303vmM208IMXwJTbaJMXo60LvHk,11386
82
+ xync_client/Pms/Volet/api.py,sha256=okqppqT7M5E6sswu-xz3L4Y9-ngefBPbFtywRi6A7Xo,3595
83
83
  xync_client/Pms/Volet/pl.py,sha256=l7lvUrpjFoObXPHaseOIAcSbkNqJdpy6OLDutxYJH3U,2451
84
84
  xync_client/Pms/Volet/_todo_req/req.mjs,sha256=ut3Jw37rL5lY7SskjZ9f1l0VE33tuP-PZEYUTcJMc2I,817
85
85
  xync_client/Pms/Volet/_todo_req/req.py,sha256=mKvdPrb-lkQ98Ws92_oBKu5yqyU8Krxy9XwuIhdsBao,1570
@@ -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.138.dist-info/METADATA,sha256=hj6obh0V9c8OVO4E87R_KRryDQez2HU1IWgdU1hEIfg,1037
99
- xync_client-0.0.138.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
- xync_client-0.0.138.dist-info/top_level.txt,sha256=bmYEVIIrD3v7yFwH-X15pEfRvzhuAdfsAZ2igvNI4O8,12
101
- xync_client-0.0.138.dist-info/RECORD,,
98
+ xync_client-0.0.139.dist-info/METADATA,sha256=9rxN-VreJl1QAUz5lI4LtIr40e1J2BzTPDFRZNpopXQ,1037
99
+ xync_client-0.0.139.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
+ xync_client-0.0.139.dist-info/top_level.txt,sha256=bmYEVIIrD3v7yFwH-X15pEfRvzhuAdfsAZ2igvNI4O8,12
101
+ xync_client-0.0.139.dist-info/RECORD,,