diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a11573869..17bc00eb0 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -5627,6 +5627,13 @@ telegramPaymentPurposePremiumGiveaway parameters:premiumGiveawayParameters curre //@star_count Number of bought stars telegramPaymentPurposeStars currency:string amount:int53 star_count:int53 = TelegramPaymentPurpose; +//@description The user buying Telegram stars for other users +//@user_id Identifier of the user to which Telegram stars are gifted +//@currency ISO 4217 currency code of the payment currency +//@amount Paid amount, in the smallest units of the currency +//@star_count Number of bought stars +telegramPaymentPurposeGiftedStars user_id:int53 currency:string amount:int53 star_count:int53 = TelegramPaymentPurpose; + //@class DeviceToken @description Represents a data needed to subscribe for push notifications through registerDevice method. //-To use specific push notification service, the correct application platform must be specified and a valid server authentication data must be uploaded at https://my.telegram.org diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 9799d324f..db033671c 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -136,6 +136,21 @@ Result get_input_invoice_info(Td *td, td_api::object_ptr(std::move(purpose)); break; } + case td_api::telegramPaymentPurposeGiftedStars::ID: { + auto p = static_cast(invoice->purpose_.get()); + UserId user_id(p->user_id_); + TRY_RESULT(input_user, td->user_manager_->get_input_user(user_id)); + if (p->amount_ <= 0 || !check_currency_amount(p->amount_)) { + return Status::Error(400, "Invalid amount of the currency specified"); + } + if (!clean_input_string(p->currency_)) { + return Status::Error(400, "Strings must be encoded in UTF-8"); + } + auto purpose = telegram_api::make_object( + std::move(input_user), p->star_count_, p->currency_, p->amount_); + result.input_invoice_ = telegram_api::make_object(std::move(purpose)); + break; + } default: UNREACHABLE(); }