mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Always show footer in webview in payments.
This commit is contained in:
parent
cd4a9d7c16
commit
491ec2db7f
8 changed files with 48 additions and 8 deletions
|
@ -1879,9 +1879,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_payments_info_name" = "Name";
|
||||
"lng_payments_info_email" = "Email";
|
||||
"lng_payments_info_phone" = "Phone";
|
||||
"lng_payments_to_provider_phone_email" = "Phone and Email will be passed to {bot_name} as billing info.";
|
||||
"lng_payments_to_provider_email" = "Email will be passed to {bot_name} as billing info.";
|
||||
"lng_payments_to_provider_phone" = "Phone will be passed to {bot_name} as billing info.";
|
||||
"lng_payments_to_provider_phone_email" = "Phone and Email will be passed to {provider} as billing info.";
|
||||
"lng_payments_to_provider_email" = "Email will be passed to {provider} as billing info.";
|
||||
"lng_payments_to_provider_phone" = "Phone will be passed to {provider} as billing info.";
|
||||
"lng_payments_processed_by" = "Processed by {provider}";
|
||||
"lng_payments_warning_title" = "Warning";
|
||||
"lng_payments_warning_body" = "Neither Telegram, nor {bot1} will have access to your credit card information. Credit card details will be handled only by the payment system, {provider}.\n\nPayments will go directly to the developer of {bot2}. Telegram cannot provide any guarantees, so proceed at your own risk. In case of problems, please contact the developer of {bot3} or your bank.";
|
||||
"lng_payments_shipping_address_title" = "Shipping Information";
|
||||
"lng_payments_card_title" = "New Card";
|
||||
"lng_payments_card_number" = "Card Number";
|
||||
|
|
|
@ -167,7 +167,10 @@ void CheckoutProcess::handleFormUpdate(const FormUpdate &update) {
|
|||
_submitState = SubmitState::Validated;
|
||||
requestPassword();
|
||||
}, [&](const VerificationNeeded &data) {
|
||||
if (!_panel->showWebview(data.url, false)) {
|
||||
auto bottomText = tr::lng_payments_processed_by(
|
||||
lt_provider,
|
||||
rpl::single(_form->invoice().provider));
|
||||
if (!_panel->showWebview(data.url, false, std::move(bottomText))) {
|
||||
File::OpenUrl(data.url);
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -405,6 +405,7 @@ void Form::refreshPaymentMethodDetails() {
|
|||
const auto &saved = _paymentMethod.savedCredentials;
|
||||
const auto &entered = _paymentMethod.newCredentials;
|
||||
_paymentMethod.ui.title = entered ? entered.title : saved.title;
|
||||
_paymentMethod.ui.provider = _invoice.provider;
|
||||
_paymentMethod.ui.ready = entered || saved;
|
||||
_paymentMethod.ui.native.defaultCountry = defaultCountry();
|
||||
_paymentMethod.ui.canSaveInformation
|
||||
|
|
|
@ -28,6 +28,9 @@ paymentsTitle: FlatLabel(paymentsDescription) {
|
|||
paymentsSeller: FlatLabel(paymentsDescription) {
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
paymentsWebviewBottom: FlatLabel(defaultFlatLabel) {
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
paymentsPriceLabel: paymentsDescription;
|
||||
paymentsPriceAmount: defaultFlatLabel;
|
||||
paymentsFullPriceLabel: paymentsTitle;
|
||||
|
|
|
@ -189,7 +189,7 @@ not_null<RpWidget*> EditInformation::setupContent() {
|
|||
: emailToProvider
|
||||
? tr::lng_payments_to_provider_email
|
||||
: tr::lng_payments_to_provider_phone)(
|
||||
lt_bot_name,
|
||||
lt_provider,
|
||||
rpl::single(_invoice.provider)),
|
||||
st::paymentsToProviderLabel),
|
||||
st::paymentsToProviderPadding);
|
||||
|
|
|
@ -235,10 +235,15 @@ void Panel::chooseTips(const Invoice &invoice) {
|
|||
}
|
||||
|
||||
void Panel::showEditPaymentMethod(const PaymentMethodDetails &method) {
|
||||
auto bottomText = method.canSaveInformation
|
||||
? rpl::producer<QString>()
|
||||
: tr::lng_payments_processed_by(
|
||||
lt_provider,
|
||||
rpl::single(method.provider));
|
||||
_widget->setTitle(tr::lng_payments_card_title());
|
||||
if (method.native.supported) {
|
||||
showEditCard(method.native, CardField::Number);
|
||||
} else if (!showWebview(method.url, true)) {
|
||||
} else if (!showWebview(method.url, true, std::move(bottomText))) {
|
||||
// #TODO payments errors not supported
|
||||
} else if (method.canSaveInformation) {
|
||||
const auto &padding = st::paymentsPanelPadding;
|
||||
|
@ -255,12 +260,33 @@ void Panel::showEditPaymentMethod(const PaymentMethodDetails &method) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Panel::showWebview(const QString &url, bool allowBack) {
|
||||
bool Panel::showWebview(
|
||||
const QString &url,
|
||||
bool allowBack,
|
||||
rpl::producer<QString> bottomText) {
|
||||
if (!_webview && !createWebview()) {
|
||||
return false;
|
||||
}
|
||||
_webview->navigate(url);
|
||||
_widget->setBackAllowed(allowBack);
|
||||
if (bottomText) {
|
||||
const auto &padding = st::paymentsPanelPadding;
|
||||
const auto label = CreateChild<FlatLabel>(
|
||||
_webviewBottom.get(),
|
||||
std::move(bottomText),
|
||||
st::paymentsWebviewBottom);
|
||||
const auto height = padding.top()
|
||||
+ label->heightNoMargins()
|
||||
+ padding.bottom();
|
||||
rpl::combine(
|
||||
_webviewBottom->widthValue(),
|
||||
label->widthValue()
|
||||
) | rpl::start_with_next([=](int outerWidth, int width) {
|
||||
label->move((outerWidth - width) / 2, padding.top());
|
||||
}, label->lifetime());
|
||||
label->show();
|
||||
_webviewBottom->resize(_webviewBottom->width(), height);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,10 @@ public:
|
|||
void choosePaymentMethod(const PaymentMethodDetails &method);
|
||||
void askSetPassword();
|
||||
|
||||
bool showWebview(const QString &url, bool allowBack);
|
||||
bool showWebview(
|
||||
const QString &url,
|
||||
bool allowBack,
|
||||
rpl::producer<QString> bottomText);
|
||||
|
||||
[[nodiscard]] rpl::producer<> backRequests() const;
|
||||
|
||||
|
|
|
@ -162,6 +162,7 @@ struct PaymentMethodDetails {
|
|||
QString title;
|
||||
NativeMethodDetails native;
|
||||
QString url;
|
||||
QString provider;
|
||||
bool ready = false;
|
||||
bool canSaveInformation = false;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue