Validate saved information on payment form open.
This commit is contained in:
parent
212497413c
commit
994dbf9eb5
|
@ -101,8 +101,14 @@ not_null<Ui::PanelDelegate*> CheckoutProcess::panelDelegate() {
|
|||
|
||||
void CheckoutProcess::handleFormUpdate(const FormUpdate &update) {
|
||||
v::match(update.data, [&](const FormReady &) {
|
||||
showForm();
|
||||
performInitialSilentValidation();
|
||||
if (!_initialSilentValidation) {
|
||||
showForm();
|
||||
}
|
||||
}, [&](const ValidateFinished &) {
|
||||
if (_initialSilentValidation) {
|
||||
_initialSilentValidation = false;
|
||||
}
|
||||
showForm();
|
||||
if (_submitState == SubmitState::Validation) {
|
||||
_submitState = SubmitState::Validated;
|
||||
|
@ -156,6 +162,11 @@ void CheckoutProcess::handleError(const Error &error) {
|
|||
if (_submitState == SubmitState::Validation) {
|
||||
_submitState = SubmitState::None;
|
||||
}
|
||||
if (_initialSilentValidation) {
|
||||
_initialSilentValidation = false;
|
||||
showForm();
|
||||
return;
|
||||
}
|
||||
if (id == u"REQ_INFO_NAME_INVALID"_q) {
|
||||
showEditError(Ui::EditField::Name);
|
||||
} else if (id == u"REQ_INFO_EMAIL_INVALID"_q) {
|
||||
|
@ -373,6 +384,19 @@ void CheckoutProcess::panelShowBox(object_ptr<Ui::BoxContent> box) {
|
|||
_panel->showBox(std::move(box));
|
||||
}
|
||||
|
||||
void CheckoutProcess::performInitialSilentValidation() {
|
||||
const auto &invoice = _form->invoice();
|
||||
const auto &saved = _form->savedInformation();
|
||||
if ((invoice.isNameRequested && saved.name.isEmpty())
|
||||
|| (invoice.isEmailRequested && saved.email.isEmpty())
|
||||
|| (invoice.isPhoneRequested && saved.phone.isEmpty())
|
||||
|| (invoice.isShippingAddressRequested && !saved.shippingAddress)) {
|
||||
return;
|
||||
}
|
||||
_initialSilentValidation = true;
|
||||
_form->validateInformation(saved);
|
||||
}
|
||||
|
||||
QString CheckoutProcess::webviewDataPath() const {
|
||||
return _session->domain().local().webviewDataPath();
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ private:
|
|||
void showEditError(Ui::EditField field);
|
||||
void chooseShippingOption();
|
||||
|
||||
void performInitialSilentValidation();
|
||||
[[nodiscard]] QString webviewDataPath() const;
|
||||
|
||||
void panelRequestClose() override;
|
||||
|
@ -84,6 +85,7 @@ private:
|
|||
const std::unique_ptr<Ui::Panel> _panel;
|
||||
std::unique_ptr<Ui::WebviewWindow> _webviewWindow;
|
||||
SubmitState _submitState = SubmitState::None;
|
||||
bool _initialSilentValidation = false;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
|
Loading…
Reference in New Issue