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
        }
