diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutController.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutController.swift index 1ed4f74477..e5631e7773 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutController.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutController.swift @@ -79,6 +79,9 @@ public final class BotCheckoutController: ViewController { private let invoice: TelegramMediaInvoice private let source: BotPaymentInvoiceSource private let completed: (String, EngineMessage.Id?) -> Void + private let pending: () -> Void + private let cancelled: () -> Void + private let failed: () -> Void private var presentationData: PresentationData @@ -86,12 +89,14 @@ public final class BotCheckoutController: ViewController { private let inputData: Promise - public init(context: AccountContext, invoice: TelegramMediaInvoice, source: BotPaymentInvoiceSource, inputData: Promise, completed: @escaping (String, EngineMessage.Id?) -> Void) { + public init(context: AccountContext, invoice: TelegramMediaInvoice, source: BotPaymentInvoiceSource, inputData: Promise, completed: @escaping (String, EngineMessage.Id?) -> Void, pending: @escaping () -> Void = {}, cancelled: @escaping () -> Void = {}, failed: @escaping () -> Void = {}) { self.context = context self.invoice = invoice self.source = source self.inputData = inputData self.completed = completed + self.cancelled = cancelled + self.failed = failed self.presentationData = context.sharedContext.currentPresentationData.with { $0 } @@ -122,6 +127,12 @@ public final class BotCheckoutController: ViewController { displayNode.dismiss = { [weak self] in self?.presentingViewController?.dismiss(animated: false, completion: nil) } + displayNode.pending = { [weak self] in + self?.pending() + } + displayNode.failed = { [weak self] in + self?.failed() + } self.displayNode = displayNode super.displayNodeDidLoad() @@ -146,6 +157,7 @@ public final class BotCheckoutController: ViewController { } @objc private func cancelPressed() { + self.cancelled() self.dismiss() } } diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift index cd06521ab7..9684509df6 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift @@ -497,7 +497,10 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz private let present: (ViewController, Any?) -> Void private let dismissAnimated: () -> Void private let completed: (String, EngineMessage.Id?) -> Void - + + var pending: () -> Void = {} + var failed: () -> Void = {} + private var stateValue = BotCheckoutControllerState() private let state = ValuePromise(BotCheckoutControllerState(), ignoreRepeated: true) private var arguments: BotCheckoutControllerArguments? @@ -1312,6 +1315,8 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz } strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), nil) + + strongSelf.failed() } })) } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 0b21abf7ec..60fd65ab55 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -3504,6 +3504,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }, getNavigationController: { [weak self] in return self?.effectiveNavigationController }) + controller.navigationPresentation = .flatModal strongSelf.currentWebAppController = controller strongSelf.present(controller, in: .window(.root)) }, error: { [weak self] error in @@ -3529,6 +3530,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }, getNavigationController: { [weak self] in return self?.effectiveNavigationController }) + controller.navigationPresentation = .flatModal strongSelf.currentWebAppController = controller strongSelf.present(controller, in: .window(.root)) }, error: { [weak self] error in @@ -14758,7 +14760,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedBotStartPayload(startPayload.payload) }) } else if let navigationController = strongSelf.effectiveNavigationController { - strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(id: peerId), botStart: startPayload)) + strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(id: peerId), botStart: startPayload, keepStack: .always)) } case let .withAttachBot(attachBotStart): if let navigationController = strongSelf.effectiveNavigationController { diff --git a/submodules/WebUI/Sources/WebAppController.swift b/submodules/WebUI/Sources/WebAppController.swift index 6b8520b6a1..2bf430a66d 100644 --- a/submodules/WebUI/Sources/WebAppController.swift +++ b/submodules/WebUI/Sources/WebAppController.swift @@ -602,7 +602,11 @@ public final class WebAppController: ViewController, AttachmentContainable { }) if let navigationController = strongSelf.controller?.getNavigationController() { let checkoutController = BotCheckoutController(context: strongSelf.context, invoice: invoice, source: .slug(slug), inputData: inputData, completed: { currencyValue, receiptMessageId in - + self?.sendInvoiceClosedEvent(slug: slug, result: .paid) + }, cancelled: { [weak self] in + self?.sendInvoiceClosedEvent(slug: slug, result: .cancelled) + }, failed: { [weak self] in + self?.sendInvoiceClosedEvent(slug: slug, result: .failed) }) checkoutController.navigationPresentation = .modal navigationController.pushViewController(checkoutController)