diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet.swift index f9a3545eb9e..27e424abb45 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheet.swift @@ -304,15 +304,6 @@ extension PaymentSheet: PaymentSheetViewControllerDelegate { self.completion?(.canceled) } } - - func paymentSheetViewControllerDidSelectPayWithLink( - _ paymentSheetViewController: PaymentSheetViewController - ) { - self.presentPayWithLinkController( - from: paymentSheetViewController, - intent: paymentSheetViewController.intent - ) - } } extension PaymentSheet: LoadingViewControllerDelegate { @@ -327,53 +318,3 @@ extension PaymentSheet: LoadingViewControllerDelegate { @_spi(STP) extension PaymentSheet: STPAnalyticsProtocol { @_spi(STP) public static let stp_analyticsIdentifier: String = "PaymentSheet" } - -extension PaymentSheet: PayWithLinkWebControllerDelegate { - - func payWithLinkWebControllerDidComplete( - _ PayWithLinkWebController: PayWithLinkWebController, - intent: Intent, - with paymentOption: PaymentOption - ) { - let backgroundColor = self.configuration.appearance.colors.background.withAlphaComponent(0.85) - self.bottomSheetViewController.addBlurEffect(animated: false, backgroundColor: backgroundColor) { - self.bottomSheetViewController.startSpinner() - let psvc = self.findPaymentSheetViewController() - psvc?.clearTextFields() - psvc?.pay(with: paymentOption, animateBuyButton: true) - } - } - - func payWithLinkWebControllerDidCancel(_ payWithLinkWebController: PayWithLinkWebController) { - } - - private func findPaymentSheetViewController() -> PaymentSheetViewController? { - for vc in bottomSheetViewController.contentStack { - if let paymentSheetVC = vc as? PaymentSheetViewController { - return paymentSheetVC - } - } - - return nil - } -} - -// MARK: - Link - -private extension PaymentSheet { - - func presentPayWithLinkController( - from presentingController: UIViewController, - intent: Intent, - completion: (() -> Void)? = nil - ) { - let payWithLinkVC = PayWithLinkWebController( - intent: intent, - configuration: configuration - ) - - payWithLinkVC.payWithLinkDelegate = self - payWithLinkVC.present(over: presentingController) - } - -} diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetViewController.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetViewController.swift index 1389d67fa73..c315beb1e89 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetViewController.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentSheetViewController.swift @@ -26,9 +26,6 @@ protocol PaymentSheetViewControllerDelegate: AnyObject { func paymentSheetViewControllerDidCancel( _ paymentSheetViewController: PaymentSheetViewController ) - func paymentSheetViewControllerDidSelectPayWithLink( - _ paymentSheetViewController: PaymentSheetViewController - ) } /// For internal SDK use only @@ -554,13 +551,38 @@ extension PaymentSheetViewController: WalletHeaderViewDelegate { func walletHeaderViewPayWithLinkTapped(_ header: WalletHeaderView) { set(error: nil) - delegate?.paymentSheetViewControllerDidSelectPayWithLink(self) + let payWithLinkVC = PayWithLinkWebController( + intent: intent, + configuration: configuration + ) + + payWithLinkVC.payWithLinkDelegate = self + payWithLinkVC.present(over: self) + } +} + +// MARK: - PayWithLinkWebControllerDelegate + +extension PaymentSheetViewController: PayWithLinkWebControllerDelegate { + + func payWithLinkWebControllerDidComplete( + _ PayWithLinkWebController: PayWithLinkWebController, + intent: Intent, + with paymentOption: PaymentOption + ) { + let backgroundColor = self.configuration.appearance.colors.background.withAlphaComponent(0.85) + bottomSheetController?.addBlurEffect(animated: false, backgroundColor: backgroundColor) { + self.bottomSheetController?.startSpinner() + self.clearTextFields() + self.pay(with: paymentOption, animateBuyButton: true) + } } + func payWithLinkWebControllerDidCancel(_ payWithLinkWebController: PayWithLinkWebController) { + } } // MARK: - BottomSheetContentViewController -/// :nodoc: extension PaymentSheetViewController: BottomSheetContentViewController { var allowsDragToDismiss: Bool { return isDismissable diff --git a/StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/PaymentSheetViewControllerSnapshotTests.swift b/StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/PaymentSheetViewControllerSnapshotTests.swift index 13646583d7d..4d7d1075e51 100644 --- a/StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/PaymentSheetViewControllerSnapshotTests.swift +++ b/StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/PaymentSheetViewControllerSnapshotTests.swift @@ -76,7 +76,4 @@ extension PaymentSheetViewControllerSnapshotTests: PaymentSheetViewControllerDel func paymentSheetViewControllerDidCancel(_ paymentSheetViewController: StripePaymentSheet.PaymentSheetViewController) { } - - func paymentSheetViewControllerDidSelectPayWithLink(_ paymentSheetViewController: StripePaymentSheet.PaymentSheetViewController) { - } }