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

[DO NOT MERGE] COIOS-834: Update TwintSDK to v8.0.2 #1905

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions AdyenActions/Components/SDK/Twint+Injectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,33 @@ import Foundation
}
}

@objc func pay(withCode code: String, appConfiguration: TWAppConfiguration, callback: String) -> Error? {
Twint.pay(withCode: code, appConfiguration: appConfiguration, callback: callback)
@objc func pay(
withCode code: String,
appConfiguration: TWAppConfiguration,
callback: String,
completionHandler: @escaping (Error?) -> Void
) {
Twint.pay(
withCode: code,
appConfiguration: appConfiguration,
callback: callback,
completionHandler: completionHandler
)
}

@objc
func registerForUOF(withCode code: String, appConfiguration: TWAppConfiguration, callback: String) -> Error? {
Twint.registerForUOF(withCode: code, appConfiguration: appConfiguration, callback: callback)
func registerForUOF(
withCode code: String,
appConfiguration: TWAppConfiguration,
callback: String,
completionHandler: @escaping (Error?) -> Void
) {
Twint.registerForUOF(
withCode: code,
appConfiguration: appConfiguration,
callback: callback,
completionHandler: completionHandler
)
}

@objc func controller(
Expand Down
35 changes: 19 additions & 16 deletions AdyenActions/Components/SDK/TwintSDKActionComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,32 +120,35 @@ import Foundation
}

private func invokeTwint(app: TWAppConfiguration, action: TwintSDKAction) {
let error: Error?
let completionHandler: (Error?) -> Void = { [weak self] error in
guard let self else { return }
if let error {
self.handleShowError(error.localizedDescription)
return
}

RedirectListener.registerForURL { [weak self] url in
self?.twint.handleOpen(url) { [weak self] error in
self?.handlePaymentResult(error: error, action: action)
}
}
}

if action.sdkData.isStored {
error = twint.registerForUOF(
twint.registerForUOF(
withCode: action.sdkData.token,
appConfiguration: app,
callback: configuration.callbackAppScheme
callback: configuration.callbackAppScheme,
completionHandler: completionHandler
)
} else {
error = twint.pay(
twint.pay(
withCode: action.sdkData.token,
appConfiguration: app,
callback: configuration.callbackAppScheme
callback: configuration.callbackAppScheme,
completionHandler: completionHandler
)
}

if let error {
handleShowError(error.localizedDescription)
return
}

RedirectListener.registerForURL { [weak self] url in
self?.twint.handleOpen(url) { [weak self] error in
self?.handlePaymentResult(error: error, action: action)
}
}
}

private func presentAppChooser(for installedApps: [TWAppConfiguration], action: TwintSDKAction) {
Expand Down
14 changes: 12 additions & 2 deletions Demo/SwiftUI/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSMinimumSystemVersion</key>
<string>14.0.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down Expand Up @@ -68,6 +66,16 @@
<string>wx33ed7fe146f6a50a</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
nauaros marked this conversation as resolved.
Show resolved Hide resolved
<string>Editor</string>
<key>CFBundleURLName</key>
<string>twint-issuer24</string>
<key>CFBundleURLSchemes</key>
<array>
<string>twint-issuer24</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
Expand All @@ -76,6 +84,8 @@
<string>weixin</string>
<string>weixinULAPI</string>
</array>
<key>LSMinimumSystemVersion</key>
<string>14.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSPhotoLibraryAddUsageDescription</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ import Foundation
internal typealias HandlePayBlock = (
_ code: String,
_ appConfiguration: TWAppConfiguration,
_ callbackAppScheme: String
) -> Error?
_ callbackAppScheme: String,
_ completionHandler: @escaping ((any Error)?) -> Void
) -> Void

internal typealias HandleRegisterForUOF = (
_ code: String,
_ appConfiguration: TWAppConfiguration,
_ callbackAppScheme: String
) -> Error?
_ callbackAppScheme: String,
_ completionHandler: @escaping ((any Error)?) -> Void
) -> Void

internal typealias HandleControllerBlock = (
_ installedAppConfigurations: [TWAppConfiguration],
Expand Down Expand Up @@ -64,21 +66,23 @@ import Foundation
) {
handleFetchInstalledAppConfigurations(completion)
}

@objc override internal func pay(
withCode code: String,
appConfiguration: TWAppConfiguration,
callback callbackAppScheme: String
) -> Error? {
handlePay(code, appConfiguration, callbackAppScheme)
callback callbackAppScheme: String,
completionHandler: @escaping ((any Error)?) -> Void
) {
handlePay(code, appConfiguration, callbackAppScheme, completionHandler)
}

@objc override internal func registerForUOF(
withCode code: String,
appConfiguration: TWAppConfiguration,
callback: String
) -> Error? {
handleRegisterForUOF(code, appConfiguration, callback)
callback: String,
completionHandler: @escaping (Error?) -> Void
) {
handleRegisterForUOF(code, appConfiguration, callback, completionHandler)
}

@objc override internal func controller(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([.dummy])
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
payBlockExpectation.fulfill()
return nil
} handleRegisterForUOF: { _, _, _ in
completionHandler(nil)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([])
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
XCTFail("Pay should not have been called")
return nil
} handleRegisterForUOF: { _, _, _ in
completionHandler(nil)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down Expand Up @@ -86,16 +86,16 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([.dummy])
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
payBlockExpectation.fulfill()
XCTAssertEqual(code, TwintSDKAction.dummy.sdkData.token)
XCTAssertEqual(appConfiguration.appDisplayName, TWAppConfiguration.dummy.appDisplayName)
XCTAssertEqual(appConfiguration.appURLScheme, TWAppConfiguration.dummy.appURLScheme)
XCTAssertEqual(callbackAppScheme, TwintSDKActionComponent.Configuration.dummy.callbackAppScheme)
return nil
} handleRegisterForUOF: { _, _, _ in
completionHandler(nil)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down Expand Up @@ -139,16 +139,16 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock(expectedAppConfigurations)
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
payBlockExpectation.fulfill()
XCTAssertEqual(code, TwintSDKAction.dummy.sdkData.token)
XCTAssertEqual(appConfiguration.appDisplayName, TWAppConfiguration.dummy.appDisplayName)
XCTAssertEqual(appConfiguration.appURLScheme, TWAppConfiguration.dummy.appURLScheme)
XCTAssertEqual(callbackAppScheme, TwintSDKActionComponent.Configuration.dummy.callbackAppScheme)
return nil
} handleRegisterForUOF: { _, _, _ in
completionHandler(nil)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTAssertEqual(installedAppConfigurations, expectedAppConfigurations)
appSelectionHandler = selectionHandler
Expand Down Expand Up @@ -222,12 +222,13 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([.dummy])
} handlePay: { code, appConfiguration, callbackAppScheme in
} handlePay: { code, appConfiguration, callbackAppScheme, completionHandler in
payBlockExpectation.fulfill()
return MockError(errorDescription: expectedAlertMessage)
} handleRegisterForUOF: { _, _, _ in
let error = MockError(errorDescription: expectedAlertMessage)
completionHandler(error)
} handleRegisterForUOF: { _, _, _, completionHandler in
XCTFail("RegisterForUOF should not have been called.")
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down Expand Up @@ -270,16 +271,16 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock([.dummy])
} handlePay: { _, _, _ in
} handlePay: { _, _, _, completionHandler in
XCTFail("Pay should not have been called.")
return nil
} handleRegisterForUOF: { code, appConfiguration, callbackAppScheme in
completionHandler(nil)
} handleRegisterForUOF: { code, appConfiguration, callbackAppScheme, completionHandler in
registerForUFO.fulfill()
XCTAssertEqual(code, TwintSDKAction.dummy.sdkData.token)
XCTAssertEqual(appConfiguration.appDisplayName, TWAppConfiguration.dummy.appDisplayName)
XCTAssertEqual(appConfiguration.appURLScheme, TWAppConfiguration.dummy.appURLScheme)
XCTAssertEqual(callbackAppScheme, TwintSDKActionComponent.Configuration.dummy.callbackAppScheme)
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTFail("Twint controller should not have been shown")
return nil
Expand Down Expand Up @@ -327,16 +328,16 @@ import XCTest
let twintSpy = TwintSpy { configurationsBlock in
fetchBlockExpectation.fulfill()
configurationsBlock(expectedAppConfigurations)
} handlePay: { _, _, _ in
} handlePay: { _, _, _, completionHandler in
XCTFail("Pay should not have been called.")
return nil
} handleRegisterForUOF: { code, appConfiguration, callbackAppScheme in
completionHandler(nil)
} handleRegisterForUOF: { code, appConfiguration, callbackAppScheme, completionHandler in
registerForUFO.fulfill()
XCTAssertEqual(code, TwintSDKAction.dummy.sdkData.token)
XCTAssertEqual(appConfiguration.appDisplayName, TWAppConfiguration.dummy.appDisplayName)
XCTAssertEqual(appConfiguration.appURLScheme, TWAppConfiguration.dummy.appURLScheme)
XCTAssertEqual(callbackAppScheme, TwintSDKActionComponent.Configuration.dummy.callbackAppScheme)
return nil
completionHandler(nil)
} handleController: { installedAppConfigurations, selectionHandler, cancelHandler in
XCTAssertEqual(installedAppConfigurations, expectedAppConfigurations)
appSelectionHandler = selectionHandler
Expand Down
4 changes: 4 additions & 0 deletions XCFramework/Dynamic/TwintSDK.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>TwintSDK.framework/TwintSDK</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
Expand All @@ -20,6 +22,8 @@
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>TwintSDK.framework/TwintSDK</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,37 @@

@interface Twint : NSObject

typedef void(^TWResponseHandler)(NSError *error);
typedef void (^TWResponseHandler)(NSError *error);

typedef void (^TWInstalledAppFetchHandler)(NSArray<TWAppConfiguration *>* installedAppConfigurations);

typedef void (^TWAppChooserSelectionHandler)(TWAppConfiguration* selectedConfiguration);

typedef void (^TWAppChooserCancelHandler)(void);

typedef void (^TWOpenTwintAppResultHandler)(NSError *error);

/**
* Calls the Twint app to execute a payment for a known code
* @param code The transaction code
* @param appConfiguration The app configuration with which the payment will be executed
* @param callbackAppScheme The callback app scheme invoked once the Twint app is done with the payment
* @return Returns a NSError object which is nil in case of successful call
* @param completionHandler The block which will be executed with an NSError object or nil in case of success
*/
+ (NSError*)payWithCode:(NSString*)code appConfiguration:(TWAppConfiguration *)appConfiguration callback:(NSString*)callbackAppScheme;
+ (void)payWithCode:(NSString*)code appConfiguration:(TWAppConfiguration *)appConfiguration callback:(NSString*)callbackAppScheme completionHandler:(TWOpenTwintAppResultHandler)completionHandler;

+ (NSError*)payWithCode:(NSString*)code appConfiguration:(TWAppConfiguration *)appConfiguration callback:(NSString*)callbackAppScheme __attribute__((deprecated("Use payWithCode:appConfiguration:callback:completionHandler: instead. This one fails on iOS 18 when using Xcode 16.")));

/**
* This method starts the registration process in the Twint app with a given code
* @param code The transaction code
* @param appConfiguration The app configuration with which the registration will be executed
* @param callbackAppScheme The callback app scheme invoked once the Twint app is done with the registration
* @return Returns a NSError object which is nil in case of successful call
* @param completionHandler The block which will be executed with an NSError object or nil in case of success
*/
+ (NSError *)registerForUOFWithCode:(NSString *)code appConfiguration:(TWAppConfiguration *)appConfiguration callback:(NSString *)callbackAppScheme;
+ (void)registerForUOFWithCode:(NSString *)code appConfiguration:(TWAppConfiguration *)appConfiguration callback:(NSString *)callbackAppScheme completionHandler:(TWOpenTwintAppResultHandler)completionHandler;

+ (NSError *)registerForUOFWithCode:(NSString *)code appConfiguration:(TWAppConfiguration *)appConfiguration callback:(NSString *)callbackAppScheme __attribute__((deprecated("Use registerForUOFWithCode:appConfiguration:callback:completionHandler: instead. This one fails on iOS 18 when using Xcode 16.")));

/**
* Fetches all available app configurations from a remote and returns all that are potentially installed on the device. If there is an error during the fetch, the cache will be used. If there is nothing in the cache yet, all Twint apps will be probed until one is found that is installed.
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
framework module TwintSDK {
umbrella header "TwintSDK.h"

export *

module * { export * }
}
Binary file not shown.
Loading
Loading