# π Tochka API
**Π£Π΄ΠΎΠ±Π½Π°Ρ ΠΎΠ±ΡΡΡΠΊΠ° Π½Π°Π΄ ΠΎΡΠΊΡΡΡΡΠΌ API ΠΠ°Π½ΠΊΠ° Π’ΠΎΡΠΊΠ°**
## π₯ Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ°
### π¦ ΠΠ· pip:
```shell
python -m pip install -u tochka_api
```
### π ΠΠ· ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ:
```shell
git clone https://github.com/WhiteApfel/tochka_api.git
cd tochka_api
python setup.py install
```
### π§ ΠΡΠΎΠ³ΡΠ΅ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ
* [x] ΠΠ²ΡΠΎΡΠΈΠ·Π°ΡΠΈΡ
* [x] ΠΠ°Π»Π°Π½ΡΡ
* [x] Π‘ΡΠ΅ΡΠ°
* [ ] Webhooks
* [ ] ΠΡΠΏΠΈΡΠΊΠΈ
* [ ] ΠΠ°ΡΡΡ
* [ ] ΠΠ»ΠΈΠ΅Π½ΡΡ
* [ ] ΠΠ»Π°ΡΠ΅ΠΆΠΈ
* [ ] Π Π°Π·ΡΠ΅ΡΠ΅Π½ΠΈΡ
* [ ] Π‘ΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΠ΅ ΡΡΠ΅ΡΠ°
* [x] Π‘ΠΠ
* [x] QR
* [x] Π’Π‘Π (Merchant)
* [x] ΠΠΎΠΌΠΏΠ°Π½ΠΈΠΈ (Legal)
* [x] ΠΠΎΠ·Π²ΡΠ°ΡΡ
### π§βπ« ΠΠ°ΠΊ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ
**π° Π£ΡΠΎΡΠ½Π΅Π½ΠΈΡ ΠΏΠΎ ΡΠΈΠΏΡ Π΄Π°Π½Π½ΡΡ
Π΄Π»Ρ ΡΡΠΌΠΌΡ**
* ``Decimal`` and ``str`` - amount in rubles
* ``int`` - amount in kopecks
**Π Π°Π·Π»ΠΈΡΠΈΡ user_code ΠΈ customer_code**
* ``user_code`` ΡΡΠΎ ΠΊΠΎΠ΄ ΠΊΠ»ΠΈΠ΅Π½ΡΠ°, ΠΊΠΎΡΠΎΡΡΠΉ ΠΈΠΌΠ΅Π΅Ρ Π΄ΠΎΡΡΡΠΏ ΠΊ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ
* ``customer_code`` ΡΡΠΎ ΠΊΠΎΠ΄ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ(ΠΠ), Π½Π° ΠΊΠΎΡΠΎΡΡΡ ΠΎΡΠΊΡΡΡΡ ΡΡΠ΅ΡΠ°
```python
import asyncio
from decimal import Decimal
from tochka_api import TochkaAPI, context_user_code
from tochka_api.models import PermissionsEnum
client_id = "<<client_id>>"
client_secret = "<<client_secret>>"
redirect_uri = "https://tochka-api.pfel.cc/"
tochka = TochkaAPI(client_id, client_secret, redirect_uri=redirect_uri)
async def add_user():
consents_token, consents_expires_in = await tochka.get_consents_token()
consents_request = await tochka.create_consents(
consents_token, PermissionsEnum.all()
)
auth_url = tochka.generate_auth_url(consent_id=consents_request.consent_id)
print("Auth:", auth_url)
code = input("Code >>> ")
token_id = input("Token_id >>> ")
tokens = await tochka.get_access_token(
code=code, token_id=token_id
)
print(f"User {tokens.user_code=} are authorized.")
context_user_code.set(tokens.user_code)
asyncio.create_task(get_accounts())
merchant_id = await register_merchant(user_code=tokens.user_code)
await register_qr(merchant_id=merchant_id)
async def get_accounts():
# user_code Π±ΡΠ΄Π΅Ρ ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½ ΠΈΠ· context_user_code
# ΠΡΠΎ thread-safe ΠΈ loop-safe
for _ in range(25):
await tochka.get_accounts()
await asyncio.sleep(2)
async def register_merchant(user_code) -> str:
# ΠΡΠ΄Π΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΡΠΊΠ°Π·Π°Π½Π½ΡΠΉ user_code
# ΠΠ°ΠΆΠ΅ Π΅ΡΠ»ΠΈ Π² context_user_code Π±ΡΠ»ΠΎ Π·Π°Π΄Π°Π½ΠΎ Π΄ΡΡΠ³ΠΎΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅
accounts = await tochka.get_accounts(user_code=user_code)
customer_info = await tochka.sbp_get_customer_info(
customer_code=accounts[0].customer_code
)
legal_entity = await tochka.sbp_get_legal_entity(customer_info.legal_id)
merchant = await tochka.sbp_register_merchant(
legal_id=legal_entity.legal_id,
name="TochkaExample",
mcc="7277",
address=" 1-ΠΉ ΠΠ΅ΡΠ½ΡΠΊΠΎΠ²ΡΠΊΠΈΠΉ ΠΏΡΠΎΠ΅Π·Π΄, Π΄. 1, ΡΡΡ. 8, ΡΡΠ°ΠΆ 1, ΠΏΠΎΠΌΠ΅Ρ. 43",
city="ΠΠΎΡΠΊΠ²Π°",
region_code="45",
zip_code="109456",
phone_number="+78002000024",
)
print(f"New merchant {merchant.merchant_id=}")
print(
*(await tochka.sbp_get_merchants(legal_id=legal_entity.legal_id)).merchants,
sep="\n",
)
return merchant.merchant_id
async def register_qr(merchant_id):
# user_code Π±ΡΠ΄Π΅Ρ ΡΠ½Π°ΡΠ»Π΅Π΄ΠΎΠ²Π°Π½ ΠΈΠ· context_user_code
# ΠΡΠΎ thread-safe ΠΈ loop-safe
accounts = await tochka.get_accounts()
customer_info = await tochka.sbp_get_customer_info(
customer_code=accounts[0].customer_code
)
legal_entity = await tochka.sbp_get_legal_entity(customer_info.legal_id)
sbp_accounts = await tochka.sbp_get_accounts(legal_entity.legal_id)
qr = await tochka.sbp_register_qr(
merchant_id=merchant_id,
account=sbp_accounts[0].account,
is_static=True,
purpose="ΠΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½ΠΈΠ΅ ΠΏΠΎ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡΡ ΠΌΠΈΠ½Π΅ΡΠ°",
media_type="image/svg+xml",
)
print("Π‘ΡΠ°ΡΠΈΡΠ½ΡΠΉ Π±Π΅Π· ΡΡΠΌΠΌΡ:\n",qr.image.content)
qr = await tochka.sbp_register_qr(
merchant_id=merchant_id,
account=sbp_accounts[0].account,
is_static=True,
amount=Decimal("100.00"), # ΠΈΠ»ΠΈ Decimal(100), ΠΈΠ»ΠΈ 10000
purpose="ΠΠΏΠ»Π°ΡΠ° Π°ΡΠ΅Π½Π΄Ρ Π±ΠΎΡΠ΄Π΅Π»Ρ",
media_type="image/svg+xml",
)
print("Π‘ΡΠ°ΡΠΈΡΠ½ΡΠΉ Ρ ΡΡΠΌΠΌΠΎΠΉ:\n",qr.image.content)
qr = await tochka.sbp_register_qr(
merchant_id=merchant_id,
account=sbp_accounts[0].account,
is_static=False,
amount=10000, # ΠΈΠ»ΠΈ Decimal(100)
ttl=60, # 0 - ΠΌΠ°ΠΊΡΠΈΠΌΠ°Π»ΡΠ½ΠΎ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΠ΅ ΠΎΠ³ΡΠ°Π½ΠΈΡΠ΅Π½ΠΈΠ΅, ΠΈΠ½Π°ΡΠ΅ Π² ΠΌΠΈΠ½ΡΡΠ°Ρ
purpose="ΠΠΏΠ»Π°ΡΠ° ΠΏΠΎΡΡΠ°Π²ΠΊΠΈ ΠΏΡΠ΅Π·Π΅ΡΠ²Π°ΡΠΈΠ²ΠΎΠ²",
media_type="image/svg+xml",
)
print("ΠΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΈΠΉ Ρ ΡΡΠΌΠΌΠΎΠΉ:\n",qr.image.content)
async def refund():
accounts = await tochka.get_accounts()
customer_info = await tochka.sbp_get_customer_info(
customer_code=accounts[0].customer_code
)
sbp_accounts = await tochka.sbp_get_accounts(customer_info.legal_id)
payments = await tochka.sbp_get_payments(
customer_info.customer_code, from_date=1,
)
print(payments)
last_payment = payments.payments[0]
refund_response = await tochka.sbp_start_refund(
account=sbp_accounts[0].account,
amount=Decimal("1.25"), # ΠΈΠ»ΠΈ 125
qrc_id=last_payment.qrc_id,
trx_id=last_payment.trx_id,
)
print("Refund: ", refund_response)
async def main():
# ΠΠΎΠ±Π°Π²ΠΈΡΡ Π΄Π²Π° ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ.
# ΠΡΠΎ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ Π±ΡΡ
Π³Π°Π»ΡΠ΅Ρ ΠΈ Π²Π»Π°Π΄Π΅Π»Π΅Ρ ΠΎΠ΄Π½ΠΎΠΉ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ
# ΠΈΠ»ΠΈ ΡΠΎΠ²Π΅ΡΡΠ΅Π½Π½ΠΎ ΡΠ°Π·Π½ΡΠ΅ Π»ΡΠ΄ΠΈ ΠΈΠ· ΡΠ°Π·Π½ΡΡ
ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ.
# ΠΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΠΌΠΎΠΆΠ΅Ρ ΡΠ°Π±ΠΎΡΠ°ΡΡ Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΠΌΠΈ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΠΌΠΈ
# Π»ΠΈΠ±ΠΎ Π² ΠΎΠ΄Π½ΠΎΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡΠΊΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅, ΡΠΎΠ³Π΄Π° Π½Π°Π΄ΠΎ ΡΠΊΠ°Π·Π°ΡΡ
# tochka = TochkaAPI(client_id, client_secret, redirect_uri=redirect_uri, one_customer_mode=True)
# ΠΈ ΡΠΎΠ³Π΄Π° ΠΏΠΎΡΠ»Π΅ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ, ΡΠΈΡΡΠ΅ΠΌΠ° Π΅Π³ΠΎ Π·Π°ΠΏΠΎΠΌΠ½ΠΈΡ.
# Π£ΠΊΠ°Π·ΡΠ²Π°ΡΡ context_user_code Π½Π΅ ΠΏΡΠΈΠ΄ΡΡΡΡ
print("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΡΡΠΎ-Π»ΠΈΠ±ΠΎ, ΡΡΠΎΠ±Ρ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΉ")
print("ΠΠ»Ρ ΠΏΡΠΎΠΏΡΡΠΊΠ° Π½Π°ΠΆΠΌΠΈΡΠ΅ Enter")
if input(">>> "):
await add_user()
await add_user()
else:
# ΠΌΠΎΠΆΠ½ΠΎ Π½Π΅ ΡΠΊΠ°Π·ΡΠ²Π°ΡΡ, Π΅ΡΠ»ΠΈ one_customer_mode=True
context_user_code.set("212332030")
await refund()
balances = await tochka.get_balances()
print(balances[0].amount)
asyncio.run(main())
```
Raw data
{
"_id": null,
"home_page": "https://github.com/WhiteApfel/tochka_api",
"name": "tochka-api",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "tochka openapi api bank",
"author": "WhiteApfel",
"author_email": "white@pfel.ru",
"download_url": "https://files.pythonhosted.org/packages/93/7b/824abc0b87453ca5703241e3a34b8f58edf29ef8d5ab6f7415def4606c51/tochka_api-0.1.0.tar.gz",
"platform": null,
"description": "# \ud83c\udf89 Tochka API\n\n**\u0423\u0434\u043e\u0431\u043d\u0430\u044f \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c API \u0411\u0430\u043d\u043a\u0430 \u0422\u043e\u0447\u043a\u0430**\n\n## \ud83d\udce5 \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\n\n### \ud83d\udce6 \u0418\u0437 pip:\n\n```shell\npython -m pip install -u tochka_api\n```\n\n### \ud83c\udfd7 \u0418\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f:\n\n```shell\ngit clone https://github.com/WhiteApfel/tochka_api.git\ncd tochka_api\npython setup.py install\n```\n\n### \ud83d\udea7 \u041f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438\n\n* [x] \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f\n* [x] \u0411\u0430\u043b\u0430\u043d\u0441\u044b\n* [x] \u0421\u0447\u0435\u0442\u0430\n* [ ] Webhooks\n* [ ] \u0412\u044b\u043f\u0438\u0441\u043a\u0438\n* [ ] \u041a\u0430\u0440\u0442\u044b\n* [ ] \u041a\u043b\u0438\u0435\u043d\u0442\u044b\n* [ ] \u041f\u043b\u0430\u0442\u0435\u0436\u0438\n* [ ] \u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\n* [ ] \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0447\u0435\u0442\u0430\n* [x] \u0421\u0411\u041f\n * [x] QR\n * [x] \u0422\u0421\u041f (Merchant)\n * [x] \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 (Legal)\n * [x] \u0412\u043e\u0437\u0432\u0440\u0430\u0442\u044b\n\n### \ud83e\uddd1\u200d\ud83c\udfeb \u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\n\n**\ud83d\udcb0 \u0423\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0438\u043f\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0443\u043c\u043c\u044b**\n\n* ``Decimal`` and ``str`` - amount in rubles\n* ``int`` - amount in kopecks\n\n**\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f user_code \u0438 customer_code**\n\n* ``user_code`` \u044d\u0442\u043e \u043a\u043e\u0434 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438\n* ``customer_code`` \u044d\u0442\u043e \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438(\u0418\u041f), \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0442\u043a\u0440\u044b\u0442\u044b \u0441\u0447\u0435\u0442\u0430\n\n```python\nimport asyncio\n\nfrom decimal import Decimal\n\nfrom tochka_api import TochkaAPI, context_user_code\nfrom tochka_api.models import PermissionsEnum\n\nclient_id = \"<<client_id>>\"\nclient_secret = \"<<client_secret>>\"\nredirect_uri = \"https://tochka-api.pfel.cc/\"\n\ntochka = TochkaAPI(client_id, client_secret, redirect_uri=redirect_uri)\n\n\nasync def add_user():\n consents_token, consents_expires_in = await tochka.get_consents_token()\n consents_request = await tochka.create_consents(\n consents_token, PermissionsEnum.all()\n )\n auth_url = tochka.generate_auth_url(consent_id=consents_request.consent_id)\n print(\"Auth:\", auth_url)\n \n code = input(\"Code >>> \")\n token_id = input(\"Token_id >>> \")\n tokens = await tochka.get_access_token(\n code=code, token_id=token_id\n )\n \n print(f\"User {tokens.user_code=} are authorized.\")\n context_user_code.set(tokens.user_code)\n \n asyncio.create_task(get_accounts())\n merchant_id = await register_merchant(user_code=tokens.user_code)\n await register_qr(merchant_id=merchant_id)\n\nasync def get_accounts():\n # user_code \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d \u0438\u0437 context_user_code\n # \u042d\u0442\u043e thread-safe \u0438 loop-safe\n for _ in range(25):\n await tochka.get_accounts()\n await asyncio.sleep(2)\n\nasync def register_merchant(user_code) -> str:\n # \u0411\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 user_code\n # \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432 context_user_code \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0430\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\n accounts = await tochka.get_accounts(user_code=user_code)\n \n customer_info = await tochka.sbp_get_customer_info(\n customer_code=accounts[0].customer_code\n )\n legal_entity = await tochka.sbp_get_legal_entity(customer_info.legal_id)\n\n merchant = await tochka.sbp_register_merchant(\n legal_id=legal_entity.legal_id,\n name=\"TochkaExample\",\n mcc=\"7277\",\n address=\" 1-\u0439 \u0412\u0435\u0448\u043d\u044f\u043a\u043e\u0432\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0435\u0437\u0434, \u0434. 1, \u0441\u0442\u0440. 8, \u044d\u0442\u0430\u0436 1, \u043f\u043e\u043c\u0435\u0449. 43\",\n city=\"\u041c\u043e\u0441\u043a\u0432\u0430\",\n region_code=\"45\",\n zip_code=\"109456\",\n phone_number=\"+78002000024\",\n )\n \n print(f\"New merchant {merchant.merchant_id=}\")\n print(\n *(await tochka.sbp_get_merchants(legal_id=legal_entity.legal_id)).merchants,\n sep=\"\\n\",\n )\n \n return merchant.merchant_id\n\nasync def register_qr(merchant_id):\n # user_code \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d \u0438\u0437 context_user_code\n # \u042d\u0442\u043e thread-safe \u0438 loop-safe\n accounts = await tochka.get_accounts()\n\n customer_info = await tochka.sbp_get_customer_info(\n customer_code=accounts[0].customer_code\n )\n legal_entity = await tochka.sbp_get_legal_entity(customer_info.legal_id)\n sbp_accounts = await tochka.sbp_get_accounts(legal_entity.legal_id)\n \n qr = await tochka.sbp_register_qr(\n merchant_id=merchant_id,\n account=sbp_accounts[0].account,\n is_static=True,\n purpose=\"\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0443 \u043c\u0438\u043d\u0435\u0442\u0430\",\n media_type=\"image/svg+xml\",\n )\n print(\"\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0431\u0435\u0437 \u0441\u0443\u043c\u043c\u044b:\\n\",qr.image.content)\n \n qr = await tochka.sbp_register_qr(\n merchant_id=merchant_id,\n account=sbp_accounts[0].account,\n is_static=True,\n amount=Decimal(\"100.00\"), # \u0438\u043b\u0438 Decimal(100), \u0438\u043b\u0438 10000\n purpose=\"\u041e\u043f\u043b\u0430\u0442\u0430 \u0430\u0440\u0435\u043d\u0434\u044b \u0431\u043e\u0440\u0434\u0435\u043b\u044f\",\n media_type=\"image/svg+xml\",\n )\n print(\"\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0441 \u0441\u0443\u043c\u043c\u043e\u0439:\\n\",qr.image.content)\n \n qr = await tochka.sbp_register_qr(\n merchant_id=merchant_id,\n account=sbp_accounts[0].account,\n is_static=False,\n amount=10000, # \u0438\u043b\u0438 Decimal(100)\n ttl=60, # 0 - \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u0438\u043d\u0430\u0447\u0435 \u0432 \u043c\u0438\u043d\u0443\u0442\u0430\u0445\n purpose=\"\u041e\u043f\u043b\u0430\u0442\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043f\u0440\u0435\u0437\u0435\u0440\u0432\u0430\u0442\u0438\u0432\u043e\u0432\",\n media_type=\"image/svg+xml\",\n )\n print(\"\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441 \u0441\u0443\u043c\u043c\u043e\u0439:\\n\",qr.image.content)\n\nasync def refund():\n accounts = await tochka.get_accounts()\n\n customer_info = await tochka.sbp_get_customer_info(\n customer_code=accounts[0].customer_code\n )\n sbp_accounts = await tochka.sbp_get_accounts(customer_info.legal_id)\n \n payments = await tochka.sbp_get_payments(\n customer_info.customer_code, from_date=1,\n )\n print(payments)\n \n last_payment = payments.payments[0]\n refund_response = await tochka.sbp_start_refund(\n account=sbp_accounts[0].account,\n amount=Decimal(\"1.25\"), # \u0438\u043b\u0438 125\n qrc_id=last_payment.qrc_id,\n trx_id=last_payment.trx_id,\n )\n print(\"Refund: \", refund_response)\n\nasync def main():\n # \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \n # \u042d\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0443\u0445\u0433\u0430\u043b\u0442\u0435\u0440 \u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438\n # \u0438\u043b\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u043b\u044e\u0434\u0438 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439.\n # \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438\n # \u043b\u0438\u0431\u043e \u0432 \u043e\u0434\u043d\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c\n # tochka = TochkaAPI(client_id, client_secret, redirect_uri=redirect_uri, one_customer_mode=True)\n # \u0438 \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0435\u0433\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442.\n # \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c context_user_code \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f\n print(\"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0442\u043e-\u043b\u0438\u0431\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439\")\n print(\"\u0414\u043b\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 Enter\")\n if input(\">>> \"):\n await add_user()\n await add_user()\n else:\n # \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 one_customer_mode=True\n context_user_code.set(\"212332030\")\n \n await refund()\n \n\n balances = await tochka.get_balances()\n print(balances[0].amount)\n\n\nasyncio.run(main())\n```\n",
"bugtrack_url": null,
"license": "Mozilla Public License 2.0",
"summary": "Simple Tochka Bank Open API client",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/WhiteApfel/tochka_api",
"Source code": "https://github.com/WhiteApfel/tochka-api",
"Write me": "https://t.me/whiteapfel"
},
"split_keywords": [
"tochka",
"openapi",
"api",
"bank"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "accb9d315b3b646269e81ffe90a39bbfb1fa48a65f3f8347ffde142f5fee8bfe",
"md5": "73304fd6ba5b83b92acb403c7610699b",
"sha256": "1d8b2bf08501d64ed636807c5dfa9d53c5478148eb2fab14f78dc88d09fe9055"
},
"downloads": -1,
"filename": "tochka_api-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "73304fd6ba5b83b92acb403c7610699b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 21157,
"upload_time": "2023-06-09T18:37:10",
"upload_time_iso_8601": "2023-06-09T18:37:10.855369Z",
"url": "https://files.pythonhosted.org/packages/ac/cb/9d315b3b646269e81ffe90a39bbfb1fa48a65f3f8347ffde142f5fee8bfe/tochka_api-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "937b824abc0b87453ca5703241e3a34b8f58edf29ef8d5ab6f7415def4606c51",
"md5": "cc16ccf1dad5ab21ad486fcf75075f8b",
"sha256": "eb93070d9c668fdcd427a95a8186604cd487b9277de5e55fbf2e0085aad4a61d"
},
"downloads": -1,
"filename": "tochka_api-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "cc16ccf1dad5ab21ad486fcf75075f8b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18908,
"upload_time": "2023-06-09T18:37:12",
"upload_time_iso_8601": "2023-06-09T18:37:12.210935Z",
"url": "https://files.pythonhosted.org/packages/93/7b/824abc0b87453ca5703241e3a34b8f58edf29ef8d5ab6f7415def4606c51/tochka_api-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-09 18:37:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "WhiteApfel",
"github_project": "tochka_api",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pydantic",
"specs": [
[
"~=",
"1.10.1"
]
]
},
{
"name": "httpx",
"specs": [
[
"~=",
"0.23.0"
]
]
},
{
"name": "ujson",
"specs": [
[
"~=",
"5.4.0"
]
]
},
{
"name": "appdirs",
"specs": [
[
"~=",
"1.4.4"
]
]
}
],
"lcname": "tochka-api"
}