2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Improve checkout information / card page design.

This commit is contained in:
John Preston
2021-03-26 19:23:12 +04:00
parent fafea73ea7
commit 47fdef1e38
13 changed files with 468 additions and 319 deletions

View File

@@ -87,6 +87,7 @@ CheckoutProcess::CheckoutProcess(
) | rpl::start_with_next([=] {
showForm();
}, _panel->lifetime());
showForm();
}
CheckoutProcess::~CheckoutProcess() {
@@ -156,7 +157,7 @@ void CheckoutProcess::handleError(const Error &error) {
showToast({ "Error: " + id });
}
break;
case Error::Type::Validate:
case Error::Type::Validate: {
if (_submitState == SubmitState::Validation) {
_submitState = SubmitState::None;
}
@@ -189,7 +190,21 @@ void CheckoutProcess::handleError(const Error &error) {
} else {
showToast({ "Error: " + id });
}
break;
} break;
case Error::Type::Stripe: {
using Field = Ui::CardField;
if (id == u"InvalidNumber"_q || id == u"IncorrectNumber"_q) {
showCardError(Field::Number);
} else if (id == u"InvalidCVC"_q || id == u"IncorrectCVC"_q) {
showCardError(Field::CVC);
} else if (id == u"InvalidExpiryMonth"_q
|| id == u"InvalidExpiryYear"_q
|| id == u"ExpiredCard"_q) {
showCardError(Field::ExpireDate);
} else {
showToast({ "Error: " + id });
}
} break;
case Error::Type::Send:
if (_submitState == SubmitState::Finishing) {
_submitState = SubmitState::None;
@@ -375,6 +390,13 @@ void CheckoutProcess::showInformationError(Ui::InformationField field) {
field);
}
void CheckoutProcess::showCardError(Ui::CardField field) {
if (_submitState != SubmitState::None) {
return;
}
_panel->showCardError(_form->paymentMethod().ui.native, field);
}
void CheckoutProcess::chooseShippingOption() {
_panel->chooseShippingOption(_form->shippingOptions());
}