diff --git a/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift b/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift index 179866b14ed..9bf56df200c 100644 --- a/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift +++ b/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift @@ -14,6 +14,7 @@ import UIKit apiClient: STPAPIClient, clientSecret: String, returnURL: String?, + additionalParameters: [String: Any], onEvent: ((FinancialConnectionsEvent) -> Void)?, from presentingViewController: UIViewController, completion: @escaping (FinancialConnectionsSDKResult) -> Void diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Common/HostController.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Common/HostController.swift index d1713a2f729..cbba0f6a365 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Common/HostController.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Common/HostController.swift @@ -44,6 +44,7 @@ class HostController { private let returnURL: String? private let analyticsClient: FinancialConnectionsAnalyticsClient private let analyticsClientV1: STPAnalyticsClientProtocol + private let additionalParameters: [String: Any] private var nativeFlowController: NativeFlowController? lazy var hostViewController = HostViewController( @@ -57,6 +58,13 @@ class HostController { weak var delegate: HostControllerDelegate? + private var isPantherPayment: Bool { + guard let linkMode = additionalParameters["link_mode"] as? String else { + return false + } + return linkMode == "link_card_brand" + } + // MARK: - Init init( @@ -65,13 +73,15 @@ class HostController { clientSecret: String, returnURL: String?, publishableKey: String?, - stripeAccount: String? + stripeAccount: String?, + additionalParameters: [String: Any] ) { self.apiClient = apiClient self.analyticsClientV1 = analyticsClientV1 self.clientSecret = clientSecret self.returnURL = returnURL self.analyticsClient = FinancialConnectionsAnalyticsClient() + self.additionalParameters = additionalParameters analyticsClient.setAdditionalParameters( linkAccountSessionClientSecret: clientSecret, publishableKey: publishableKey, @@ -154,7 +164,8 @@ private extension HostController { apiClient: apiClient, manifest: manifest, sessionFetcher: sessionFetcher, - returnURL: returnURL + returnURL: returnURL, + isPantherPayment: isPantherPayment ) webFlowViewController.delegate = self navigationController.setViewControllers([webFlowViewController], animated: true) @@ -171,7 +182,8 @@ private extension HostController { accountPickerPane: synchronizePayload.text?.accountPickerPane, apiClient: apiClient, clientSecret: clientSecret, - analyticsClient: analyticsClient + analyticsClient: analyticsClient, + isPantherPayment: isPantherPayment ) nativeFlowController = NativeFlowController( dataManager: dataManager, diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift index 995deb3f7b2..e054d383bb0 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift @@ -20,6 +20,7 @@ public class FinancialConnectionsSDKImplementation: FinancialConnectionsSDKInter apiClient: STPAPIClient, clientSecret: String, returnURL: String?, + additionalParameters: [String: Any], onEvent: ((StripeCore.FinancialConnectionsEvent) -> Void)?, from presentingViewController: UIViewController, completion: @escaping (FinancialConnectionsSDKResult) -> Void @@ -30,6 +31,7 @@ public class FinancialConnectionsSDKImplementation: FinancialConnectionsSDKInter ) financialConnectionsSheet.apiClient = apiClient financialConnectionsSheet.onEvent = onEvent + financialConnectionsSheet.additionalParameters = additionalParameters // Captures self explicitly until the callback is invoked financialConnectionsSheet.present( from: presentingViewController, diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSheet.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSheet.swift index fcd81068e7e..51eca6e3551 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSheet.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSheet.swift @@ -77,6 +77,9 @@ final public class FinancialConnectionsSheet { // Analytics client to use for logging analytics @_spi(STP) public let analyticsClient: STPAnalyticsClientProtocol + // Any additional parameters useful for the financial connections SDK to know. + @_spi(STP) public var additionalParameters: [String: Any] = [:] + // MARK: - Init /** diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowDataManager.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowDataManager.swift index af017e24386..115848eb74c 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowDataManager.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowDataManager.swift @@ -34,6 +34,7 @@ protocol NativeFlowDataManager: AnyObject { var lastPaneLaunched: FinancialConnectionsSessionManifest.NextPane? { get set } var customSuccessPaneCaption: String? { get set } var customSuccessPaneSubCaption: String? { get set } + var isPantherPayment: Bool { get } func createPaymentDetails( consumerSessionClientSecret: String, @@ -83,6 +84,7 @@ class NativeFlowAPIDataManager: NativeFlowDataManager { let apiClient: FinancialConnectionsAPIClient let clientSecret: String let analyticsClient: FinancialConnectionsAnalyticsClient + let isPantherPayment: Bool var institution: FinancialConnectionsInstitution? var authSession: FinancialConnectionsAuthSession? @@ -117,7 +119,8 @@ class NativeFlowAPIDataManager: NativeFlowDataManager { accountPickerPane: FinancialConnectionsAccountPickerPane?, apiClient: FinancialConnectionsAPIClient, clientSecret: String, - analyticsClient: FinancialConnectionsAnalyticsClient + analyticsClient: FinancialConnectionsAnalyticsClient, + isPantherPayment: Bool ) { self.manifest = manifest self.visualUpdate = visualUpdate @@ -131,6 +134,7 @@ class NativeFlowAPIDataManager: NativeFlowDataManager { self.authSession = manifest.activeAuthSession // If the server returns active institution use that, otherwise resort to initial institution. self.institution = manifest.activeInstitution ?? manifest.initialInstitution + self.isPantherPayment = isPantherPayment didUpdateManifest() } diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Web/FinancialConnectionsWebFlowViewController.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Web/FinancialConnectionsWebFlowViewController.swift index db88f4d9a4a..260d6286038 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Web/FinancialConnectionsWebFlowViewController.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Web/FinancialConnectionsWebFlowViewController.swift @@ -69,6 +69,7 @@ final class FinancialConnectionsWebFlowViewController: UIViewController { private let sessionFetcher: FinancialConnectionsSessionFetcher private let manifest: FinancialConnectionsSessionManifest private let returnURL: String? + private let isPantherPayment: Bool // MARK: - UI @@ -94,13 +95,15 @@ final class FinancialConnectionsWebFlowViewController: UIViewController { apiClient: FinancialConnectionsAPIClient, manifest: FinancialConnectionsSessionManifest, sessionFetcher: FinancialConnectionsSessionFetcher, - returnURL: String? + returnURL: String?, + isPantherPayment: Bool ) { self.clientSecret = clientSecret self.apiClient = apiClient self.manifest = manifest self.sessionFetcher = sessionFetcher self.returnURL = returnURL + self.isPantherPayment = isPantherPayment super.init(nibName: nil, bundle: nil) } @@ -153,6 +156,9 @@ extension FinancialConnectionsWebFlowViewController { var additionalQueryParameters = additionalQueryParameters if manifest.isProductInstantDebits { additionalQueryParameters = (additionalQueryParameters ?? "") + "&return_payment_method=true" + if isPantherPayment { + additionalQueryParameters = (additionalQueryParameters ?? "") + "&link_mode=link_card_brand" + } } authSessionManager? .start(additionalQueryParameters: additionalQueryParameters) diff --git a/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift b/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift index 192a4221099..ab1c6581bc6 100644 --- a/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift +++ b/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift @@ -254,6 +254,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, + additionalParameters: additionalParameters, onEvent: onEvent, from: viewController ) { result in @@ -507,6 +508,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, + additionalParameters: additionalParameters, onEvent: onEvent, from: viewController ) { result in @@ -596,6 +598,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, + additionalParameters: additionalParameters, onEvent: onEvent, from: viewController ) { result in