diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 7a3f6b021..cac2ce2aa 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4893,8 +4893,8 @@ validateOrderInfo chat_id:int53 message_id:int53 order_info:orderInfo allow_save //@description Sends a filled-out payment form to the bot for final verification @chat_id Chat identifier of the Invoice message @message_id Message identifier //@payment_form_id Payment form identifier returned by getPaymentForm @order_info_id Identifier returned by validateOrderInfo, or an empty string @shipping_option_id Identifier of a chosen shipping option, if applicable -//@credentials The credentials chosen by user for payment -sendPaymentForm chat_id:int53 message_id:int53 payment_form_id:int64 order_info_id:string shipping_option_id:string credentials:InputCredentials = PaymentResult; +//@credentials The credentials chosen by user for payment @tip_amount Chosen by the user amount of tip in the smallest units of the currency +sendPaymentForm chat_id:int53 message_id:int53 payment_form_id:int64 order_info_id:string shipping_option_id:string credentials:InputCredentials tip_amount:int53 = PaymentResult; //@description Returns information about a successful payment @chat_id Chat identifier of the PaymentSuccessful message @message_id Message identifier getPaymentReceipt chat_id:int53 message_id:int53 = PaymentReceipt; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 6716a8ffe..86a073f67 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -37391,7 +37391,7 @@ void MessagesManager::validate_order_info(FullMessageId full_message_id, tl_obje void MessagesManager::send_payment_form(FullMessageId full_message_id, int64 payment_form_id, const string &order_info_id, const string &shipping_option_id, - const tl_object_ptr &credentials, + const tl_object_ptr &credentials, int64 tip_amount, Promise> &&promise) { auto r_message_id = get_invoice_message_id(full_message_id); if (r_message_id.is_error()) { @@ -37399,7 +37399,7 @@ void MessagesManager::send_payment_form(FullMessageId full_message_id, int64 pay } ::td::send_payment_form(full_message_id.get_dialog_id(), r_message_id.ok(), payment_form_id, order_info_id, - shipping_option_id, credentials, std::move(promise)); + shipping_option_id, credentials, tip_amount, std::move(promise)); } void MessagesManager::get_payment_receipt(FullMessageId full_message_id, diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 24a2d635b..97d7035b3 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -918,7 +918,7 @@ class MessagesManager : public Actor { void send_payment_form(FullMessageId full_message_id, int64 payment_form_id, const string &order_info_id, const string &shipping_option_id, const tl_object_ptr &credentials, - Promise> &&promise); + int64 tip_amount, Promise> &&promise); void get_payment_receipt(FullMessageId full_message_id, Promise> &&promise); diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 5f7d489df..259e5a03d 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -360,7 +360,8 @@ class SendPaymentFormQuery : public Td::ResultHandler { } void send(DialogId dialog_id, ServerMessageId server_message_id, int64 payment_form_id, const string &order_info_id, - const string &shipping_option_id, tl_object_ptr input_credentials) { + const string &shipping_option_id, tl_object_ptr input_credentials, + int64 tip_amount) { CHECK(input_credentials != nullptr); dialog_id_ = dialog_id; @@ -376,9 +377,12 @@ class SendPaymentFormQuery : public Td::ResultHandler { if (!shipping_option_id.empty()) { flags |= telegram_api::payments_sendPaymentForm::SHIPPING_OPTION_ID_MASK; } - send_query(G()->net_query_creator().create( - telegram_api::payments_sendPaymentForm(flags, payment_form_id, std::move(input_peer), server_message_id.get(), - order_info_id, shipping_option_id, std::move(input_credentials), 0))); + if (tip_amount != 0) { + flags |= telegram_api::payments_sendPaymentForm::TIP_AMOUNT_MASK; + } + send_query(G()->net_query_creator().create(telegram_api::payments_sendPaymentForm( + flags, payment_form_id, std::move(input_peer), server_message_id.get(), order_info_id, shipping_option_id, + std::move(input_credentials), tip_amount))); } void on_result(uint64 id, BufferSlice packet) override { @@ -877,7 +881,7 @@ void validate_order_info(DialogId dialog_id, ServerMessageId server_message_id, void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, int64 payment_form_id, const string &order_info_id, const string &shipping_option_id, - const tl_object_ptr &credentials, + const tl_object_ptr &credentials, int64 tip_amount, Promise> &&promise) { CHECK(credentials != nullptr); @@ -930,7 +934,7 @@ void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, in .get_actor_unsafe() ->create_handler(std::move(promise)) ->send(dialog_id, server_message_id, payment_form_id, order_info_id, shipping_option_id, - std::move(input_credentials)); + std::move(input_credentials), tip_amount); } void get_payment_receipt(DialogId dialog_id, ServerMessageId server_message_id, diff --git a/td/telegram/Payments.h b/td/telegram/Payments.h index 96c6dd854..66b9e4abd 100644 --- a/td/telegram/Payments.h +++ b/td/telegram/Payments.h @@ -149,7 +149,7 @@ void validate_order_info(DialogId dialog_id, ServerMessageId server_message_id, void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, int64 payment_form_id, const string &order_info_id, const string &shipping_option_id, - const tl_object_ptr &credentials, + const tl_object_ptr &credentials, int64 tip_amount, Promise> &&promise); void get_payment_receipt(DialogId dialog_id, ServerMessageId server_message_id, diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 27430095a..1c3b7df4e 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7734,7 +7734,7 @@ void Td::on_request(uint64 id, td_api::sendPaymentForm &request) { CREATE_REQUEST_PROMISE(); messages_manager_->send_payment_form({DialogId(request.chat_id_), MessageId(request.message_id_)}, request.payment_form_id_, request.order_info_id_, request.shipping_option_id_, - request.credentials_, std::move(promise)); + request.credentials_, request.tip_amount_, std::move(promise)); } void Td::on_request(uint64 id, const td_api::getPaymentReceipt &request) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 96905d0e9..75f33b050 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1839,25 +1839,28 @@ class CliClient final : public Actor { } else if (op == "spfs") { string chat_id; string message_id; + int64 tip_amount; int64 payment_form_id; string order_info_id; string shipping_option_id; string saved_credentials_id; - get_args(args, chat_id, message_id, payment_form_id, order_info_id, shipping_option_id, saved_credentials_id); + get_args(args, chat_id, message_id, tip_amount, payment_form_id, order_info_id, shipping_option_id, + saved_credentials_id); send_request(td_api::make_object( as_chat_id(chat_id), as_message_id(message_id), payment_form_id, order_info_id, shipping_option_id, - td_api::make_object(saved_credentials_id))); + td_api::make_object(saved_credentials_id), tip_amount)); } else if (op == "spfn") { string chat_id; string message_id; + int64 tip_amount; int64 payment_form_id; string order_info_id; string shipping_option_id; string data; - get_args(args, chat_id, message_id, payment_form_id, order_info_id, shipping_option_id, data); + get_args(args, chat_id, message_id, tip_amount, payment_form_id, order_info_id, shipping_option_id, data); send_request(td_api::make_object( as_chat_id(chat_id), as_message_id(message_id), payment_form_id, order_info_id, shipping_option_id, - td_api::make_object(data, true))); + td_api::make_object(data, true), tip_amount)); } else if (op == "gpre") { string chat_id; string message_id;