diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index d4c1830ae..a91ea87f0 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2088,6 +2088,7 @@ labeledPricePart label:string amount:int53 = LabeledPricePart; //@max_tip_amount The maximum allowed amount of tip in the smallest units of the currency //@suggested_tip_amounts Suggested amounts of tip in the smallest units of the currency //@recurring_payment_terms_of_service_url An HTTP URL with terms of service for recurring payments. If non-empty, the invoice payment will result in recurring payments and the user must accept the terms of service before allowed to pay +//@terms_of_service_url An HTTP URL with terms of service for non-recurring payments. If non-empty, then the user must accept the terms of service before allowed to pay //@is_test True, if the payment is a test payment //@need_name True, if the user's name is needed for payment //@need_phone_number True, if the user's phone number is needed for payment @@ -2096,7 +2097,7 @@ labeledPricePart label:string amount:int53 = LabeledPricePart; //@send_phone_number_to_provider True, if the user's phone number will be sent to the provider //@send_email_address_to_provider True, if the user's email address will be sent to the provider //@is_flexible True, if the total price depends on the shipping method -invoice currency:string price_parts:vector max_tip_amount:int53 suggested_tip_amounts:vector recurring_payment_terms_of_service_url:string is_test:Bool need_name:Bool need_phone_number:Bool need_email_address:Bool need_shipping_address:Bool send_phone_number_to_provider:Bool send_email_address_to_provider:Bool is_flexible:Bool = Invoice; +invoice currency:string price_parts:vector max_tip_amount:int53 suggested_tip_amounts:vector recurring_payment_terms_of_service_url:string terms_of_service_url:string is_test:Bool need_name:Bool need_phone_number:Bool need_email_address:Bool need_shipping_address:Bool send_phone_number_to_provider:Bool send_email_address_to_provider:Bool is_flexible:Bool = Invoice; //@description Order information //@name Name of the user diff --git a/td/telegram/InputInvoice.cpp b/td/telegram/InputInvoice.cpp index fc606b044..d02523abc 100644 --- a/td/telegram/InputInvoice.cpp +++ b/td/telegram/InputInvoice.cpp @@ -35,7 +35,8 @@ bool operator==(const InputInvoice &lhs, const InputInvoice &rhs) { lhs.is_flexible_ == rhs.is_flexible_ && lhs.currency_ == rhs.currency_ && lhs.price_parts_ == rhs.price_parts_ && lhs.max_tip_amount_ == rhs.max_tip_amount_ && lhs.suggested_tip_amounts_ == rhs.suggested_tip_amounts_ && - lhs.recurring_payment_terms_of_service_url_ == rhs.recurring_payment_terms_of_service_url_; + lhs.recurring_payment_terms_of_service_url_ == rhs.recurring_payment_terms_of_service_url_ && + lhs.terms_of_service_url_ == rhs.terms_of_service_url_; }; return lhs.title_ == rhs.title_ && lhs.description_ == rhs.description_ && lhs.photo_ == rhs.photo_ && @@ -129,6 +130,12 @@ Result InputInvoice::process_input_message_invoice( if (!clean_input_string(input_invoice->invoice_->currency_)) { return Status::Error(400, "Invoice currency must be encoded in UTF-8"); } + if (!clean_input_string(input_invoice->invoice_->recurring_payment_terms_of_service_url_)) { + return Status::Error(400, "Invoice terms of service URL must be encoded in UTF-8"); + } + if (!clean_input_string(input_invoice->invoice_->terms_of_service_url_)) { + return Status::Error(400, "Invoice terms of service URL must be encoded in UTF-8"); + } InputInvoice result; result.title_ = std::move(input_invoice->title_); @@ -200,6 +207,7 @@ Result InputInvoice::process_input_message_invoice( result.invoice_.suggested_tip_amounts_ = std::move(input_invoice->invoice_->suggested_tip_amounts_); result.invoice_.recurring_payment_terms_of_service_url_ = std::move(input_invoice->invoice_->recurring_payment_terms_of_service_url_); + result.invoice_.terms_of_service_url_ = std::move(input_invoice->invoice_->terms_of_service_url_); result.invoice_.is_test_ = input_invoice->invoice_->is_test_; result.invoice_.need_name_ = input_invoice->invoice_->need_name_; result.invoice_.need_phone_number_ = input_invoice->invoice_->need_phone_number_; @@ -267,9 +275,14 @@ tl_object_ptr InputInvoice::Invoice::get_input_invoice() if (max_tip_amount_ != 0) { flags |= telegram_api::invoice::MAX_TIP_AMOUNT_MASK; } + string terms_of_service_url; if (!recurring_payment_terms_of_service_url_.empty()) { flags |= telegram_api::invoice::RECURRING_MASK; flags |= telegram_api::invoice::TERMS_URL_MASK; + terms_of_service_url = recurring_payment_terms_of_service_url_; + } else if (!terms_of_service_url_.empty()) { + flags |= telegram_api::invoice::TERMS_URL_MASK; + terms_of_service_url = terms_of_service_url_; } auto prices = transform(price_parts_, [](const LabeledPricePart &price) { @@ -278,7 +291,7 @@ tl_object_ptr InputInvoice::Invoice::get_input_invoice() return make_tl_object( flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, currency_, std::move(prices), - max_tip_amount_, vector(suggested_tip_amounts_), recurring_payment_terms_of_service_url_); + max_tip_amount_, vector(suggested_tip_amounts_), terms_of_service_url); } static tl_object_ptr get_input_web_document(const FileManager *file_manager, diff --git a/td/telegram/InputInvoice.h b/td/telegram/InputInvoice.h index 1adaf82d4..fc453f829 100644 --- a/td/telegram/InputInvoice.h +++ b/td/telegram/InputInvoice.h @@ -30,6 +30,7 @@ class InputInvoice { int64 max_tip_amount_ = 0; vector suggested_tip_amounts_; string recurring_payment_terms_of_service_url_; + string terms_of_service_url_; bool is_test_ = false; bool need_name_ = false; bool need_phone_number_ = false; diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 0c49c52fb..71a082204 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -194,13 +194,16 @@ static tl_object_ptr convert_invoice(tl_object_ptrrecurring_) { recurring_terms_url = std::move(invoice->terms_url_); + } else { + terms_url = std::move(invoice->terms_url_); } return make_tl_object(std::move(invoice->currency_), std::move(labeled_prices), invoice->max_tip_amount_, std::move(invoice->suggested_tip_amounts_), - recurring_terms_url, is_test, need_name, need_phone_number, need_email_address, - need_shipping_address, send_phone_number_to_provider, + recurring_terms_url, terms_url, is_test, need_name, need_phone_number, + need_email_address, need_shipping_address, send_phone_number_to_provider, send_email_address_to_provider, is_flexible); }