Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting maxIssuerNumber for Twint via Drop-In configuration #1913

Merged
merged 10 commits into from
Dec 10, 2024
18 changes: 17 additions & 1 deletion AdyenActions/AdyenActionComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,35 @@ public final class AdyenActionComponent: ActionComponent, ActionHandlingComponen
public struct Twint {

/// The callback app scheme invoked once the Twint app is done with the payment
///
/// - Important: This value is required to only provide the scheme,
/// without a host/path/.... (e.g. "my-app", not a url "my-app://...")
public var callbackAppScheme: String

/// The issuer number of the highest scheme you listed under `LSApplicationQueriesSchemes`.
/// E.g. pass 39, if you listed all schemes from "twint-issuer1" up to and including "twint-issuer39". The value is clamped between 0 and 39.
///
/// - Important: All apps above "twint-issuer39" will always be returned if one of these apps is installed. For this to work, `LSApplicationQueriesSchemes` must include "twint-extended".
/// If you configure any `maxIssuerNumber` below 39, the result will always contain all apps above `maxIssuerNumber` up to and including 39, even if none of them are installed.
/// Additionally, if the fetch fails and the cache is empty, none of these apps will be found when probing.
public var maxIssuerNumber: Int

/// Initializes a new instance
///
/// - Parameter callbackAppScheme: The callback app scheme invoked once the Twint app is done with the payment
///
/// - Important: The value of ``callbackAppScheme`` is required to only provide the scheme,
/// without a host/path/... (e.g. "my-app", not a url "my-app://...")
public init(callbackAppScheme: String) {
public init(
callbackAppScheme: String,
maxIssuerNumber: Int = .max
) {
if !Self.isCallbackSchemeValid(callbackAppScheme) {
AdyenAssertion.assertionFailure(message: "Format of provided callbackAppScheme '\(callbackAppScheme)' is incorrect.")
}

self.callbackAppScheme = callbackAppScheme
self.maxIssuerNumber = maxIssuerNumber
}

/// Validating whether or not the provided `callbackAppScheme` only contains a scheme
Expand Down Expand Up @@ -265,6 +280,7 @@ public final class AdyenActionComponent: ActionComponent, ActionHandlingComponen
configuration: .init(
style: configuration.style.awaitComponentStyle,
callbackAppScheme: twintConfiguration.callbackAppScheme,
maxIssuerNumber: twintConfiguration.maxIssuerNumber,
localizationParameters: configuration.localizationParameters
)
)
Expand Down
Loading