feat: update changelog for new payment methods; add UserNotFoundError handling in purchase flows

This commit is contained in:
bohd4nx
2026-05-30 00:17:06 +03:00
parent d01c45d85b
commit b85b34f2b1
5 changed files with 20 additions and 6 deletions
+4
View File
@@ -59,6 +59,8 @@ async def purchase_stars(
try:
result = await client.call("searchStarsRecipient", {"query": username, "quantity": ""}, page_url=STARS_PAGE)
if "assigned to a user" in str(result.get("error", "")).lower():
raise UserNotFoundError(UserNotFoundError.NOT_A_USER.format(username=username))
recipient = result.get("found", {}).get("recipient")
if not recipient:
raise UserNotFoundError(UserNotFoundError.NOT_FOUND.format(username=username))
@@ -140,6 +142,8 @@ async def purchase_premium(
try:
result = await client.call("searchPremiumGiftRecipient", {"query": username, "months": months}, page_url=PREMIUM_PAGE)
if "assigned to a user" in str(result.get("error", "")).lower():
raise UserNotFoundError(UserNotFoundError.NOT_A_USER.format(username=username))
recipient = result.get("found", {}).get("recipient")
if not recipient:
raise UserNotFoundError(UserNotFoundError.NOT_FOUND.format(username=username))
+1
View File
@@ -94,6 +94,7 @@ class UserNotFoundError(FragmentAPIError):
NOT_FOUND = (
"Telegram user '{username}' was not found on Fragment. Double-check the username and make sure the account exists."
)
NOT_A_USER = "'{username}' does not belong to a user account. Make sure the username is assigned to a personal Telegram account, not a channel or bot."
class AlreadySubscribedError(FragmentAPIError):
+2
View File
@@ -17,6 +17,8 @@ else:
class PaymentMethod(StrEnum):
TON = "ton"
USDT_TON = "usdt_ton"
# Not supported yet
USDT_ETH = "usdt_eth"
USDT_POL = "usdt_pol"
USDC_ETH = "usdc_eth"