fix(payments): open_url_direct payment URL opens externally in Telegram (#654272)

The reported #654272 case ('функция немедленного открытия ссылки', reproduced on RollyPay AND YooKassa, fine on desktop) is the open_url_direct flow — not the connection deep-link opener fixed in 325e221.

When a payment method has open_url_direct, the cabinet did window.location.href = payment_url INSIDE the Telegram in-app WebView. SBP/RollyPay/YooKassa pages then hand off to a bank app via a custom scheme, which the WebView can't open: Android shows net::ERR_UNKNOWN_URL_SCHEME, iOS opens nothing ('приложение не определяется'); link generation logs fine. Desktop works because it's a real browser.

Add openPaymentUrl(): in Telegram open via openLink (external browser — the OS hands off to the bank app, return_url brings the user back); on web keep same-tab navigation (no popup blocker). Applied to TopUpAmount (top-up) and GiftSubscription (gift purchase). QuickPurchase is a web landing page (no platform abstraction) and is unaffected.
This commit is contained in:
c0mrade
2026-06-08 14:21:45 +03:00
parent 325e221e32
commit ce5737fcbc
3 changed files with 35 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ import type { PaymentMethod, PaymentMethodOption } from '../types';
import BentoCard from '../components/ui/BentoCard';
import { saveTopUpPendingInfo } from '../utils/topUpStorage';
import { getSafeRedirectPath } from '../utils/safeRedirect';
import { openPaymentUrl } from '../utils/openPaymentUrl';
import { copyToClipboard } from '@/utils/clipboard';
import {
CardIcon,
@@ -245,7 +246,11 @@ export default function TopUpAmount() {
lowerUrl.startsWith('http://t.me/') ||
lowerUrl.startsWith('tg://');
if (method?.open_url_direct && !isTelegramDeepLink) {
window.location.href = redirectUrl;
// In the Telegram WebView, same-container navigation to the provider page breaks
// when it hands off to a bank app via a custom scheme (SBP) — Android shows
// ERR_UNKNOWN_URL_SCHEME, iOS opens nothing (bug #654272). Open externally there;
// on web keep same-tab navigation.
openPaymentUrl(redirectUrl, platform, openLink);
return;
}