MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / applyPrepaid

Method applyPrepaid

Telegram/SourceFiles/api/api_premium.cpp:549–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547}
548
549rpl::producer<rpl::no_value, QString> PremiumGiftCodeOptions::applyPrepaid(
550 const Payments::InvoicePremiumGiftCode &invoice,
551 uint64 prepaidId) {
552 return [=](auto consumer) {
553 auto lifetime = rpl::lifetime();
554 const auto channel = _peer->asChannel();
555 if (!channel) {
556 return lifetime;
557 }
558
559 _api.request(MTPpayments_LaunchPrepaidGiveaway(
560 _peer->input(),
561 MTP_long(prepaidId),
562 invoice.giveawayCredits
563 ? Payments::InvoiceCreditsGiveawayToTL(invoice)
564 : Payments::InvoicePremiumGiftCodeGiveawayToTL(invoice)
565 )).done([=](const MTPUpdates &result) {
566 _peer->session().api().applyUpdates(result);
567 consumer.put_done();
568 }).fail([=](const MTP::Error &error) {
569 consumer.put_error_copy(error.type());
570 }).send();
571
572 return lifetime;
573 };
574}
575
576const std::vector<int> &PremiumGiftCodeOptions::availablePresets() const {
577 return _availablePresets;

Callers 1

CreateGiveawayBoxFunction · 0.80

Calls 13

MTP_longFunction · 0.85
asChannelMethod · 0.80
apiMethod · 0.80
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
requestMethod · 0.45
inputMethod · 0.45
applyUpdatesMethod · 0.45
sessionMethod · 0.45

Tested by

no test coverage detected