Support themes in getPaymentForm.
This commit is contained in:
parent
37cee0d823
commit
5d5f950d2b
@ -1349,6 +1349,11 @@ inputCredentialsGooglePay data:string = InputCredentials;
|
|||||||
//@description Stripe payment provider @publishable_key Stripe API publishable key @need_country True, if the user country must be provided @need_postal_code True, if the user ZIP/postal code must be provided @need_cardholder_name True, if the cardholder name must be provided
|
//@description Stripe payment provider @publishable_key Stripe API publishable key @need_country True, if the user country must be provided @need_postal_code True, if the user ZIP/postal code must be provided @need_cardholder_name True, if the cardholder name must be provided
|
||||||
paymentsProviderStripe publishable_key:string need_country:Bool need_postal_code:Bool need_cardholder_name:Bool = PaymentsProviderStripe;
|
paymentsProviderStripe publishable_key:string need_country:Bool need_postal_code:Bool need_cardholder_name:Bool = PaymentsProviderStripe;
|
||||||
|
|
||||||
|
//@description Theme colors for a payment form @background_color A color of the payment form background in the RGB24 format @text_color A color of text in the RGB24 format
|
||||||
|
//@hint_color A color of hints in the RGB24 format @link_color A color of links in the RGB24 format @button_color A color of thebuttons in the RGB24 format
|
||||||
|
//@button_text_color A color of text on the buttons in the RGB24 format
|
||||||
|
paymentFormTheme background_color:int32 text_color:int32 hint_color:int32 link_color:int32 button_color:int32 button_text_color:int32 = PaymentFormTheme;
|
||||||
|
|
||||||
//@description Contains information about an invoice payment form
|
//@description Contains information about an invoice payment form
|
||||||
//@id The payment form identifier
|
//@id The payment form identifier
|
||||||
//@invoice Full information of the invoice
|
//@invoice Full information of the invoice
|
||||||
@ -4929,8 +4934,8 @@ closeSecretChat secret_chat_id:int32 = Ok;
|
|||||||
getChatEventLog chat_id:int53 query:string from_event_id:int64 limit:int32 filters:chatEventLogFilters user_ids:vector<int32> = ChatEvents;
|
getChatEventLog chat_id:int53 query:string from_event_id:int64 limit:int32 filters:chatEventLogFilters user_ids:vector<int32> = ChatEvents;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns an invoice payment form. This method should be called when the user presses inlineKeyboardButtonBuy @chat_id Chat identifier of the Invoice message @message_id Message identifier
|
//@description Returns an invoice payment form. This method should be called when the user presses inlineKeyboardButtonBuy @chat_id Chat identifier of the Invoice message @message_id Message identifier @theme Preferred payment form theme
|
||||||
getPaymentForm chat_id:int53 message_id:int53 = PaymentForm;
|
getPaymentForm chat_id:int53 message_id:int53 theme:paymentFormTheme = PaymentForm;
|
||||||
|
|
||||||
//@description Validates the order information provided by a user and returns the available shipping options for a flexible invoice @chat_id Chat identifier of the Invoice message @message_id Message identifier @order_info The order information, provided by the user @allow_save True, if the order information can be saved
|
//@description Validates the order information provided by a user and returns the available shipping options for a flexible invoice @chat_id Chat identifier of the Invoice message @message_id Message identifier @order_info The order information, provided by the user @allow_save True, if the order information can be saved
|
||||||
validateOrderInfo chat_id:int53 message_id:int53 order_info:orderInfo allow_save:Bool = ValidatedOrderInfo;
|
validateOrderInfo chat_id:int53 message_id:int53 order_info:orderInfo allow_save:Bool = ValidatedOrderInfo;
|
||||||
|
@ -266,7 +266,8 @@ class GetPaymentFormQuery : public Td::ResultHandler {
|
|||||||
explicit GetPaymentFormQuery(Promise<tl_object_ptr<td_api::paymentForm>> &&promise) : promise_(std::move(promise)) {
|
explicit GetPaymentFormQuery(Promise<tl_object_ptr<td_api::paymentForm>> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(DialogId dialog_id, ServerMessageId server_message_id) {
|
void send(DialogId dialog_id, ServerMessageId server_message_id,
|
||||||
|
tl_object_ptr<telegram_api::dataJSON> &&theme_parameters) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
||||||
if (input_peer == nullptr) {
|
if (input_peer == nullptr) {
|
||||||
@ -274,8 +275,11 @@ class GetPaymentFormQuery : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
send_query(G()->net_query_creator().create(
|
if (theme_parameters != nullptr) {
|
||||||
telegram_api::payments_getPaymentForm(flags, std::move(input_peer), server_message_id.get(), nullptr)));
|
flags |= telegram_api::payments_getPaymentForm::THEME_PARAMS_MASK;
|
||||||
|
}
|
||||||
|
send_query(G()->net_query_creator().create(telegram_api::payments_getPaymentForm(
|
||||||
|
flags, std::move(input_peer), server_message_id.get(), std::move(theme_parameters))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_result(uint64 id, BufferSlice packet) override {
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
@ -1134,9 +1138,24 @@ void answer_pre_checkout_query(Td *td, int64 pre_checkout_query_id, const string
|
|||||||
td->create_handler<SetBotPreCheckoutAnswerQuery>(std::move(promise))->send(pre_checkout_query_id, error_message);
|
td->create_handler<SetBotPreCheckoutAnswerQuery>(std::move(promise))->send(pre_checkout_query_id, error_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_payment_form(Td *td, FullMessageId full_message_id, Promise<tl_object_ptr<td_api::paymentForm>> &&promise) {
|
void get_payment_form(Td *td, FullMessageId full_message_id, const td_api::object_ptr<td_api::paymentFormTheme> &theme,
|
||||||
|
Promise<tl_object_ptr<td_api::paymentForm>> &&promise) {
|
||||||
TRY_RESULT_PROMISE(promise, server_message_id, td->messages_manager_->get_invoice_message_id(full_message_id));
|
TRY_RESULT_PROMISE(promise, server_message_id, td->messages_manager_->get_invoice_message_id(full_message_id));
|
||||||
td->create_handler<GetPaymentFormQuery>(std::move(promise))->send(full_message_id.get_dialog_id(), server_message_id);
|
|
||||||
|
tl_object_ptr<telegram_api::dataJSON> theme_parameters;
|
||||||
|
if (theme != nullptr) {
|
||||||
|
theme_parameters = make_tl_object<telegram_api::dataJSON>(string());
|
||||||
|
theme_parameters->data_ = json_encode<string>(json_object([&theme](auto &o) {
|
||||||
|
o("bg_color", theme->background_color_);
|
||||||
|
o("text_color", theme->text_color_);
|
||||||
|
o("hint_color", theme->hint_color_);
|
||||||
|
o("link_color", theme->link_color_);
|
||||||
|
o("button_color", theme->button_color_);
|
||||||
|
o("button_text_color", theme->button_text_color_);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
td->create_handler<GetPaymentFormQuery>(std::move(promise))
|
||||||
|
->send(full_message_id.get_dialog_id(), server_message_id, std::move(theme_parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
void validate_order_info(Td *td, FullMessageId full_message_id, tl_object_ptr<td_api::orderInfo> order_info,
|
void validate_order_info(Td *td, FullMessageId full_message_id, tl_object_ptr<td_api::orderInfo> order_info,
|
||||||
|
@ -179,7 +179,8 @@ void answer_shipping_query(Td *td, int64 shipping_query_id,
|
|||||||
void answer_pre_checkout_query(Td *td, int64 pre_checkout_query_id, const string &error_message,
|
void answer_pre_checkout_query(Td *td, int64 pre_checkout_query_id, const string &error_message,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
void get_payment_form(Td *td, FullMessageId full_message_id, Promise<tl_object_ptr<td_api::paymentForm>> &&promise);
|
void get_payment_form(Td *td, FullMessageId full_message_id, const td_api::object_ptr<td_api::paymentFormTheme> &theme,
|
||||||
|
Promise<tl_object_ptr<td_api::paymentForm>> &&promise);
|
||||||
|
|
||||||
void validate_order_info(Td *td, FullMessageId full_message_id, tl_object_ptr<td_api::orderInfo> order_info,
|
void validate_order_info(Td *td, FullMessageId full_message_id, tl_object_ptr<td_api::orderInfo> order_info,
|
||||||
bool allow_save, Promise<tl_object_ptr<td_api::validatedOrderInfo>> &&promise);
|
bool allow_save, Promise<tl_object_ptr<td_api::validatedOrderInfo>> &&promise);
|
||||||
|
@ -7736,7 +7736,8 @@ void Td::on_request(uint64 id, td_api::getBankCardInfo &request) {
|
|||||||
void Td::on_request(uint64 id, const td_api::getPaymentForm &request) {
|
void Td::on_request(uint64 id, const td_api::getPaymentForm &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST_PROMISE();
|
CREATE_REQUEST_PROMISE();
|
||||||
get_payment_form(this, {DialogId(request.chat_id_), MessageId(request.message_id_)}, std::move(promise));
|
get_payment_form(this, {DialogId(request.chat_id_), MessageId(request.message_id_)}, request.theme_,
|
||||||
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::validateOrderInfo &request) {
|
void Td::on_request(uint64 id, td_api::validateOrderInfo &request) {
|
||||||
|
@ -1828,7 +1828,9 @@ class CliClient final : public Actor {
|
|||||||
string chat_id;
|
string chat_id;
|
||||||
string message_id;
|
string message_id;
|
||||||
get_args(args, chat_id, message_id);
|
get_args(args, chat_id, message_id);
|
||||||
send_request(td_api::make_object<td_api::getPaymentForm>(as_chat_id(chat_id), as_message_id(message_id)));
|
send_request(td_api::make_object<td_api::getPaymentForm>(
|
||||||
|
as_chat_id(chat_id), as_message_id(message_id),
|
||||||
|
td_api::make_object<td_api::paymentFormTheme>(0, -1, 256, 65536, 123456789, 65535)));
|
||||||
} else if (op == "voi") {
|
} else if (op == "voi") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string message_id;
|
string message_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user