diff --git a/Telegram/SourceFiles/payments/payments_form.cpp b/Telegram/SourceFiles/payments/payments_form.cpp index b2133bbe0..036b91c96 100644 --- a/Telegram/SourceFiles/payments/payments_form.cpp +++ b/Telegram/SourceFiles/payments/payments_form.cpp @@ -126,6 +126,7 @@ void Form::fillInvoiceFromMessage() { return item->media(); }(); if (const auto invoice = media ? media->invoice() : nullptr) { + _invoice.isTest = invoice->isTest; _invoice.cover = Ui::Cover{ .title = invoice->title, .description = invoice->description, diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.cpp b/Telegram/SourceFiles/payments/ui/payments_panel.cpp index 885e74a00..110809014 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp @@ -56,7 +56,8 @@ void Panel::showForm( const RequestedInformation ¤t, const PaymentMethodDetails &method, const ShippingOptions &options) { - _widget->setTitle(invoice.receipt + _testMode = invoice.isTest; + setTitle(invoice.receipt ? tr::lng_payments_receipt_title() : tr::lng_payments_checkout_title()); auto form = base::make_unique_q( @@ -81,7 +82,7 @@ void Panel::showEditInformation( const Invoice &invoice, const RequestedInformation ¤t, InformationField field) { - _widget->setTitle(tr::lng_payments_shipping_address_title()); + setTitle(tr::lng_payments_shipping_address_title()); auto edit = base::make_unique_q( _widget.get(), invoice, @@ -240,7 +241,7 @@ void Panel::showEditPaymentMethod(const PaymentMethodDetails &method) { : tr::lng_payments_processed_by( lt_provider, rpl::single(method.provider)); - _widget->setTitle(tr::lng_payments_card_title()); + setTitle(tr::lng_payments_card_title()); if (method.native.supported) { showEditCard(method.native, CardField::Number); } else if (!showWebview(method.url, true, std::move(bottomText))) { @@ -419,6 +420,15 @@ void Panel::showCardError( } } +void Panel::setTitle(rpl::producer title) { + using namespace rpl::mappers; + if (_testMode) { + _widget->setTitle(std::move(title) | rpl::map(_1 + " (Test)")); + } else { + _widget->setTitle(std::move(title)); + } +} + rpl::producer<> Panel::backRequests() const { return _widget->backRequests(); } diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.h b/Telegram/SourceFiles/payments/ui/payments_panel.h index 01cb5a490..afe5d72e5 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.h +++ b/Telegram/SourceFiles/payments/ui/payments_panel.h @@ -83,6 +83,7 @@ public: private: bool createWebview(); + void setTitle(rpl::producer title); const not_null _delegate; std::unique_ptr _widget; @@ -92,6 +93,7 @@ private: QPointer _weakFormSummary; QPointer _weakEditInformation; QPointer _weakEditCard; + bool _testMode = false; };