             private func presentPaymentSheet() {
                 let paymentSheet = parent.paymentSheet
 
-                // This is a bit of a hack: We traverse the view hierarchy looking for the most reasonable VC to present from.
-                // A VC hosted within a SwiftUI cell, for example, doesn't have a parent, so we need to find the UIWindow.
-                var presentingViewController = uiViewController.view.window?.rootViewController
-                presentingViewController =
-                    presentingViewController?.presentedViewController ?? presentingViewController
-                    ?? uiViewController
-                if let presentingViewController = presentingViewController {
-                    paymentSheet.present(from: presentingViewController) {
-                        (result: PaymentSheetResult) in
-                        self.parent.presented = false
-                        self.parent.onCompletion(result)
-                    }
+
+                paymentSheet.present(from: findViewControllerPresenter(from: uiViewController)) {
+                    (result: PaymentSheetResult) in
+                    self.parent.presented = false
+                    self.parent.onCompletion(result)
                 }
             }
 

        }
    }
}


            private func presentPaymentSheet() {
                let flowController = parent.paymentSheetFlowController
                let presenter = findViewControllerPresenter(from: uiViewController)

                switch parent.action {
                case .confirmPayment:
                    flowController.confirm(from: presenter) { result in
                        self.parent.presented = false
                        self.parent.paymentCompletion!(result)
                    }
                case .presentPaymentOptions:
                    flowController.presentPaymentOptions(from: presenter) {
                        self.parent.presented = false
                        self.parent.optionsCompletion?()
                    }
                }
            }
