Skip to main content

crystlpay easy interaction

Project description

Библиотека полностью повтраяет структуру вложоности 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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiocrystal-0.1.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiocrystal-0.1.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file aiocrystal-0.1.1.tar.gz.

File metadata

  • Download URL: aiocrystal-0.1.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for aiocrystal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1daead0865d59620ae403edd9f4b3be0ea100275cabc054af65f78c0ba52ee89
MD5 4f3ae507cb78b625530beb153d7916a4
BLAKE2b-256 035b7088b40d9534eba45c7e0d457e8e5180575ff08ba2f3067c7230a746c21a

See more details on using hashes here.

File details

Details for the file aiocrystal-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aiocrystal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for aiocrystal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8e369eef073b36b3b0044039db3f93b8d44f5b50eaee645d9e9c3409be89c19
MD5 03f6fa834f180bf189d2ef7760360cee
BLAKE2b-256 beabf5e033b8188332c361f8560eaf6d83d3c2c324ec77b7581be71af1523594

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page