diff --git a/StripeCore/StripeCore.xcodeproj/project.pbxproj b/StripeCore/StripeCore.xcodeproj/project.pbxproj index 1317d96253e..3781dc919d3 100644 --- a/StripeCore/StripeCore.xcodeproj/project.pbxproj +++ b/StripeCore/StripeCore.xcodeproj/project.pbxproj @@ -42,6 +42,7 @@ 45DAE581F74EF7E11C64212B /* InstallMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21E64986F72C7BD8B1105A95 /* InstallMethod.swift */; }; 48A6CCB4008A5060C2655C5F /* XCTestCase+Stripe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DE48D0086BED21F9E837D0B /* XCTestCase+Stripe.swift */; }; 4910B9282C3D8F3F00B030D4 /* Result+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4910B9272C3D8F3F00B030D4 /* Result+Extensions.swift */; }; + 491785452D5A6027007B4BDF /* FinancialConnectionsConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 491785442D5A6027007B4BDF /* FinancialConnectionsConfiguration.swift */; }; 492039932CA47A8600CE2072 /* ElementsSessionContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 492039922CA47A8600CE2072 /* ElementsSessionContext.swift */; }; 493B33062CA3015600E3622F /* LinkMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 493B33052CA3015600E3622F /* LinkMode.swift */; }; 49E8CE2A2CD146CE0009DFBB /* KeyedEncodingContainer+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49E8CE292CD146CE0009DFBB /* KeyedEncodingContainer+Extensions.swift */; }; @@ -245,6 +246,7 @@ 4689F6B4384244D9FD282560 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 48A3D6592296104A1512AE92 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; 4910B9272C3D8F3F00B030D4 /* Result+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Result+Extensions.swift"; sourceTree = ""; }; + 491785442D5A6027007B4BDF /* FinancialConnectionsConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsConfiguration.swift; sourceTree = ""; }; 492039922CA47A8600CE2072 /* ElementsSessionContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementsSessionContext.swift; sourceTree = ""; }; 493B33052CA3015600E3622F /* LinkMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkMode.swift; sourceTree = ""; }; 49424775D3233411D9C2473B /* StripeCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StripeCodable.swift; sourceTree = ""; }; @@ -498,6 +500,7 @@ CB0E9DC72CB9C79E00E083D1 /* LinkBankPaymentMethod.swift */, CB8035292D31BA79008F0556 /* AvailableIncentives.swift */, CB80352B2D31BAC7008F0556 /* LinkConsumerIncentive.swift */, + 491785442D5A6027007B4BDF /* FinancialConnectionsConfiguration.swift */, ); path = "Connections Bindings"; sourceTree = ""; @@ -1021,6 +1024,7 @@ 6A05FB472BCF24370001D128 /* FinancialConnectionsLinkedBank.swift in Sources */, 9FBA50345D53E82AA974F672 /* STPAPIClient+FileUpload.swift in Sources */, 31AD3BDC2B0C23E40080C800 /* Locale+StripeCore.swift in Sources */, + 491785452D5A6027007B4BDF /* FinancialConnectionsConfiguration.swift in Sources */, C164984958CDC2C9CA4B6316 /* STPAPIClient.swift in Sources */, 97D0B2120678A75F75648D84 /* STPAppInfo.swift in Sources */, 12FF091C555F75B914464475 /* STPMultipartFormDataEncoder.swift in Sources */, diff --git a/StripeCore/StripeCore/Source/Connections Bindings/ElementsSessionContext.swift b/StripeCore/StripeCore/Source/Connections Bindings/ElementsSessionContext.swift index 775796e6a60..507a3a88316 100644 --- a/StripeCore/StripeCore/Source/Connections Bindings/ElementsSessionContext.swift +++ b/StripeCore/StripeCore/Source/Connections Bindings/ElementsSessionContext.swift @@ -44,14 +44,6 @@ import Foundation } } - /// Intermediary object between `PaymentSheet.Configuration.UserInterfaceStyle` - /// and `FinancialConnectionsSheet.Configuration.UserInterfaceStyle`. - @_spi(STP) @frozen public enum StyleConfig { - case automatic - case alwaysLight - case alwaysDark - } - @_spi(STP) public let amount: Int? @_spi(STP) public let currency: String? @_spi(STP) public let prefillDetails: PrefillDetails? @@ -59,7 +51,6 @@ import Foundation @_spi(STP) public let linkMode: LinkMode? @_spi(STP) public let billingDetails: BillingDetails? @_spi(STP) public let eligibleForIncentive: Bool - @_spi(STP) public let styleConfig: StyleConfig? @_spi(STP) public var billingAddress: BillingAddress? { BillingAddress(from: billingDetails) @@ -79,8 +70,7 @@ import Foundation intentId: IntentID? = nil, linkMode: LinkMode? = nil, billingDetails: BillingDetails? = nil, - eligibleForIncentive: Bool = false, - styleConfig: StyleConfig? = nil + eligibleForIncentive: Bool = false ) { self.amount = amount self.currency = currency @@ -89,7 +79,6 @@ import Foundation self.linkMode = linkMode self.billingDetails = billingDetails self.eligibleForIncentive = eligibleForIncentive - self.styleConfig = styleConfig } } diff --git a/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsConfiguration.swift b/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsConfiguration.swift new file mode 100644 index 00000000000..d3154799394 --- /dev/null +++ b/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsConfiguration.swift @@ -0,0 +1,24 @@ +// +// FinancialConnectionsConfiguration.swift +// StripeCore +// +// Created by Mat Schmid on 2025-02-10. +// + +import Foundation + +/// Intermediary object between `PaymentSheet.Configuration` / `STPBankAccountCollectorConfiguration` +/// and `FinancialConnectionsSheet.Configuration`. +@_spi(STP) public struct FinancialConnectionsConfiguration { + @_spi(STP) @frozen public enum StyleConfig { + case automatic + case alwaysLight + case alwaysDark + } + + @_spi(STP) public let styleConfig: StyleConfig + + @_spi(STP) public init(styleConfig: StyleConfig = .automatic) { + self.styleConfig = styleConfig + } +} diff --git a/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift b/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift index 1bdbb1f18b0..902152a2f4d 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?, + sheetConfiguration: FinancialConnectionsConfiguration?, elementsSessionContext: ElementsSessionContext?, onEvent: ((FinancialConnectionsEvent) -> Void)?, from presentingViewController: UIViewController, diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift index 8aa0cbfcc32..875c7898776 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?, + sheetConfiguration: FinancialConnectionsConfiguration?, elementsSessionContext: ElementsSessionContext?, onEvent: ((StripeCore.FinancialConnectionsEvent) -> Void)?, from presentingViewController: UIViewController, @@ -34,7 +35,7 @@ public class FinancialConnectionsSDKImplementation: FinancialConnectionsSDKInter financialConnectionsSheet.onEvent = onEvent var configuration = FinancialConnectionsSheet.Configuration() - if let styleConfig = elementsSessionContext?.styleConfig { + if let styleConfig = sheetConfiguration?.styleConfig { switch styleConfig { case .automatic: configuration.style = .automatic case .alwaysLight: configuration.style = .alwaysLight diff --git a/StripePaymentSheet/StripePaymentSheet.xcodeproj/project.pbxproj b/StripePaymentSheet/StripePaymentSheet.xcodeproj/project.pbxproj index 4adc52937ab..4c62584fb25 100644 --- a/StripePaymentSheet/StripePaymentSheet.xcodeproj/project.pbxproj +++ b/StripePaymentSheet/StripePaymentSheet.xcodeproj/project.pbxproj @@ -137,7 +137,6 @@ 47B19F96CCEA290541E3B988 /* CardSectionElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D03000A6807B09BFD8E6CB1 /* CardSectionElement.swift */; }; 48DA2EFE0944E737B0F197B0 /* OHHTTPStubs in Frameworks */ = {isa = PBXBuildFile; productRef = B2AFFAD776D5F21DF837F1BD /* OHHTTPStubs */; }; 49803444CD948F1ED28FF021 /* PaymentSheetFormFactory+FormSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD7A1EFF100C589FDFF4D516 /* PaymentSheetFormFactory+FormSpec.swift */; }; - 49AED8FB2D4C46A700FD7C23 /* ElementsSessionContext+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49AED8FA2D4C46A700FD7C23 /* ElementsSessionContext+Extensions.swift */; }; 49F62EDF394F18E5BB201D53 /* StripePaymentSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AA6166F234C3A2129CBD573 /* StripePaymentSheet.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4A1A0A542B824C830A200BE0 /* StubbedBackend.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF8498CCD12A5190F9267CD /* StubbedBackend.swift */; }; 4A8C7B2AFB290567C961DAB0 /* StripePaymentsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F22354BD25171B8DC2B922D2 /* StripePaymentsUI.framework */; }; @@ -560,7 +559,6 @@ 45B6DC9BD9183495E5649369 /* LinkAccountService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkAccountService.swift; sourceTree = ""; }; 47C5DB8C01BA7137369C8B4D /* TextFieldElement+Card.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TextFieldElement+Card.swift"; sourceTree = ""; }; 492B254E43F3BB9F9CEAEA06 /* PaymentSheetLoaderStubbedTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentSheetLoaderStubbedTest.swift; sourceTree = ""; }; - 49AED8FA2D4C46A700FD7C23 /* ElementsSessionContext+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ElementsSessionContext+Extensions.swift"; sourceTree = ""; }; 4BEFE8C0CFEAE73F9FD736D3 /* STPStringUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPStringUtils.swift; sourceTree = ""; }; 4C6AA41454A6757B3E26AE67 /* StripePaymentSheetTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StripePaymentSheetTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 4D595AA033BC84CB4E1C277F /* PaymentSheetFormFactorySnapshotTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentSheetFormFactorySnapshotTest.swift; sourceTree = ""; }; @@ -1237,7 +1235,6 @@ 4DA1B1B7662E177725062922 /* StripePaymentSheet+Exports.swift */, 70ED08B0F303B7C2334602C3 /* StripePaymentSheetBundleLocator.swift */, 6103F2BB2BE45990002D67F8 /* SavedPaymentMethodManager.swift */, - 49AED8FA2D4C46A700FD7C23 /* ElementsSessionContext+Extensions.swift */, ); path = Helpers; sourceTree = ""; @@ -2286,7 +2283,6 @@ B2979A0740F8730FC14DFEC1 /* BottomSheetViewController.swift in Sources */, 2E4C37C73AD202C8A3DD2E4E /* LoadingViewController.swift in Sources */, A8ECBDF889E258F03B86BC2E /* PaymentSheetFlowControllerViewController.swift in Sources */, - 49AED8FB2D4C46A700FD7C23 /* ElementsSessionContext+Extensions.swift in Sources */, 247A8FEE5184E5976720599E /* PaymentSheetViewController.swift in Sources */, 6B31B9BA2B90FCE60064E210 /* CustomerSession.swift in Sources */, 4DDECA1F7EC6B624C00D549E /* PollingViewController.swift in Sources */, diff --git a/StripePaymentSheet/StripePaymentSheet/Source/Helpers/ElementsSessionContext+Extensions.swift b/StripePaymentSheet/StripePaymentSheet/Source/Helpers/ElementsSessionContext+Extensions.swift deleted file mode 100644 index 9027860bd7b..00000000000 --- a/StripePaymentSheet/StripePaymentSheet/Source/Helpers/ElementsSessionContext+Extensions.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ElementsSessionContext+Extensions.swift -// StripePaymentSheet -// -// Created by Mat Schmid on 2025-01-30. -// - -@_spi(STP) import StripeCore - -extension ElementsSessionContext.StyleConfig { - /// Convenience init to transform a `PaymentSheet.UserInterfaceStyle` into `ElementsSessionContext.StyleConfig`. - init(from style: PaymentSheet.UserInterfaceStyle) { - switch style { - case .automatic: self = .automatic - case .alwaysLight: self = .alwaysLight - case .alwaysDark: self = .alwaysDark - } - } -} diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/CustomerSheet/CustomerAddPaymentMethodViewController.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/CustomerSheet/CustomerAddPaymentMethodViewController.swift index 0c3cef8dd21..95db20e1204 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/CustomerSheet/CustomerAddPaymentMethodViewController.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/CustomerSheet/CustomerAddPaymentMethodViewController.swift @@ -320,6 +320,17 @@ extension CustomerAddPaymentMethodViewController { } } + let bankAccountCollectorConfiguration: STPBankAccountCollectorConfiguration = { + let style: STPBankAccountCollectorConfiguration.UserInterfaceStyle = { + switch configuration.style { + case .automatic: return .automatic + case .alwaysLight: return .alwaysLight + case .alwaysDark: return .alwaysDark + } + }() + return .init(style: style) + }() + let additionalParameters: [String: Any] = [ "hosted_surface": "customer_sheet", ] @@ -327,6 +338,7 @@ extension CustomerAddPaymentMethodViewController { clientSecret: clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, onEvent: nil, params: params, from: viewController, diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Link/LinkPaymentController.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Link/LinkPaymentController.swift index 2a2a922bba3..abf30363cb9 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Link/LinkPaymentController.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Link/LinkPaymentController.swift @@ -247,6 +247,7 @@ import UIKit ) let elementsSessionContext = makeElementsSessionContext() + let bankAccountCollectorConfiguration = makeBankAccountCollectorConfiguration() switch mode { case .paymentIntentClientSecret(let string): @@ -254,6 +255,7 @@ import UIKit clientSecret: string, returnURL: configuration.returnURL, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, @@ -265,6 +267,7 @@ import UIKit clientSecret: string, returnURL: configuration.returnURL, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, @@ -290,6 +293,7 @@ import UIKit currency: currency, onBehalfOf: nil, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, from: presentingViewController, financialConnectionsCompletion: completionHandler @@ -314,7 +318,6 @@ import UIKit ) ) - let styleConfig = ElementsSessionContext.StyleConfig(from: configuration.style) return ElementsSessionContext( amount: mode.amount, currency: mode.currency, @@ -322,11 +325,21 @@ import UIKit intentId: nil, linkMode: nil, billingDetails: billingDetails, - eligibleForIncentive: false, - styleConfig: styleConfig + eligibleForIncentive: false ) } + private func makeBankAccountCollectorConfiguration() -> STPBankAccountCollectorConfiguration { + let style: STPBankAccountCollectorConfiguration.UserInterfaceStyle = { + switch configuration.style { + case .automatic: return .automatic + case .alwaysLight: return .alwaysLight + case .alwaysDark: return .alwaysDark + } + }() + return .init(style: style) + } + private func makePrefillDetails() -> ElementsSessionContext.PrefillDetails { var billingPhone: PhoneNumber? diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift index b20a63fcaa0..e30ee9e334d 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift @@ -275,7 +275,6 @@ extension PaymentMethodFormViewController { ) let linkMode = elementsSession.linkSettings?.linkMode let billingDetails = instantDebitsFormElement?.billingDetails - let styleConfig = ElementsSessionContext.StyleConfig(from: configuration.style) return ElementsSessionContext( amount: intent.amount, @@ -284,11 +283,21 @@ extension PaymentMethodFormViewController { intentId: intentId, linkMode: linkMode, billingDetails: billingDetails, - eligibleForIncentive: instantDebitsFormElement?.displayableIncentive != nil, - styleConfig: styleConfig + eligibleForIncentive: instantDebitsFormElement?.displayableIncentive != nil ) } + private var bankAccountCollectorConfiguration: STPBankAccountCollectorConfiguration { + let style: STPBankAccountCollectorConfiguration.UserInterfaceStyle = { + switch configuration.style { + case .automatic: return .automatic + case .alwaysLight: return .alwaysLight + case .alwaysDark: return .alwaysDark + } + }() + return .init(style: style) + } + private var shouldOverridePrimaryButton: Bool { if paymentMethodType == .stripe(.USBankAccount) { if case .new = paymentOption { @@ -394,6 +403,7 @@ extension PaymentMethodFormViewController { clientSecret: paymentIntent.clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, @@ -405,6 +415,7 @@ extension PaymentMethodFormViewController { clientSecret: setupIntent.clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, @@ -430,6 +441,7 @@ extension PaymentMethodFormViewController { currency: currency, onBehalfOf: intentConfig.onBehalfOf, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, from: viewController, financialConnectionsCompletion: financialConnectionsCompletion @@ -495,6 +507,7 @@ extension PaymentMethodFormViewController { clientSecret: paymentIntent.clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, @@ -506,6 +519,7 @@ extension PaymentMethodFormViewController { clientSecret: setupIntent.clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, @@ -531,6 +545,7 @@ extension PaymentMethodFormViewController { currency: currency, onBehalfOf: intentConfig.onBehalfOf, additionalParameters: additionalParameters, + configuration: bankAccountCollectorConfiguration, elementsSessionContext: elementsSessionContext, from: viewController, financialConnectionsCompletion: financialConnectionsCompletion diff --git a/StripePayments/StripePayments.xcodeproj/project.pbxproj b/StripePayments/StripePayments.xcodeproj/project.pbxproj index f31ca06c29c..2b7a6928666 100644 --- a/StripePayments/StripePayments.xcodeproj/project.pbxproj +++ b/StripePayments/StripePayments.xcodeproj/project.pbxproj @@ -99,6 +99,7 @@ 457AB5EDA3C13FF9FE9FBD9A /* STPBlocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01AD8DAB423F22BE6FC2FFCB /* STPBlocks.swift */; }; 466FD050408B0678FE5B60FC /* STPPaymentIntentEnums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BD1E8C2A561AF7E6CDFCD97 /* STPPaymentIntentEnums.swift */; }; 47677A8DE9E3D36E3392F7DE /* STPPaymentMethodAlipay.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF5E4108B8BF1C30BECC326 /* STPPaymentMethodAlipay.swift */; }; + 491785432D5A5D10007B4BDF /* STPBankAccountCollectorConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 491785422D5A5D10007B4BDF /* STPBankAccountCollectorConfiguration.swift */; }; 4A93430C40F5C73BC76447B2 /* StripePaymentsBundleLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 468FAF1D4D81DB5F5854287B /* StripePaymentsBundleLocator.swift */; }; 4C7486A126100F8F067F248A /* STPPaymentMethodGiropay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 444BEF2E8A83B5B489062595 /* STPPaymentMethodGiropay.swift */; }; 4C9A78FBE900C635CC3AA400 /* STPThreeDSUICustomization.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07382674619AEF657397B21 /* STPThreeDSUICustomization.swift */; }; @@ -480,6 +481,7 @@ 48A73DA27ABEC6115513F315 /* STPPaymentMethodNetBanking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodNetBanking.swift; sourceTree = ""; }; 48EE0DEDAB9A8BFF0523FF9F /* STPPaymentMethodBLIKParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodBLIKParams.swift; sourceTree = ""; }; 48F636D8CADF68EB74B88313 /* STPFixtures+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "STPFixtures+Swift.swift"; sourceTree = ""; }; + 491785422D5A5D10007B4BDF /* STPBankAccountCollectorConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPBankAccountCollectorConfiguration.swift; sourceTree = ""; }; 4C3628526271ABA16C3994EE /* STPConnectAccountAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPConnectAccountAddress.swift; sourceTree = ""; }; 4D99D2C6C436F6FAFB3960EE /* STPPaymentMethodBancontactParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodBancontactParams.swift; sourceTree = ""; }; 4FED7EC426D937D69C4B2D3B /* STPCollectBankAccountParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPCollectBankAccountParams.swift; sourceTree = ""; }; @@ -1130,6 +1132,7 @@ 2382674B84CA7425010A90D9 /* STPPaymentConfirmation+SwiftUI.swift */, 64C6DBBF4EED92890747C305 /* StripePayments+Export.swift */, 468FAF1D4D81DB5F5854287B /* StripePaymentsBundleLocator.swift */, + 491785422D5A5D10007B4BDF /* STPBankAccountCollectorConfiguration.swift */, ); path = Helpers; sourceTree = ""; @@ -1722,6 +1725,7 @@ 617C1C862BB496FC00B10AC5 /* STPPaymentMethodAlma.swift in Sources */, 5C525B22CAAC7F5AECD9A2E1 /* STPPaymentMethodCashApp.swift in Sources */, A654AC171329ED0CAF201AA6 /* STPPaymentMethodCashAppParams.swift in Sources */, + 491785432D5A5D10007B4BDF /* STPBankAccountCollectorConfiguration.swift in Sources */, C27F356B376711748348CF7A /* STPPaymentMethodEPS.swift in Sources */, E64BE0DAFA6617118654F975 /* STPPaymentMethodEPSParams.swift in Sources */, A2E2D049AA993AF599BA8809 /* STPPaymentMethodFPX.swift in Sources */, diff --git a/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift b/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift index 4e87cffc919..4b480ab79b8 100644 --- a/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift +++ b/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift @@ -106,6 +106,7 @@ public class STPBankAccountCollector: NSObject { /// - clientSecret: Client secret of the payment intent /// - returnURL: A URL that redirects back to your app to be used to return after completing authentication in another app (such as bank app or Safari). /// - params: Parameters for this call + /// - configuration: Configuration for the bank account collector. /// - viewController: Presenting view controller that will present the modal /// - onEvent: The `onEvent` closure is triggered upon the occurrence of specific events during the process of a user connecting their financial accounts. /// - completion: Completion block to be called on completion of the operation. @@ -115,6 +116,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, params: STPCollectBankAccountParams, + configuration: STPBankAccountCollectorConfiguration = .init(), from viewController: UIViewController, onEvent: ((FinancialConnectionsEvent) -> Void)?, completion: @escaping STPCollectBankAccountForPaymentCompletionBlock @@ -176,6 +178,7 @@ public class STPBankAccountCollector: NSObject { _collectBankAccountForPayment( clientSecret: clientSecret, returnURL: returnURL, + configuration: configuration, onEvent: onEvent, params: params, from: viewController, @@ -188,6 +191,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, additionalParameters: [String: Any] = [:], + configuration: STPBankAccountCollectorConfiguration, elementsSessionContext: ElementsSessionContext?, onEvent: ((FinancialConnectionsEvent) -> Void)?, params: STPCollectBankAccountParams, @@ -207,6 +211,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: clientSecret, returnURL: returnURL, additionalParameters: additionalParameters, + configuration: configuration, elementsSessionContext: elementsSessionContext, onEvent: onEvent, params: params, @@ -219,6 +224,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, additionalParameters: [String: Any] = [:], + configuration: STPBankAccountCollectorConfiguration, elementsSessionContext: ElementsSessionContext? = nil, onEvent: ((FinancialConnectionsEvent) -> Void)?, params: STPCollectBankAccountParams, @@ -257,6 +263,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, + sheetConfiguration: configuration.asFinancialConnectionsConfiguration, elementsSessionContext: elementsSessionContext, onEvent: onEvent, from: viewController @@ -367,6 +374,7 @@ public class STPBankAccountCollector: NSObject { /// - clientSecret: Client secret of the setup intent /// - returnURL: A URL that redirects back to your app to be used to return after completing authentication in another app (such as bank app or Safari). /// - params: Parameters for this call + /// - configuration: Configuration for the bank account collector. /// - viewController: Presenting view controller that will present the modal /// - onEvent: The `onEvent` closure is triggered upon the occurrence of specific events during the process of a user connecting their financial accounts. /// - completion: Completion block to be called on completion of the operation. @@ -376,6 +384,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, params: STPCollectBankAccountParams, + configuration: STPBankAccountCollectorConfiguration = .init(), from viewController: UIViewController, onEvent: ((FinancialConnectionsEvent) -> Void)?, completion: @escaping STPCollectBankAccountForSetupCompletionBlock @@ -436,6 +445,7 @@ public class STPBankAccountCollector: NSObject { collectBankAccountForSetup( clientSecret: clientSecret, returnURL: returnURL, + configuration: configuration, onEvent: onEvent, params: params, from: viewController, @@ -447,6 +457,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, additionalParameters: [String: Any] = [:], + configuration: STPBankAccountCollectorConfiguration, elementsSessionContext: ElementsSessionContext? = nil, onEvent: ((FinancialConnectionsEvent) -> Void)?, params: STPCollectBankAccountParams, @@ -466,6 +477,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: clientSecret, returnURL: returnURL, additionalParameters: additionalParameters, + configuration: configuration, elementsSessionContext: elementsSessionContext, onEvent: onEvent, params: params, @@ -478,6 +490,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, additionalParameters: [String: Any] = [:], + configuration: STPBankAccountCollectorConfiguration, elementsSessionContext: ElementsSessionContext?, onEvent: ((FinancialConnectionsEvent) -> Void)?, params: STPCollectBankAccountParams, @@ -515,6 +528,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, + sheetConfiguration: configuration.asFinancialConnectionsConfiguration, elementsSessionContext: elementsSessionContext, onEvent: onEvent, from: viewController @@ -567,6 +581,7 @@ public class STPBankAccountCollector: NSObject { currency: String?, onBehalfOf: String?, additionalParameters: [String: Any] = [:], + configuration: STPBankAccountCollectorConfiguration, elementsSessionContext: ElementsSessionContext?, from viewController: UIViewController, financialConnectionsCompletion: @escaping ( @@ -608,6 +623,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, + sheetConfiguration: configuration.asFinancialConnectionsConfiguration, elementsSessionContext: elementsSessionContext, onEvent: onEvent, from: viewController diff --git a/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollectorConfiguration.swift b/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollectorConfiguration.swift new file mode 100644 index 00000000000..b7b9b7f414c --- /dev/null +++ b/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollectorConfiguration.swift @@ -0,0 +1,44 @@ +// +// STPBankAccountCollectorConfiguration.swift +// StripePayments +// +// Created by Mat Schmid on 2025-02-10. +// + +import Foundation +@_spi(STP) import StripeCore + +/// Configuration for the bank account collector. +public struct STPBankAccountCollectorConfiguration { + /// Style options for colors in the bank account collector. + @frozen public enum UserInterfaceStyle { + /// (default) The bank account collector will automatically switch between light and dark mode compatible colors based on device settings. + case automatic + + /// The bank account collector will always use colors appropriate for light mode UI. + case alwaysLight + + /// The bank account collector will always use colors appropriate for dark mode UI. + case alwaysDark + } + + public var style: UserInterfaceStyle + + public init(style: UserInterfaceStyle = .automatic) { + self.style = style + } +} + +// MARK: Tramsformation helpers +extension STPBankAccountCollectorConfiguration { + var asFinancialConnectionsConfiguration: FinancialConnectionsConfiguration { + let styleConfig: FinancialConnectionsConfiguration.StyleConfig = { + switch style { + case .automatic: return .automatic + case .alwaysLight: return .alwaysLight + case .alwaysDark: return .alwaysDark + } + }() + return .init(styleConfig: styleConfig) + } +} diff --git a/StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift b/StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift index 03eb1e0be72..0865ab0e3cd 100644 --- a/StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift +++ b/StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift @@ -64,6 +64,7 @@ final class StubbedConnectionsSDKInterface: FinancialConnectionsSDKInterface { apiClient: STPAPIClient, clientSecret: String, returnURL: String?, + sheetConfiguration: FinancialConnectionsConfiguration?, elementsSessionContext: ElementsSessionContext?, onEvent: ((FinancialConnectionsEvent) -> Void)?, from presentingViewController: UIViewController,