mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Partly reverted "Processed payments form with API scheme on layer 181.".
This commit is contained in:
parent
e4e343b871
commit
d73313479b
2 changed files with 47 additions and 71 deletions
|
@ -377,7 +377,7 @@ void Form::requestForm() {
|
||||||
)).done([=](const MTPpayments_PaymentForm &result) {
|
)).done([=](const MTPpayments_PaymentForm &result) {
|
||||||
hideProgress();
|
hideProgress();
|
||||||
result.match([&](const MTPDpayments_paymentForm &data) {
|
result.match([&](const MTPDpayments_paymentForm &data) {
|
||||||
processForm(result);
|
processForm(data);
|
||||||
}, [&](const MTPDpayments_paymentFormStars &data) {
|
}, [&](const MTPDpayments_paymentFormStars &data) {
|
||||||
_session->data().processUsers(data.vusers());
|
_session->data().processUsers(data.vusers());
|
||||||
const auto currency = qs(data.vinvoice().data().vcurrency());
|
const auto currency = qs(data.vinvoice().data().vcurrency());
|
||||||
|
@ -437,44 +437,33 @@ void Form::requestReceipt() {
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Form::processForm(const MTPpayments_PaymentForm &result) {
|
void Form::processForm(const MTPDpayments_paymentForm &data) {
|
||||||
using TLForm = MTPDpayments_paymentForm;
|
_session->data().processUsers(data.vusers());
|
||||||
using TLCredits = MTPDpayments_paymentFormStars;
|
|
||||||
result.match([&](const auto &data) {
|
|
||||||
_session->data().processUsers(data.vusers());
|
|
||||||
|
|
||||||
data.vinvoice().match([&](const auto &data) {
|
data.vinvoice().match([&](const auto &data) {
|
||||||
processInvoice(data);
|
processInvoice(data);
|
||||||
|
});
|
||||||
|
processDetails(data);
|
||||||
|
if (const auto info = data.vsaved_info()) {
|
||||||
|
info->match([&](const auto &data) {
|
||||||
|
processSavedInformation(data);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
processDetails(result);
|
|
||||||
result.match([&](const TLForm &data) {
|
|
||||||
if (const auto info = data.vsaved_info()) {
|
|
||||||
info->match([&](const auto &data) {
|
|
||||||
processSavedInformation(data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [](const TLCredits &) {
|
|
||||||
});
|
|
||||||
_paymentMethod.savedCredentials.clear();
|
_paymentMethod.savedCredentials.clear();
|
||||||
_paymentMethod.savedCredentialsIndex = 0;
|
_paymentMethod.savedCredentialsIndex = 0;
|
||||||
result.match([&](const TLForm &data) {
|
if (const auto credentials = data.vsaved_credentials()) {
|
||||||
if (const auto credentials = data.vsaved_credentials()) {
|
_paymentMethod.savedCredentials.reserve(credentials->v.size());
|
||||||
_paymentMethod.savedCredentials.reserve(credentials->v.size());
|
for (const auto &saved : credentials->v) {
|
||||||
for (const auto &saved : credentials->v) {
|
_paymentMethod.savedCredentials.push_back({
|
||||||
_paymentMethod.savedCredentials.push_back({
|
.id = qs(saved.data().vid()),
|
||||||
.id = qs(saved.data().vid()),
|
.title = qs(saved.data().vtitle()),
|
||||||
.title = qs(saved.data().vtitle()),
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
refreshPaymentMethodDetails();
|
|
||||||
}
|
}
|
||||||
if (const auto additional = data.vadditional_methods()) {
|
refreshPaymentMethodDetails();
|
||||||
processAdditionalPaymentMethods(additional->v);
|
}
|
||||||
}
|
if (const auto additional = data.vadditional_methods()) {
|
||||||
}, [](const TLCredits &) {
|
processAdditionalPaymentMethods(additional->v);
|
||||||
});
|
}
|
||||||
fillPaymentMethodInformation();
|
fillPaymentMethodInformation();
|
||||||
_updates.fire(FormReady{});
|
_updates.fire(FormReady{});
|
||||||
}
|
}
|
||||||
|
@ -548,44 +537,31 @@ void Form::processInvoice(const MTPDinvoice &data) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Form::processDetails(const MTPpayments_PaymentForm &result) {
|
void Form::processDetails(const MTPDpayments_paymentForm &data) {
|
||||||
using TLForm = MTPDpayments_paymentForm;
|
const auto nativeParams = data.vnative_params();
|
||||||
using TLCredits = MTPDpayments_paymentFormStars;
|
auto nativeParamsJson = nativeParams
|
||||||
_details = result.match([&](const TLForm &data) {
|
? nativeParams->match(
|
||||||
const auto nativeParams = data.vnative_params();
|
[&](const MTPDdataJSON &data) { return data.vdata().v; })
|
||||||
auto nativeParamsJson = nativeParams
|
: QByteArray();
|
||||||
? nativeParams->match(
|
_details = FormDetails{
|
||||||
[&](const MTPDdataJSON &data) { return data.vdata().v; })
|
.formId = data.vform_id().v,
|
||||||
: QByteArray();
|
.url = qs(data.vurl()),
|
||||||
return FormDetails{
|
.nativeProvider = qs(data.vnative_provider().value_or_empty()),
|
||||||
.formId = data.vform_id().v,
|
.nativeParamsJson = std::move(nativeParamsJson),
|
||||||
.url = qs(data.vurl()),
|
.botId = data.vbot_id().v,
|
||||||
.nativeProvider = qs(data.vnative_provider().value_or_empty()),
|
.providerId = data.vprovider_id().v,
|
||||||
.nativeParamsJson = std::move(nativeParamsJson),
|
.canSaveCredentials = data.is_can_save_credentials(),
|
||||||
.botId = data.vbot_id().v,
|
.passwordMissing = data.is_password_missing(),
|
||||||
.providerId = data.vprovider_id().v,
|
};
|
||||||
.canSaveCredentials = data.is_can_save_credentials(),
|
_invoice.cover.title = qs(data.vtitle());
|
||||||
.passwordMissing = data.is_password_missing(),
|
|
||||||
};
|
|
||||||
}, [](const TLCredits &data) {
|
|
||||||
return FormDetails{
|
|
||||||
.formId = data.vform_id().v,
|
|
||||||
.botId = data.vbot_id().v,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
_invoice.cover.title = result.match([](const auto &data) {
|
|
||||||
return qs(data.vtitle());
|
|
||||||
});
|
|
||||||
_invoice.cover.description = TextUtilities::ParseEntities(
|
_invoice.cover.description = TextUtilities::ParseEntities(
|
||||||
result.match([](const auto &d) { return qs(d.vdescription()); }),
|
qs(data.vdescription()),
|
||||||
TextParseLinks | TextParseMultiline);
|
TextParseLinks | TextParseMultiline);
|
||||||
if (_invoice.cover.thumbnail.isNull() && !_thumbnailLoadProcess) {
|
if (_invoice.cover.thumbnail.isNull() && !_thumbnailLoadProcess) {
|
||||||
result.match([&](const auto &data) {
|
if (const auto photo = data.vphoto()) {
|
||||||
if (const auto photo = data.vphoto()) {
|
loadThumbnail(
|
||||||
loadThumbnail(
|
_session->data().photoFromWeb(*photo, ImageLocation()));
|
||||||
_session->data().photoFromWeb(*photo, ImageLocation()));
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (const auto botId = _details.botId) {
|
if (const auto botId = _details.botId) {
|
||||||
if (const auto bot = _session->data().userLoaded(botId)) {
|
if (const auto bot = _session->data().userLoaded(botId)) {
|
||||||
|
|
|
@ -313,11 +313,11 @@ private:
|
||||||
|
|
||||||
void requestForm();
|
void requestForm();
|
||||||
void requestReceipt();
|
void requestReceipt();
|
||||||
void processForm(const MTPpayments_PaymentForm &result);
|
void processForm(const MTPDpayments_paymentForm &data);
|
||||||
void processReceipt(const MTPDpayments_paymentReceipt &data);
|
void processReceipt(const MTPDpayments_paymentReceipt &data);
|
||||||
void processReceipt(const MTPDpayments_paymentReceiptStars &data);
|
void processReceipt(const MTPDpayments_paymentReceiptStars &data);
|
||||||
void processInvoice(const MTPDinvoice &data);
|
void processInvoice(const MTPDinvoice &data);
|
||||||
void processDetails(const MTPpayments_PaymentForm &result);
|
void processDetails(const MTPDpayments_paymentForm &data);
|
||||||
void processDetails(const MTPDpayments_paymentReceipt &data);
|
void processDetails(const MTPDpayments_paymentReceipt &data);
|
||||||
void processDetails(const MTPDpayments_paymentReceiptStars &data);
|
void processDetails(const MTPDpayments_paymentReceiptStars &data);
|
||||||
void processSavedInformation(const MTPDpaymentRequestedInfo &data);
|
void processSavedInformation(const MTPDpaymentRequestedInfo &data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue