Skip to content

Commit fcbfefc

Browse files
committed
Add FC Lite killswitch and priority override
1 parent 096e823 commit fcbfefc

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

Diff for: Example/FinancialConnections Example/FinancialConnections Example/Playground/PlaygroundViewModel.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,12 @@ final class PlaygroundViewModel: ObservableObject {
288288
}
289289

290290
func didSelectShow() {
291+
let useFCLite = playgroundConfiguration.sdkType == .fcLite
292+
FinancialConnectionsSDKAvailability.shouldPreferFCLite = useFCLite
293+
291294
switch playgroundConfiguration.integrationType {
292295
case .standalone:
293-
if playgroundConfiguration.sdkType == .fcLite {
296+
if useFCLite {
294297
setupFcLite()
295298
} else {
296299
setupStandalone()

Diff for: StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheetLoader.swift

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ final class PaymentSheetLoader {
110110
let isLinkEnabled = PaymentSheet.isLinkEnabled(elementsSession: elementsSession, configuration: configuration)
111111
let isApplePayEnabled = PaymentSheet.isApplePayEnabled(elementsSession: elementsSession, configuration: configuration)
112112

113+
// Disable FC Lite if killswitch is enabled
114+
let isFcLiteKillswitchEnabled = elementsSession.flags["elements_disable_fc_lite"] == true
115+
FinancialConnectionsSDKAvailability.fcLiteKillswitchEnabled = isFcLiteKillswitchEnabled
116+
113117
// Send load finished analytic
114118
// This is hacky; the logic to determine the default selected payment method belongs to the SavedPaymentOptionsViewController. We invoke it here just to report it to analytics before that VC loads.
115119
let (defaultSelectedIndex, paymentOptionsViewModels) = SavedPaymentOptionsViewController.makeViewModels(

Diff for: StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift

+18-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@ import UIKit
1515
NSClassFromString("StripeFinancialConnections.FinancialConnectionsSDKImplementation")
1616
as? FinancialConnectionsSDKInterface.Type
1717

18-
static let FinancialConnectionsLiteClass: FinancialConnectionsSDKInterface.Type? =
18+
static let FinancialConnectionsLiteImplementation: FinancialConnectionsSDKInterface.Type? =
1919
NSClassFromString("StripePaymentSheet.FCLiteImplementation")
2020
as? FinancialConnectionsSDKInterface.Type
2121

22+
@_spi(STP) public static var fcLiteKillswitchEnabled: Bool = false
23+
@_spi(STP) public static var shouldPreferFCLite: Bool = false
24+
25+
private static var FCLiteClassIfEnabled: FinancialConnectionsSDKInterface.Type? {
26+
guard !Self.fcLiteKillswitchEnabled else {
27+
return nil
28+
}
29+
return Self.FinancialConnectionsLiteImplementation
30+
}
31+
2232
static let isUnitTest: Bool = {
2333
#if targetEnvironment(simulator)
2434
return NSClassFromString("XCTest") != nil
@@ -37,14 +47,15 @@ import UIKit
3747

3848
// Return true for unit tests, the value of `FinancialConnectionsSDKAvailable` for UI tests,
3949
// and whether or not the Financial Connections SDK is available otherwise.
50+
// Falls back on FC Lite availability.
4051
@_spi(STP) public static var isFinancialConnectionsSDKAvailable: Bool {
4152
if isUnitTest {
4253
return true
4354
} else if isUITest {
4455
let financialConnectionsSDKAvailable = ProcessInfo.processInfo.environment["FinancialConnectionsSDKAvailable"] == "true"
4556
return financialConnectionsSDKAvailable
4657
} else {
47-
return (FinancialConnectionsSDKClass != nil || FinancialConnectionsLiteClass != nil)
58+
return (FinancialConnectionsSDKClass != nil || FCLiteClassIfEnabled != nil)
4859
}
4960
}
5061

@@ -54,7 +65,11 @@ import UIKit
5465
return StubbedConnectionsSDKInterface()
5566
}
5667

57-
guard let klass = /*FinancialConnectionsSDKClass ??*/ FinancialConnectionsLiteClass else {
68+
let klass: FinancialConnectionsSDKInterface.Type? = shouldPreferFCLite
69+
? (FCLiteClassIfEnabled ?? FinancialConnectionsSDKClass)
70+
: (FinancialConnectionsSDKClass ?? FCLiteClassIfEnabled)
71+
72+
guard let klass else {
5873
return nil
5974
}
6075

0 commit comments

Comments
 (0)