Files
B.Tech-Project-III/negot8/backend/tools/upi_generator.py
2026-04-05 00:43:23 +05:30

17 lines
699 B
Python

from urllib.parse import quote
class UPIGeneratorTool:
name = "generate_upi_link"
async def execute(self, payee_upi: str, payee_name: str, amount: float, note: str = "") -> dict:
# upi.link is a web-based redirect service that opens any UPI app on mobile.
# This format works as a Telegram inline-button URL (https:// required).
upi_link = f"https://upi.link/{quote(payee_upi, safe='')}?amount={amount:.2f}&cu=INR"
if note:
upi_link += f"&remarks={quote(note)}"
return {
"upi_link": upi_link,
"display_text": f"Pay ₹{amount:,.0f} to {payee_name}",
"payee_upi": payee_upi, "amount": amount
}