tdesktop/Telegram/SourceFiles/payments/payments_checkout_process.h

103 lines
2.5 KiB
C
Raw Normal View History

2021-03-23 12:34:34 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "payments/ui/payments_panel_delegate.h"
#include "base/weak_ptr.h"
class HistoryItem;
namespace Stripe {
class APIClient;
} // namespace Stripe
2021-03-23 12:34:34 +00:00
namespace Main {
class Session;
} // namespace Main
namespace Payments::Ui {
class Panel;
class WebviewWindow;
enum class InformationField;
2021-03-23 12:34:34 +00:00
} // namespace Payments::Ui
namespace Payments {
class Form;
struct FormUpdate;
struct Error;
2021-03-23 12:34:34 +00:00
class CheckoutProcess final
: public base::has_weak_ptr
, private Ui::PanelDelegate {
struct PrivateTag {};
public:
static void Start(not_null<const HistoryItem*> item);
CheckoutProcess(
not_null<Main::Session*> session,
FullMsgId itemId,
PrivateTag);
~CheckoutProcess();
void requestActivate();
private:
enum class SubmitState {
None,
Validation,
Validated,
Finishing,
};
2021-03-23 12:34:34 +00:00
[[nodiscard]] not_null<PanelDelegate*> panelDelegate();
void handleFormUpdate(const FormUpdate &update);
void handleError(const Error &error);
2021-03-23 12:34:34 +00:00
void showForm();
void showEditInformation(Ui::InformationField field);
void showInformationError(Ui::InformationField field);
void chooseShippingOption();
void editPaymentMethod();
void performInitialSilentValidation();
[[nodiscard]] QString webviewDataPath() const;
2021-03-23 12:34:34 +00:00
void panelRequestClose() override;
void panelCloseSure() override;
void panelSubmit() override;
void panelWebviewMessage(const QJsonDocument &message) override;
bool panelWebviewNavigationAttempt(const QString &uri) override;
void panelEditPaymentMethod() override;
void panelEditShippingInformation() override;
void panelEditName() override;
void panelEditEmail() override;
void panelEditPhone() override;
void panelChooseShippingOption() override;
void panelChangeShippingOption(const QString &id) override;
void panelValidateInformation(Ui::RequestedInformation data) override;
void panelValidateCard(Ui::UncheckedCardDetails data) override;
void panelShowBox(object_ptr<Ui::BoxContent> box) override;
2021-03-23 12:34:34 +00:00
const not_null<Main::Session*> _session;
const std::unique_ptr<Form> _form;
const std::unique_ptr<Ui::Panel> _panel;
std::unique_ptr<Ui::WebviewWindow> _webviewWindow;
std::unique_ptr<Stripe::APIClient> _stripe;
SubmitState _submitState = SubmitState::None;
bool _initialSilentValidation = false;
2021-03-23 12:34:34 +00:00
rpl::lifetime _lifetime;
};
} // namespace Payments