Payment: Show error on invalid link (#5875)

This commit is contained in:
zubiden 2025-05-14 19:01:46 +03:00 committed by Alexander Zinchuk
parent e41619fd23
commit dc722a9cc2
3 changed files with 37 additions and 20 deletions

View File

@ -742,6 +742,7 @@
"PollsStopWarning" = "If you stop this poll now, nobody will be able to vote in it anymore. This action cannot be undone.";
"PollsStopSure" = "Stop";
"PaymentTestInvoice" = "TEST INVOICE";
"PaymentInvoiceNotFound" = "Invoice not found";
"AttachLiveLocation" = "Live Location";
"NoWordsRecognized" = "No words recognized.";
"ViaBot" = "via";

View File

@ -97,6 +97,8 @@ addActionHandler('openInvoice', async (global, actions, payload): Promise<void>
if ('error' in form) {
setGlobal(global);
handlePaymentFormError(form.error, tabId);
return;
}
@ -1099,7 +1101,7 @@ async function payInputStarInvoice<T extends GlobalState>(
setGlobal(global);
if ('error' in form) {
actions.showDialog({ data: { message: form.error || 'Error', hasErrorKey: true }, tabId });
handlePaymentFormError(form.error, tabId);
return;
}
@ -1179,3 +1181,17 @@ addActionHandler('processStarGiftWithdrawal', async (global, actions, payload):
actions.openUrl({ url: result.url, shouldSkipModal: true, tabId });
actions.closeGiftWithdrawModal({ tabId });
});
function handlePaymentFormError(error: string, tabId: number) {
if (error === 'SLUG_INVALID') {
getActions().showNotification({
message: {
key: 'PaymentInvoiceNotFound',
},
tabId,
});
return;
}
getActions().showDialog({ data: { message: error, hasErrorKey: true }, tabId });
}

View File

@ -654,6 +654,7 @@ export interface LangPair {
'PollsStopWarning': undefined;
'PollsStopSure': undefined;
'PaymentTestInvoice': undefined;
'PaymentInvoiceNotFound': undefined;
'AttachLiveLocation': undefined;
'NoWordsRecognized': undefined;
'ViaBot': undefined;
@ -981,7 +982,6 @@ export interface LangPair {
'ChatListFilterErrorEmpty': undefined;
'ChatListFilterErrorTitleEmpty': undefined;
'FilterMuted': undefined;
'ReadFolder': undefined;
'FilterRead': undefined;
'FilterArchived': undefined;
'GroupsAndChannelsLimitTitle': undefined;
@ -1284,14 +1284,25 @@ export interface LangPair {
'PrivacyGiftsInfo': undefined;
'PrivacyAcceptedGiftTitle': undefined;
'PrivacyAcceptedGiftInfo': undefined;
'PrivacyDisplayGiftsButton': undefined;
'PrivacyDisplayGift': undefined;
'SendDisallowError': undefined;
'PrivacyValueBots': undefined;
'PrivacyGiftLimitedEdition': undefined;
'PrivacyGiftUnlimited': undefined;
'PrivacyGiftUnique': undefined;
'PrivacyGiftPremiumSubscription': undefined;
'PrivacyDisplayGiftsButton': undefined;
'PrivacyDisplayGift': undefined;
'SendDisallowError': undefined;
'PrivacySubscribeToTelegramPremium': undefined;
'PrivacyDisableLimitedEditionStarGifts': undefined;
'PrivacyEnableLimitedEditionStarGifts': undefined;
'PrivacyDisableUnlimitedStarGifts': undefined;
'PrivacyEnableUnlimitedStarGifts': undefined;
'PrivacyDisableUniqueStarGifts': undefined;
'PrivacyEnableUniqueStarGifts': undefined;
'PrivacyDisablePremiumGifts': undefined;
'PrivacyEnablePremiumGifts': undefined;
'DisplayGiftsButton': undefined;
'HideGiftsButton': undefined;
'CustomShareGiftsInfo': undefined;
'AllChatsSearchContext': undefined;
'PrivateChatsSearchContext': undefined;
@ -1479,17 +1490,6 @@ export interface LangPair {
'GroupMessagesChargePrice': undefined;
'RightsChargeStarsAbout': undefined;
'UnlockButtonTitle': undefined;
'PrivacySubscribeToTelegramPremium': undefined;
'PrivacyDisableLimitedEditionStarGifts': undefined;
'PrivacyEnableLimitedEditionStarGifts': undefined;
'PrivacyDisableUnlimitedStarGifts': undefined;
'PrivacyEnableUnlimitedStarGifts': undefined;
'PrivacyDisableUniqueStarGifts': undefined;
'PrivacyEnableUniqueStarGifts': undefined;
'PrivacyDisablePremiumGifts': undefined;
'PrivacyEnablePremiumGifts': undefined;
'DisplayGiftsButton': undefined;
'HideGiftsButton': undefined;
'FrozenAccountModalTitle': undefined;
'FrozenAccountViolationTitle': undefined;
'FrozenAccountViolationSubtitle': undefined;
@ -1579,10 +1579,6 @@ export interface LangPairWithVariables<V extends unknown = LangVariable> {
'SpeakingWithVolume': {
'volume': V;
};
'PrivacyDisplayGiftIconInChats':{
'icon': V;
'gift': V;
};
'CallEmojiKeyTooltip': {
'user': V;
};
@ -2002,6 +1998,10 @@ export interface LangPairWithVariables<V extends unknown = LangVariable> {
'bot': V;
'filename': V;
};
'PrivacyDisplayGiftIconInChats': {
'icon': V;
'gift': V;
};
'StarsSubscribeBotButtonMonth': {
'amount': V;
};