Библиотека полностью повтраяет структуру вложоности https://docs.crystalpay.io/
Создания счета & проверка(не рекомендуеться иза лимита)
from aiocrystal import CrystalPay
from aiocrystal.utils.types import InvoiceState
import asyncio
cp=CrystalPay(auth_login='name',
auth_secret='Secret',
salt='salt'
)
async def main():
invoice=await cp.invoice.create(amount=100, description='aiocrystal<3')
invoice_id=invoice.id
print(invoice.url)
while True:
invoice_state=(await cp.invoice.info(invoice_id)).state
if InvoiceState.payed == invoice_state:
print('Succes')
break
await asyncio.sleep(5)
asyncio.run(main())
WebHook Fastapi & пример фильтров
from typing import Union
from fastapi import FastAPI
from aiocrystal.v3.async_crystal import CrystalPay
from aiocrystal.utils.types import CallbackInvoice, InvoiceState
from aiocrystal.webhook import FastApiManager
import uvicorn
import asyncio
host=''
app = FastAPI()
cp=CrystalPay(auth_login='name',
auth_secret='Secret',
salt='Salt',
webhook_manager=FastApiManager(
app_fastapi=app,
end_point_invoice='/pay/crystalpay'
)
)
# пример фильтрации
async def IsPayed(invoice: CallbackInvoice):
return invoice.rub_amount >= 100
async def AntiUnavailableIsPayed(invoice: CallbackInvoice):
return invoice.state == InvoiceState.payed
@cp.callback_invoice(IsPayed, AntiUnavailableIsPayed) #<- вохможность добавлять несколько фильтров
async def pay_cp(invoice: CallbackInvoice):
print(f'Пришло: {invoice.rub_amount}')
async def main():
invoice=await cp.invoice.create(100, callback_url=f'{host}/pay/crystalpay')
print(invoice.url)
asyncio.run(main())
uvicorn.run(app, host="localhost", port=5000)
Release files for aiocrystal 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiocrystal-0.1.1.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiocrystal-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.5 kB
Release files / aiocrystal-0.1.1.tar.gz
| Download URL | aiocrystal-0.1.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1daead0865d59620ae403edd9f4b3be0ea100275cabc054af65f78c0ba52ee89
|
|
BLAKE2b-256 checksum How to use checksums |
035b7088b40d9534eba45c7e0d457e8e5180575ff08ba2f3067c7230a746c21a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / aiocrystal-0.1.1-py3-none-any.whl
| Download URL | aiocrystal-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8e369eef073b36b3b0044039db3f93b8d44f5b50eaee645d9e9c3409be89c19
|
|
BLAKE2b-256 checksum How to use checksums |
beabf5e033b8188332c361f8560eaf6d83d3c2c324ec77b7581be71af1523594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|