diff --git a/StripeCore/StripeCore.xcodeproj/project.pbxproj b/StripeCore/StripeCore.xcodeproj/project.pbxproj index 9ea62074a92..22293cd96e5 100644 --- a/StripeCore/StripeCore.xcodeproj/project.pbxproj +++ b/StripeCore/StripeCore.xcodeproj/project.pbxproj @@ -39,7 +39,6 @@ 4910B9282C3D8F3F00B030D4 /* Result+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4910B9272C3D8F3F00B030D4 /* Result+Extensions.swift */; }; 49ECDA412CA340E100F647F0 /* AsyncTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49ECDA402CA340E100F647F0 /* AsyncTests.swift */; }; 493B33062CA3015600E3622F /* LinkMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 493B33052CA3015600E3622F /* LinkMode.swift */; }; - 4955688F2CA1FB8D00518AFD /* ElementsContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4955688E2CA1FB8D00518AFD /* ElementsContext.swift */; }; 4B2FAC57E03D8654A177C408 /* Dictionary+Stripe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7727AEEFD2FC880BADDA1872 /* Dictionary+Stripe.swift */; }; 53D46A03B77577EE21F4B166 /* StripeCodableTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FCE36551600C3E53BEAF8F0 /* StripeCodableTest.swift */; }; 552DA7969984C443617DBC3E /* STPMultipartFormDataPart.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1C72BA9C44FF60A0E7BEF76 /* STPMultipartFormDataPart.swift */; }; @@ -229,11 +228,11 @@ 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 = ""; }; + 492039902CA4624600CE2072 /* 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 = ""; }; 49538DBF8457D96707A2DA56 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; 49ECDA402CA340E100F647F0 /* AsyncTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncTests.swift; sourceTree = ""; }; - 4955688E2CA1FB8D00518AFD /* ElementsContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementsContext.swift; sourceTree = ""; }; 4A8030BF88608CA86E295F18 /* Enums+CustomStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Enums+CustomStringConvertible.swift"; sourceTree = ""; }; 4C51E3FA5EE3587BB7BBC634 /* STPError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPError.swift; sourceTree = ""; }; 4EC3BCEEECB3E1485B18F0C4 /* FinancialConnectionsSDKInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsSDKInterface.swift; sourceTree = ""; }; @@ -451,8 +450,8 @@ 6A05FB462BCF24370001D128 /* FinancialConnectionsLinkedBank.swift */, 6A05FB482BCF244A0001D128 /* InstantDebitsLinkedBank.swift */, 6A05FB4A2BCF245C0001D128 /* FinancialConnectionsEvent.swift */, - 4955688E2CA1FB8D00518AFD /* ElementsContext.swift */, 493B33052CA3015600E3622F /* LinkMode.swift */, + 492039902CA4624600CE2072 /* ElementsSessionContext.swift */, ); path = "Connections Bindings"; sourceTree = ""; @@ -981,6 +980,7 @@ 02A26B79617FAE660C9EB506 /* StripeError.swift in Sources */, 3B9D69AB1CB61725C7A012B6 /* StripeServiceError.swift in Sources */, 95156E152471058151076A51 /* Analytic.swift in Sources */, + 492039912CA4624600CE2072 /* ElementsSessionContext.swift in Sources */, 766FE8E61B44967F057ED424 /* AnalyticLoggableError.swift in Sources */, 3815D229613D52D7799805B0 /* AnalyticsClientV2.swift in Sources */, 35931C64F06BEB233A219869 /* NetworkDetector.swift in Sources */, @@ -1014,7 +1014,6 @@ 096274D0729AA8849FAD103C /* PaymentsSDKVariant.swift in Sources */, DA5A05459309B9B77ACDD736 /* STPDeviceUtils.swift in Sources */, 4910B9282C3D8F3F00B030D4 /* Result+Extensions.swift in Sources */, - 4955688F2CA1FB8D00518AFD /* ElementsContext.swift in Sources */, 83790210FFC2DD764C042C8E /* STPDispatchFunctions.swift in Sources */, 72DA29CA8A750E8B00DBF3D4 /* STPError.swift in Sources */, F628BBE9FDA9D3A217ACA753 /* STPNumericStringValidator.swift in Sources */, diff --git a/StripeCore/StripeCore/Source/Connections Bindings/ElementsContext.swift b/StripeCore/StripeCore/Source/Connections Bindings/ElementsContext.swift deleted file mode 100644 index 42055554375..00000000000 --- a/StripeCore/StripeCore/Source/Connections Bindings/ElementsContext.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// ElementsContext.swift -// StripeCore -// -// Created by Mat Schmid on 2024-09-23. -// - -import Foundation - -@_spi(STP) public struct ElementsContext { - @_spi(STP) public let linkMode: LinkMode? - - @_spi(STP) public init(linkMode: LinkMode?) { - self.linkMode = linkMode - } -} diff --git a/StripeCore/StripeCore/Source/Connections Bindings/ElementsSessionContext.swift b/StripeCore/StripeCore/Source/Connections Bindings/ElementsSessionContext.swift new file mode 100644 index 00000000000..842f6afe6f8 --- /dev/null +++ b/StripeCore/StripeCore/Source/Connections Bindings/ElementsSessionContext.swift @@ -0,0 +1,17 @@ +// +// ElementsSessionContext.swift +// StripeCore +// +// Created by Mat Schmid on 2024-09-25. +// + +import Foundation + +/// Contains elements session context useful for the Financial Connections SDK. +@_spi(STP) public struct ElementsSessionContext { + @_spi(STP) public let linkMode: LinkMode? + + @_spi(STP) public init(linkMode: LinkMode?) { + self.linkMode = linkMode + } +} diff --git a/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift b/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift index 05bfb0a937d..1bdbb1f18b0 100644 --- a/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift +++ b/StripeCore/StripeCore/Source/Connections Bindings/FinancialConnectionsSDKInterface.swift @@ -14,7 +14,7 @@ import UIKit apiClient: STPAPIClient, clientSecret: String, returnURL: String?, - elementsContext: ElementsContext?, + elementsSessionContext: ElementsSessionContext?, onEvent: ((FinancialConnectionsEvent) -> Void)?, from presentingViewController: UIViewController, completion: @escaping (FinancialConnectionsSDKResult) -> Void diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift index 40052da83d6..8b7e61c8d37 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSDK/FinancialConnectionsSDKImplementation.swift @@ -20,7 +20,7 @@ public class FinancialConnectionsSDKImplementation: FinancialConnectionsSDKInter apiClient: STPAPIClient, clientSecret: String, returnURL: String?, - elementsContext: ElementsContext?, + elementsSessionContext: ElementsSessionContext?, onEvent: ((StripeCore.FinancialConnectionsEvent) -> Void)?, from presentingViewController: UIViewController, completion: @escaping (FinancialConnectionsSDKResult) -> Void @@ -30,7 +30,7 @@ public class FinancialConnectionsSDKImplementation: FinancialConnectionsSDKInter returnURL: returnURL ) financialConnectionsSheet.apiClient = apiClient - financialConnectionsSheet.elementsContext = elementsContext + financialConnectionsSheet.elementsSessionContext = elementsSessionContext financialConnectionsSheet.onEvent = onEvent // Captures self explicitly until the callback is invoked financialConnectionsSheet.present( diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSheet.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSheet.swift index 377d2eea14e..7c6dc598000 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSheet.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/FinancialConnectionsSheet.swift @@ -75,7 +75,7 @@ final public class FinancialConnectionsSheet { private var wrapperViewController: ModalPresentationWrapperViewController? // Any additional Elements context useful for the Financial Connections SDK. - @_spi(STP) public var elementsContext: ElementsContext? + @_spi(STP) public var elementsSessionContext: ElementsSessionContext? // Analytics client to use for logging analytics @_spi(STP) public let analyticsClient: STPAnalyticsClientProtocol diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift index f802e6f92ac..c56518ae341 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift @@ -208,9 +208,9 @@ extension PaymentMethodFormViewController { private var usBankAccountFormElement: USBankAccountPaymentMethodElement? { form as? USBankAccountPaymentMethodElement } private var instantDebitsFormElement: InstantDebitsPaymentMethodElement? { form as? InstantDebitsPaymentMethodElement } - private var elementsContext: ElementsContext? { + private var elementsSessionContext: ElementsSessionContext? { let linkMode = elementsSession.linkSettings?.linkMode - return ElementsContext(linkMode: linkMode) + return ElementsSessionContext(linkMode: linkMode) } private var shouldOverridePrimaryButton: Bool { @@ -317,7 +317,7 @@ extension PaymentMethodFormViewController { clientSecret: paymentIntent.clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, from: viewController, @@ -328,7 +328,7 @@ extension PaymentMethodFormViewController { clientSecret: setupIntent.clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, from: viewController, @@ -353,7 +353,7 @@ extension PaymentMethodFormViewController { currency: currency, onBehalfOf: intentConfig.onBehalfOf, additionalParameters: additionalParameters, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, from: viewController, financialConnectionsCompletion: financialConnectionsCompletion ) @@ -410,7 +410,7 @@ extension PaymentMethodFormViewController { clientSecret: paymentIntent.clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, from: viewController, @@ -421,7 +421,7 @@ extension PaymentMethodFormViewController { clientSecret: setupIntent.clientSecret, returnURL: configuration.returnURL, additionalParameters: additionalParameters, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: nil, params: params, from: viewController, diff --git a/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift b/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift index 503dfda3093..2760eb3b3e7 100644 --- a/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift +++ b/StripePayments/StripePayments/Source/Helpers/STPBankAccountCollector.swift @@ -188,7 +188,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, additionalParameters: [String: Any] = [:], - elementsContext: ElementsContext?, + elementsSessionContext: ElementsSessionContext?, onEvent: ((FinancialConnectionsEvent) -> Void)?, params: STPCollectBankAccountParams, from viewController: UIViewController, @@ -207,7 +207,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: clientSecret, returnURL: returnURL, additionalParameters: additionalParameters, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: onEvent, params: params, from: viewController, @@ -219,7 +219,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, additionalParameters: [String: Any] = [:], - elementsContext: ElementsContext? = nil, + elementsSessionContext: ElementsSessionContext? = nil, onEvent: ((FinancialConnectionsEvent) -> Void)?, params: STPCollectBankAccountParams, from viewController: UIViewController, @@ -257,7 +257,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: onEvent, from: viewController ) { result in @@ -446,7 +446,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, additionalParameters: [String: Any] = [:], - elementsContext: ElementsContext? = nil, + elementsSessionContext: ElementsSessionContext? = nil, onEvent: ((FinancialConnectionsEvent) -> Void)?, params: STPCollectBankAccountParams, from viewController: UIViewController, @@ -465,7 +465,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: clientSecret, returnURL: returnURL, additionalParameters: additionalParameters, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: onEvent, params: params, from: viewController, @@ -477,7 +477,7 @@ public class STPBankAccountCollector: NSObject { clientSecret: String, returnURL: String?, additionalParameters: [String: Any] = [:], - elementsContext: ElementsContext?, + elementsSessionContext: ElementsSessionContext?, onEvent: ((FinancialConnectionsEvent) -> Void)?, params: STPCollectBankAccountParams, from viewController: UIViewController, @@ -514,7 +514,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: onEvent, from: viewController ) { result in @@ -565,7 +565,7 @@ public class STPBankAccountCollector: NSObject { currency: String?, onBehalfOf: String?, additionalParameters: [String: Any] = [:], - elementsContext: ElementsContext?, + elementsSessionContext: ElementsSessionContext?, from viewController: UIViewController, financialConnectionsCompletion: @escaping ( FinancialConnectionsSDKResult?, LinkAccountSession?, NSError? @@ -605,7 +605,7 @@ public class STPBankAccountCollector: NSObject { apiClient: self.apiClient, clientSecret: linkAccountSession.clientSecret, returnURL: returnURL, - elementsContext: elementsContext, + elementsSessionContext: elementsSessionContext, onEvent: onEvent, from: viewController ) { result in diff --git a/StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift b/StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift index e3bf7ef6d38..0853c38e1ab 100644 --- a/StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift +++ b/StripePayments/StripePayments/Source/Internal/Helpers/ConnectionsSDKAvailability.swift @@ -51,7 +51,7 @@ final class StubbedConnectionsSDKInterface: FinancialConnectionsSDKInterface { apiClient: STPAPIClient, clientSecret: String, returnURL: String?, - elementsContext: ElementsContext?, + elementsSessionContext: ElementsSessionContext?, onEvent: ((FinancialConnectionsEvent) -> Void)?, from presentingViewController: UIViewController, completion: @escaping (FinancialConnectionsSDKResult) -> Void