Add td_api::assignAppStoreTransaction.
This commit is contained in:
parent
2144d8fcd0
commit
e0605b2013
@ -6406,6 +6406,9 @@ getPremiumState = PremiumState;
|
||||
//@description Checks whether Telegram Premium purchase is possible. Must be called before in-store Premium purchase
|
||||
canPurchasePremium = Ok;
|
||||
|
||||
//@description Informs server about a Telegram Premium purchase through App Store. For official applications only @receipt App Store receipt @is_restore True, if this is restore of Premium purchase
|
||||
assignAppStoreTransaction receipt:bytes is_restore:Bool = Ok;
|
||||
|
||||
//@description Informs server about a Telegram Premium purchase through Google Play. For official applications only @purchase_token Google Play purchase token
|
||||
assignGooglePlayTransaction purchase_token:string = Ok;
|
||||
|
||||
|
@ -168,6 +168,38 @@ class CanPurchasePremiumQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class AssignAppStoreTransactionQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit AssignAppStoreTransactionQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(const string &receipt, bool is_restore) {
|
||||
int32 flags = 0;
|
||||
if (is_restore) {
|
||||
flags |= telegram_api::payments_assignAppStoreTransaction::RESTORE_MASK;
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::payments_assignAppStoreTransaction(flags, false /*ignored*/, BufferSlice(receipt))));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::payments_assignAppStoreTransaction>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for AssignAppStoreTransactionQuery: " << 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 AssignPlayMarketTransactionQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -438,6 +470,10 @@ void can_purchase_premium(Td *td, Promise<Unit> &&promise) {
|
||||
td->create_handler<CanPurchasePremiumQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
void assign_app_store_transaction(Td *td, const string &receipt, bool is_restore, Promise<Unit> &&promise) {
|
||||
td->create_handler<AssignAppStoreTransactionQuery>(std::move(promise))->send(receipt, is_restore);
|
||||
}
|
||||
|
||||
void assign_play_market_transaction(Td *td, const string &purchase_token, Promise<Unit> &&promise) {
|
||||
td->create_handler<AssignPlayMarketTransactionQuery>(std::move(promise))->send(purchase_token);
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ void get_premium_state(Td *td, Promise<td_api::object_ptr<td_api::premiumState>>
|
||||
|
||||
void can_purchase_premium(Td *td, Promise<Unit> &&promise);
|
||||
|
||||
void assign_app_store_transaction(Td *td, const string &receipt, bool is_restore, Promise<Unit> &&promise);
|
||||
|
||||
void assign_play_market_transaction(Td *td, const string &purchase_token, Promise<Unit> &&promise);
|
||||
|
||||
} // namespace td
|
||||
|
@ -7898,6 +7898,12 @@ void Td::on_request(uint64 id, const td_api::canPurchasePremium &request) {
|
||||
can_purchase_premium(this, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::assignAppStoreTransaction &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
assign_app_store_transaction(this, request.receipt_, request.is_restore_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::assignGooglePlayTransaction &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.purchase_token_);
|
||||
|
@ -1309,6 +1309,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::canPurchasePremium &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::assignAppStoreTransaction &request);
|
||||
|
||||
void on_request(uint64 id, td_api::assignGooglePlayTransaction &request);
|
||||
|
||||
void on_request(uint64 id, td_api::acceptTermsOfService &request);
|
||||
|
Loading…
Reference in New Issue
Block a user