From cd4a9d7c1640463400bb540ddec5d5c84e068c00 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 1 Apr 2021 18:05:46 +0400 Subject: [PATCH] Show 'phone/email passed to provider' in payments. --- Telegram/Resources/langs/lang.strings | 3 +++ .../SourceFiles/payments/payments_form.cpp | 9 +++++++-- .../SourceFiles/payments/ui/payments.style | 3 +++ .../payments/ui/payments_edit_information.cpp | 18 ++++++++++++++++++ .../payments/ui/payments_panel_data.h | 1 + 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 9a59fa5c2a..0594f9d1ba 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1879,6 +1879,9 @@ 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_shipping_address_title" = "Shipping Information"; "lng_payments_card_title" = "New Card"; "lng_payments_card_number" = "Card Number"; diff --git a/Telegram/SourceFiles/payments/payments_form.cpp b/Telegram/SourceFiles/payments/payments_form.cpp index 660f731bcd..614a81232f 100644 --- a/Telegram/SourceFiles/payments/payments_form.cpp +++ b/Telegram/SourceFiles/payments/payments_form.cpp @@ -336,11 +336,16 @@ void Form::processDetails(const MTPDpayments_paymentForm &data) { .canSaveCredentials = data.is_can_save_credentials(), .passwordMissing = data.is_password_missing(), }; - if (_details.botId) { - if (const auto bot = _session->data().userLoaded(_details.botId)) { + if (const auto botId = _details.botId) { + if (const auto bot = _session->data().userLoaded(botId)) { _invoice.cover.seller = bot->name; } } + if (const auto providerId = _details.providerId) { + if (const auto bot = _session->data().userLoaded(providerId)) { + _invoice.provider = bot->name; + } + } } void Form::processDetails(const MTPDpayments_paymentReceipt &data) { diff --git a/Telegram/SourceFiles/payments/ui/payments.style b/Telegram/SourceFiles/payments/ui/payments.style index 5a7ba82148..737c7b836d 100644 --- a/Telegram/SourceFiles/payments/ui/payments.style +++ b/Telegram/SourceFiles/payments/ui/payments.style @@ -89,3 +89,6 @@ paymentTipsErrorLabel: FlatLabel(defaultFlatLabel) { textFg: boxTextFgError; } paymentTipsErrorPadding: margins(22px, 6px, 22px, 0px); + +paymentsToProviderLabel: paymentsShippingPrice; +paymentsToProviderPadding: margins(28px, 6px, 28px, 6px); diff --git a/Telegram/SourceFiles/payments/ui/payments_edit_information.cpp b/Telegram/SourceFiles/payments/ui/payments_edit_information.cpp index 04940544e5..486842957f 100644 --- a/Telegram/SourceFiles/payments/ui/payments_edit_information.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_edit_information.cpp @@ -176,6 +176,24 @@ not_null EditInformation::setupContent() { .defaultPhone = _information.defaultPhone, }); } + const auto emailToProvider = _invoice.isEmailRequested + && _invoice.emailSentToProvider; + const auto phoneToProvider = _invoice.isPhoneRequested + && _invoice.phoneSentToProvider; + if (emailToProvider || phoneToProvider) { + inner->add( + object_ptr( + inner, + ((emailToProvider && phoneToProvider) + ? tr::lng_payments_to_provider_phone_email + : emailToProvider + ? tr::lng_payments_to_provider_email + : tr::lng_payments_to_provider_phone)( + lt_bot_name, + rpl::single(_invoice.provider)), + st::paymentsToProviderLabel), + st::paymentsToProviderPadding); + } _save = inner->add( object_ptr( inner, diff --git a/Telegram/SourceFiles/payments/ui/payments_panel_data.h b/Telegram/SourceFiles/payments/ui/payments_panel_data.h index bfd8b78fe3..6df01a54d2 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel_data.h +++ b/Telegram/SourceFiles/payments/ui/payments_panel_data.h @@ -52,6 +52,7 @@ struct Invoice { bool isFlexible = false; bool isTest = false; + QString provider; bool phoneSentToProvider = false; bool emailSentToProvider = false;