From 1d7af482fe024f216a99f25c9aeb05ea42042b14 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 20 Jul 2022 20:44:40 +0300 Subject: [PATCH] Support additional payment options in payment form. --- td/generate/scheme/td_api.tl | 7 ++++++- td/telegram/Payments.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 9077dc983..4723be972 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1562,12 +1562,17 @@ paymentProviderStripe publishable_key:string need_country:Bool need_postal_code: paymentProviderOther url:string = PaymentProvider; +//@description Describes an additional payment option @title Title for the payment option @url Payment form URL to be opened in a web view +paymentOption title:string url:string = PaymentOption; + + //@description Contains information about an invoice payment form //@id The payment form identifier //@invoice Full information about the invoice //@seller_bot_user_id User identifier of the seller bot //@payment_provider_user_id User identifier of the payment provider bot //@payment_provider Information about the payment provider +//@additional_payment_options The list of additional payment options //@saved_order_info Saved server-side order information; may be null //@saved_credentials Information about saved card credentials; may be null //@can_save_credentials True, if the user can choose to save credentials @@ -1575,7 +1580,7 @@ paymentProviderOther url:string = PaymentProvider; //@product_title Product title //@product_description Product description //@product_photo Product photo; may be null -paymentForm id:int64 invoice:invoice seller_bot_user_id:int53 payment_provider_user_id:int53 payment_provider:PaymentProvider saved_order_info:orderInfo saved_credentials:savedCredentials can_save_credentials:Bool need_password:Bool product_title:string product_description:formattedText product_photo:photo = PaymentForm; +paymentForm id:int64 invoice:invoice seller_bot_user_id:int53 payment_provider_user_id:int53 payment_provider:PaymentProvider additional_payment_options:vector saved_order_info:orderInfo saved_credentials:savedCredentials can_save_credentials:Bool need_password:Bool product_title:string product_description:formattedText product_photo:photo = PaymentForm; //@description Contains a temporary identifier of validated order information, which is stored for one hour. Also contains the available shipping options @order_info_id Temporary identifier of the order information @shipping_options Available shipping options validatedOrderInfo order_info_id:string shipping_options:vector = ValidatedOrderInfo; diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 6e52bffcd..47153d013 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -388,11 +388,16 @@ class GetPaymentFormQuery final : public Td::ResultHandler { if (payment_provider == nullptr) { payment_provider = td_api::make_object(std::move(payment_form->url_)); } + auto additional_payment_options = transform( + payment_form->additional_methods_, [](const telegram_api::object_ptr &method) { + return td_api::make_object(method->title_, method->url_); + }); promise_.set_value(make_tl_object( payment_form->form_id_, convert_invoice(std::move(payment_form->invoice_)), td_->contacts_manager_->get_user_id_object(seller_bot_user_id, "paymentForm seller"), td_->contacts_manager_->get_user_id_object(payments_provider_user_id, "paymentForm provider"), - std::move(payment_provider), convert_order_info(std::move(payment_form->saved_info_)), + std::move(payment_provider), std::move(additional_payment_options), + convert_order_info(std::move(payment_form->saved_info_)), convert_saved_credentials(std::move(payment_form->saved_credentials_)), can_save_credentials, need_password, payment_form->title_, get_product_description_object(payment_form->description_), get_photo_object(td_->file_manager_.get(), photo)));