generate_pay_link
Generates a Payme checkout URL that redirects the user to the payment page.
Usage
link = payme.generate_pay_link(
amount=1000, # in UZS
account={"order_id": 1},
return_url="https://example.com/success",
)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount |
int |
Yes | Amount in UZS — will be converted to tiyin automatically |
account |
dict |
Yes | Account fields that will be passed to your handlers via ctx.account |
return_url |
str |
No | URL to redirect after payment |
Sandbox vs Production
The generated URL depends on the sandbox setting:
# sandbox=True
# https://checkout.test.paycom.uz/...
# sandbox=False
# https://checkout.paycom.uz/...
Example with aiogram
from aiogram import Router
from aiogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
from aiogram.filters import Command
from app.deps import get_payme
router = Router()
@router.message(Command("pay"))
async def cmd_pay(message: Message):
link = get_payme().generate_pay_link(
amount=1000,
account={"order_id": 1, "chat_id": message.chat.id},
return_url="https://t.me/your_bot",
)
await message.answer(
"Follow the link to complete your payment:",
reply_markup=InlineKeyboardMarkup(inline_keyboard=[[
InlineKeyboardButton(text="Pay", url=link)
]])
)