diff --git a/Telegram/SourceFiles/boxes/send_credits_box.cpp b/Telegram/SourceFiles/boxes/send_credits_box.cpp index 309f4833ce..2873b4ffec 100644 --- a/Telegram/SourceFiles/boxes/send_credits_box.cpp +++ b/Telegram/SourceFiles/boxes/send_credits_box.cpp @@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "payments/payments_checkout_process.h" #include "payments/payments_form.h" -#include "payments/payments_form.h" #include "settings/settings_credits_graphics.h" #include "ui/controls/userpic_button.h" #include "ui/effects/premium_graphics.h" diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 03561bdd6f..68da29a3a7 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -610,7 +610,8 @@ void AttachWebView::botHandleInvoice(QString slug) { reactivate, _context ? Payments::ProcessNonPanelPaymentFormFactory( - _context->controller.get()) + _context->controller.get(), + reactivate) : nullptr); } diff --git a/Telegram/SourceFiles/payments/payments_non_panel_process.cpp b/Telegram/SourceFiles/payments/payments_non_panel_process.cpp index 62a3b4681b..efab4dd89f 100644 --- a/Telegram/SourceFiles/payments/payments_non_panel_process.cpp +++ b/Telegram/SourceFiles/payments/payments_non_panel_process.cpp @@ -40,7 +40,8 @@ bool IsCreditsInvoice(not_null item) { } // namespace Fn ProcessNonPanelPaymentFormFactory( - not_null controller) { + not_null controller, + Fn maybeReturnToBot) { return [=](NonPanelPaymentForm form) { using CreditsFormDataPtr = std::shared_ptr; using CreditsReceiptPtr = std::shared_ptr; @@ -51,12 +52,24 @@ Fn ProcessNonPanelPaymentFormFactory( controller->session().user()); const auto sendBox = [=, weak = base::make_weak(controller)] { if (const auto strong = weak.get()) { - controller->uiShow()->show(Box( + const auto unsuccessful = std::make_shared(true); + const auto box = controller->uiShow()->show(Box( Ui::SendCreditsBox, form, crl::guard(strong, [=] { + *unsuccessful = false; Ui::StartFireworks(strong->content()); + if (maybeReturnToBot) { + maybeReturnToBot(CheckoutResult::Paid); + } }))); + box->boxClosing() | rpl::start_with_next([=] { + crl::on_main([=] { + if ((*unsuccessful) && maybeReturnToBot) { + maybeReturnToBot(CheckoutResult::Cancelled); + } + }); + }, box->lifetime()); } }; const auto weak = base::make_weak(controller); diff --git a/Telegram/SourceFiles/payments/payments_non_panel_process.h b/Telegram/SourceFiles/payments/payments_non_panel_process.h index 76939415d2..fb647a72a3 100644 --- a/Telegram/SourceFiles/payments/payments_non_panel_process.h +++ b/Telegram/SourceFiles/payments/payments_non_panel_process.h @@ -15,10 +15,12 @@ class SessionController; namespace Payments { +enum class CheckoutResult; struct NonPanelPaymentForm; Fn ProcessNonPanelPaymentFormFactory( - not_null controller); + not_null controller, + Fn maybeReturnToBot = nullptr); Fn ProcessNonPanelPaymentFormFactory( not_null controller, diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 0cd0ae1a2f..066adf6f04 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -23,7 +23,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_common_session.h" #include "settings/settings_credits_graphics.h" #include "statistics/widgets/chart_header_widget.h" -#include "ui/boxes/boost_box.h" // Ui::StartFireworks. #include "ui/controls/userpic_button.h" #include "ui/effects/credits_graphics.h" #include "ui/effects/premium_graphics.h"