mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added posting of payment event to webview bot after credits sending.
This commit is contained in:
parent
c0f3d263a3
commit
9a5923676a
5 changed files with 20 additions and 6 deletions
|
@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "payments/payments_checkout_process.h"
|
#include "payments/payments_checkout_process.h"
|
||||||
#include "payments/payments_form.h"
|
#include "payments/payments_form.h"
|
||||||
#include "payments/payments_form.h"
|
|
||||||
#include "settings/settings_credits_graphics.h"
|
#include "settings/settings_credits_graphics.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
|
|
|
@ -610,7 +610,8 @@ void AttachWebView::botHandleInvoice(QString slug) {
|
||||||
reactivate,
|
reactivate,
|
||||||
_context
|
_context
|
||||||
? Payments::ProcessNonPanelPaymentFormFactory(
|
? Payments::ProcessNonPanelPaymentFormFactory(
|
||||||
_context->controller.get())
|
_context->controller.get(),
|
||||||
|
reactivate)
|
||||||
: nullptr);
|
: nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ bool IsCreditsInvoice(not_null<HistoryItem*> item) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Fn<void(NonPanelPaymentForm)> ProcessNonPanelPaymentFormFactory(
|
Fn<void(NonPanelPaymentForm)> ProcessNonPanelPaymentFormFactory(
|
||||||
not_null<Window::SessionController*> controller) {
|
not_null<Window::SessionController*> controller,
|
||||||
|
Fn<void(CheckoutResult)> maybeReturnToBot) {
|
||||||
return [=](NonPanelPaymentForm form) {
|
return [=](NonPanelPaymentForm form) {
|
||||||
using CreditsFormDataPtr = std::shared_ptr<CreditsFormData>;
|
using CreditsFormDataPtr = std::shared_ptr<CreditsFormData>;
|
||||||
using CreditsReceiptPtr = std::shared_ptr<CreditsReceiptData>;
|
using CreditsReceiptPtr = std::shared_ptr<CreditsReceiptData>;
|
||||||
|
@ -51,12 +52,24 @@ Fn<void(NonPanelPaymentForm)> ProcessNonPanelPaymentFormFactory(
|
||||||
controller->session().user());
|
controller->session().user());
|
||||||
const auto sendBox = [=, weak = base::make_weak(controller)] {
|
const auto sendBox = [=, weak = base::make_weak(controller)] {
|
||||||
if (const auto strong = weak.get()) {
|
if (const auto strong = weak.get()) {
|
||||||
controller->uiShow()->show(Box(
|
const auto unsuccessful = std::make_shared<bool>(true);
|
||||||
|
const auto box = controller->uiShow()->show(Box(
|
||||||
Ui::SendCreditsBox,
|
Ui::SendCreditsBox,
|
||||||
form,
|
form,
|
||||||
crl::guard(strong, [=] {
|
crl::guard(strong, [=] {
|
||||||
|
*unsuccessful = false;
|
||||||
Ui::StartFireworks(strong->content());
|
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);
|
const auto weak = base::make_weak(controller);
|
||||||
|
|
|
@ -15,10 +15,12 @@ class SessionController;
|
||||||
|
|
||||||
namespace Payments {
|
namespace Payments {
|
||||||
|
|
||||||
|
enum class CheckoutResult;
|
||||||
struct NonPanelPaymentForm;
|
struct NonPanelPaymentForm;
|
||||||
|
|
||||||
Fn<void(NonPanelPaymentForm)> ProcessNonPanelPaymentFormFactory(
|
Fn<void(NonPanelPaymentForm)> ProcessNonPanelPaymentFormFactory(
|
||||||
not_null<Window::SessionController*> controller);
|
not_null<Window::SessionController*> controller,
|
||||||
|
Fn<void(Payments::CheckoutResult)> maybeReturnToBot = nullptr);
|
||||||
|
|
||||||
Fn<void(NonPanelPaymentForm)> ProcessNonPanelPaymentFormFactory(
|
Fn<void(NonPanelPaymentForm)> ProcessNonPanelPaymentFormFactory(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
|
|
@ -23,7 +23,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/settings_common_session.h"
|
#include "settings/settings_common_session.h"
|
||||||
#include "settings/settings_credits_graphics.h"
|
#include "settings/settings_credits_graphics.h"
|
||||||
#include "statistics/widgets/chart_header_widget.h"
|
#include "statistics/widgets/chart_header_widget.h"
|
||||||
#include "ui/boxes/boost_box.h" // Ui::StartFireworks.
|
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/effects/credits_graphics.h"
|
#include "ui/effects/credits_graphics.h"
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
|
|
Loading…
Add table
Reference in a new issue