Add td_api::refundStarPayment.
This commit is contained in:
parent
62acb0aecd
commit
d624f49e43
@ -10410,6 +10410,11 @@ deleteSavedCredentials = Ok;
|
||||
//@description Creates a link for the given invoice; for bots only @invoice Information about the invoice of the type inputMessageInvoice
|
||||
createInvoiceLink invoice:InputMessageContent = HttpUrl;
|
||||
|
||||
//@description Refunds a previously done payment in Telegram Stars
|
||||
//@user_id Identifier of the user that did the payment
|
||||
//@telegram_payment_charge_id Telegram payment identifier
|
||||
refundStarPayment user_id:int53 telegram_payment_charge_id:string = Ok;
|
||||
|
||||
|
||||
//@description Returns a user that can be contacted to get support
|
||||
getSupportUser = User;
|
||||
|
@ -868,6 +868,34 @@ class ExportInvoiceQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class RefundStarsChargeQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit RefundStarsChargeQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(telegram_api::object_ptr<telegram_api::InputUser> &&input_user, const string &telegram_payment_charge_id) {
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::payments_refundStarsCharge(std::move(input_user), telegram_payment_charge_id)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::payments_refundStarsCharge>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for RefundStarsChargeQuery: " << to_string(ptr);
|
||||
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class GetBankCardInfoQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::bankCardInfo>> promise_;
|
||||
|
||||
@ -1130,6 +1158,12 @@ void export_invoice(Td *td, td_api::object_ptr<td_api::InputMessageContent> &&in
|
||||
td->create_handler<ExportInvoiceQuery>(std::move(promise))->send(std::move(input_media));
|
||||
}
|
||||
|
||||
void refund_star_payment(Td *td, UserId user_id, const string &telegram_payment_charge_id, Promise<Unit> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, td->user_manager_->get_input_user(user_id));
|
||||
td->create_handler<RefundStarsChargeQuery>(std::move(promise))
|
||||
->send(std::move(input_user), telegram_payment_charge_id);
|
||||
}
|
||||
|
||||
void get_bank_card_info(Td *td, const string &bank_card_number,
|
||||
Promise<td_api::object_ptr<td_api::bankCardInfo>> &&promise) {
|
||||
td->create_handler<GetBankCardInfoQuery>(std::move(promise))->send(bank_card_number);
|
||||
|
@ -48,6 +48,8 @@ void delete_saved_credentials(Td *td, Promise<Unit> &&promise);
|
||||
|
||||
void export_invoice(Td *td, td_api::object_ptr<td_api::InputMessageContent> &&invoice, Promise<string> &&promise);
|
||||
|
||||
void refund_star_payment(Td *td, UserId user_id, const string &telegram_payment_charge_id, Promise<Unit> &&promise);
|
||||
|
||||
void get_bank_card_info(Td *td, const string &bank_card_number,
|
||||
Promise<td_api::object_ptr<td_api::bankCardInfo>> &&promise);
|
||||
|
||||
|
@ -9076,6 +9076,13 @@ void Td::on_request(uint64 id, td_api::createInvoiceLink &request) {
|
||||
export_invoice(this, std::move(request.invoice_), std::move(query_promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::refundStarPayment &request) {
|
||||
CHECK_IS_BOT();
|
||||
CLEAN_INPUT_STRING(request.telegram_payment_charge_id_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
refund_star_payment(this, UserId(request.user_id_), request.telegram_payment_charge_id_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getPassportElement &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.password_);
|
||||
|
@ -1759,6 +1759,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::createInvoiceLink &request);
|
||||
|
||||
void on_request(uint64 id, td_api::refundStarPayment &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getPassportElement &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getAllPassportElements &request);
|
||||
|
@ -2760,6 +2760,11 @@ class CliClient final : public Actor {
|
||||
// send_request(td_api::make_object<td_api::sendTonLiteServerRequest>());
|
||||
// } else if (op == "gtwps") {
|
||||
// send_request(td_api::make_object<td_api::getTonWalletPasswordSalt>());
|
||||
} else if (op == "rsp") {
|
||||
UserId user_id;
|
||||
string telegram_payment_charge_id;
|
||||
get_args(args, user_id, telegram_payment_charge_id);
|
||||
send_request(td_api::make_object<td_api::refundStarPayment>(user_id, telegram_payment_charge_id));
|
||||
} else if (op == "gpr") {
|
||||
send_request(td_api::make_object<td_api::getUserPrivacySettingRules>(as_user_privacy_setting(args)));
|
||||
} else if (op == "spr") {
|
||||
|
Loading…
Reference in New Issue
Block a user