Star gifts API

This commit is contained in:
Ilya Laktyushin
2024-09-16 15:51:26 +04:00
parent f18f337f2c
commit f3eee0c021
25 changed files with 1333 additions and 826 deletions

View File

@@ -1389,6 +1389,9 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
}
let botPeerId = paymentForm.paymentBotId
guard let botPeerId else {
return
}
let _ = (context.engine.data.get(
TelegramEngine.EngineData.Item.Peer.Peer(id: botPeerId)
)
@@ -1460,15 +1463,15 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
}
}
if !liabilityNoticeAccepted {
if !liabilityNoticeAccepted, let paymentBotId = paymentForm.paymentBotId {
let botPeer: Signal<EnginePeer?, NoError> = self.context.engine.data.get(
TelegramEngine.EngineData.Item.Peer.Peer(id: paymentForm.paymentBotId)
TelegramEngine.EngineData.Item.Peer.Peer(id: paymentBotId)
)
let providerPeer: Signal<EnginePeer?, NoError> = paymentForm.providerId.flatMap {
self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: $0))
} ?? .single(nil)
let _ = (combineLatest(
ApplicationSpecificNotice.getBotPaymentLiability(accountManager: self.context.sharedContext.accountManager, peerId: paymentForm.paymentBotId),
ApplicationSpecificNotice.getBotPaymentLiability(accountManager: self.context.sharedContext.accountManager, peerId: paymentBotId),
botPeer,
providerPeer
)
@@ -1489,7 +1492,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
strongSelf.present(textAlertController(context: strongSelf.context, title: strongSelf.presentationData.strings.Checkout_LiabilityAlertTitle, text: paymentText, actions: [TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: { }), TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {
if let strongSelf = self {
let _ = ApplicationSpecificNotice.setBotPaymentLiability(accountManager: strongSelf.context.sharedContext.accountManager, peerId: paymentForm.paymentBotId).start()
let _ = ApplicationSpecificNotice.setBotPaymentLiability(accountManager: strongSelf.context.sharedContext.accountManager, peerId: paymentBotId).start()
strongSelf.pay(savedCredentialsToken: savedCredentialsToken, liabilityNoticeAccepted: true)
}
})]), nil)