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

new TwintSDK integration #1474

Merged
merged 126 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
f1a2774
Testing cocoapods twint sdk integration
neelSharma12 Nov 7, 2023
d875f53
Added Twint as SPM
neelSharma12 Nov 13, 2023
986046d
Fixed syntax
neelSharma12 Nov 13, 2023
c6fc858
updated twitn
neelSharma12 Nov 13, 2023
f4234fe
temp
neelSharma12 Nov 13, 2023
1a0d11d
temp
neelSharma12 Nov 13, 2023
7abfc3e
temp
neelSharma12 Nov 13, 2023
efd5ab4
temp
neelSharma12 Nov 13, 2023
77de274
temp
neelSharma12 Nov 13, 2023
38897a0
temp
neelSharma12 Nov 13, 2023
17fa79e
tempy
neelSharma12 Nov 13, 2023
7fb536f
tempy
neelSharma12 Nov 14, 2023
8482f68
tempy
neelSharma12 Nov 14, 2023
c214d18
Checking change version
neelSharma12 Nov 14, 2023
b9e021d
Revert "Checking change version"
neelSharma12 Nov 14, 2023
c71626b
Updated podspec
neelSharma12 Nov 27, 2023
7218f39
Updated podspec
neelSharma12 Nov 27, 2023
d1f672d
Updated podspec
neelSharma12 Nov 28, 2023
43ac5d2
Updated podspec
neelSharma12 Nov 28, 2023
2a628a1
Updated podspec
neelSharma12 Nov 28, 2023
2e47da9
Renamed Twint moduler
neelSharma12 Nov 29, 2023
a0733b6
Resolved conflicts
neelSharma12 Nov 29, 2023
7a76506
Fixed spell checker job
neelSharma12 Nov 29, 2023
cb331d2
Fixed spell check job
neelSharma12 Nov 30, 2023
17f5f4b
Merge branch 'develop' into feature_Twint
goergisn Dec 8, 2023
16c5afb
Merge branch 'develop' into feature_Twint
goergisn Dec 11, 2023
b82fa4f
Added Twint PM and Twint details
neelSharma12 Dec 11, 2023
07dd59e
Revert "Merge branch 'develop' into feature_Twint"
goergisn Dec 11, 2023
cc13fad
Revert "Merge branch 'develop' into feature_Twint"
goergisn Dec 11, 2023
be5df87
resolve conflict
neelSharma12 Dec 11, 2023
c482150
Revert "Revert "Merge branch 'develop' into feature_Twint""
goergisn Dec 11, 2023
cbddca2
Revert "Revert "Merge branch 'develop' into feature_Twint""
goergisn Dec 11, 2023
f6dbcc1
Merge branch 'develop' of github.com:Adyen/adyen-ios into feature_Twint
neelSharma12 Feb 2, 2024
e9e32e8
Added twint component, twint action component, tests
neelSharma12 Feb 29, 2024
ad671da
Checking for TwintSDK to make native and redirect flow possible
goergisn Feb 29, 2024
f24a93c
Adding Configuration to provide return url for the TwintSDKAction
goergisn Feb 29, 2024
a4a51cb
Better readability
goergisn Feb 29, 2024
ebbd955
Refactoring TwintSDKAction
goergisn Mar 1, 2024
5a8db94
Showing alert without a sheet + cancellation
goergisn Mar 1, 2024
a8a5835
Fixing typo
goergisn Mar 1, 2024
68885c9
[Twint] Checking for TwintSDK to make native and redirect flow possib…
neelSharma12 Mar 1, 2024
3f27167
[Twint] Adding Configuration to provide return url for the TwintSDKAc…
neelSharma12 Mar 1, 2024
9fb42b2
[Twint] Alert presentation fix (#1534)
neelSharma12 Mar 1, 2024
ac96b4c
Fixed DropIn Configuration for Twint
goergisn Mar 4, 2024
893a0df
Fixed DropIn Configuration for Twint (#1535)
neelSharma12 Mar 4, 2024
c258128
Injecting Twint into the TwintSDKActionComponent
goergisn Mar 4, 2024
c5d0cf8
Adding unit tests for the twint sdk action
goergisn Mar 4, 2024
8d97845
Injecting Twint into the TwintSDKActionComponent (#1536)
neelSharma12 Mar 5, 2024
b3e6dbf
Adding unit tests for the twint sdk action (#1537)
neelSharma12 Mar 5, 2024
8b48062
Merge branch 'develop' into feature_Twint
neelSharma12 Mar 5, 2024
745d888
Moving TwintSpy to Test target
goergisn Mar 5, 2024
24d1c01
Moving TwintSpy to Test target (#1538)
neelSharma12 Mar 5, 2024
b660886
handling twint redirect
goergisn Mar 5, 2024
a4b0200
Adding todos
goergisn Mar 5, 2024
e631df3
Reverting redirect handling check
goergisn Mar 6, 2024
ce9086a
handling twint redirect (#1540)
neelSharma12 Mar 6, 2024
ab0f528
ConfigurationConstants.returnUrl now returns a url
goergisn Mar 6, 2024
10f33af
Refactoring tests
goergisn Mar 6, 2024
8e25efd
Fixed tests + added validation
goergisn Mar 6, 2024
de8d739
ConfigurationConstants.returnUrl now returns a url (#1541)
neelSharma12 Mar 6, 2024
201515b
Added Adyen action in AdyenTwint podspec and package
neelSharma12 Mar 6, 2024
56b1c98
Merge branch 'feature_Twint' into twint_action_full_test
goergisn Mar 7, 2024
e7a1777
Fixing some warnings + failure flow tests
goergisn Mar 7, 2024
73f6238
Fixing demo app
goergisn Mar 8, 2024
1de70c0
Twint action full test (#1544)
neelSharma12 Mar 8, 2024
fbed89c
Updating strings
goergisn Mar 12, 2024
1f85375
Updating localization key
goergisn Mar 12, 2024
fe54396
Reverted Configuration
goergisn Mar 12, 2024
8cf8eec
Reverting german build setting
goergisn Mar 12, 2024
c526c9a
added documentation
neelSharma12 Mar 12, 2024
44e0ced
Updating strings (#1547)
neelSharma12 Mar 12, 2024
3cfbad2
Fixed review comments
neelSharma12 Mar 12, 2024
9ffbc90
updated readme file for twint component
neelSharma12 Mar 12, 2024
76dfdd9
added documentation (#1548)
neelSharma12 Mar 12, 2024
c22e137
Merge branch 'develop' of github.com:Adyen/adyen-ios into feature_Twint
neelSharma12 Mar 12, 2024
e30f3f3
Adding AdyenAction tests for Twint
goergisn Mar 13, 2024
09cb8a9
Adding AdyenAction tests for Twint (#1550)
neelSharma12 Mar 13, 2024
48590e7
Removed LocalizationKey from which was not needed
neelSharma12 Mar 25, 2024
83b3677
Resolved conflict
neelSharma12 Mar 25, 2024
4a8fcd3
Added changes related to status api call
neelSharma12 Apr 23, 2024
15fa3ab
Fixed polling tests
goergisn Apr 24, 2024
111814e
Added changes related to status api call (#1644)
neelSharma12 Apr 24, 2024
e1370ba
Merge branch 'develop' into feature_Twint
goergisn Apr 25, 2024
4f41c82
Fixed tests
goergisn Apr 25, 2024
660d4d2
fix: referencing self
goergisn Apr 25, 2024
fd75abc
using canImport(TwintSDK)
goergisn Apr 26, 2024
b69e4f0
Added AdyenTwint to CocoaPods integration test
goergisn Apr 26, 2024
ad4b824
Adding AdyenTwint to SPM integration test
goergisn Apr 26, 2024
05df667
Trying out bundling TwintSDK with AdyenTwint
goergisn Apr 26, 2024
1748514
Improving TWINT code
goergisn Apr 26, 2024
12e5173
Fixing tests
goergisn Apr 26, 2024
fe8b6be
Fixing carthage integration test
goergisn Apr 26, 2024
d8f7e0f
Fixing CancellableMock import
goergisn Apr 26, 2024
99e295c
moving to apple silicon for integration tests
goergisn Apr 26, 2024
3da3f50
fixing project
goergisn Apr 26, 2024
c5f8255
Merge branch 'develop' into feature_Twint
goergisn Apr 30, 2024
9028950
Some fixes
goergisn Apr 30, 2024
6ca3258
Adding WeChatPay scheme back
goergisn Apr 30, 2024
2a7952c
Some more project adjustment
goergisn Apr 30, 2024
27374ab
Fixing tests
goergisn Apr 30, 2024
87f4dd0
Merge branch 'develop' into feature_Twint
goergisn Apr 30, 2024
9523dbe
Fixing tests
goergisn Apr 30, 2024
c94a203
Trying something out
goergisn Apr 30, 2024
958efcc
Fixed package
goergisn Apr 30, 2024
51dc455
Removing unnecessary adyen dependency
goergisn Apr 30, 2024
5d6c493
Trying something
goergisn Apr 30, 2024
1918d92
fixing comma issue
goergisn Apr 30, 2024
c2d989d
trying something out
goergisn Apr 30, 2024
a577432
Trying out more
goergisn Apr 30, 2024
e277bd5
Make Twint work on SPM and CocoaPods
goergisn Apr 30, 2024
afcdd98
Commenting out archiving code
goergisn Apr 30, 2024
34be2f1
updating podspec
goergisn May 1, 2024
0302424
Reverting podspec change
goergisn May 1, 2024
33f8293
Trying to bump the swift tools version
goergisn May 1, 2024
15f7f70
Adding cleanup trap
goergisn May 2, 2024
d39aa4e
Trying out more
goergisn May 2, 2024
95e6ad9
not archiving for x68
goergisn May 2, 2024
62ed314
Only testing build
goergisn May 2, 2024
ba730c4
Maybe this works
goergisn May 2, 2024
8f55c06
actually running the archive code
goergisn May 2, 2024
f1392fb
Merge branch 'develop' into feature_Twint
goergisn May 2, 2024
1b758eb
Merge branch 'develop' into feature_Twint
goergisn May 2, 2024
0e6192f
Trying newer xcode version
goergisn May 2, 2024
4ab1ae1
Merge branch 'feature_Twint' of github.com:Adyen/adyen-ios into featu…
goergisn May 2, 2024
5c28d6e
lets try a newer macos and even newer xcode
goergisn May 2, 2024
74d49d7
Remove AdyenActions dependency from Twint
goergisn May 3, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test-SPM-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:

SPM:
runs-on: macos-13
runs-on: macos-13-xlarge # Apple Silicon Runner
steps:
- uses: actions/checkout@v4
- uses: n1hility/cancel-previous-runs@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-carthage-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:

carthage:
runs-on: macos-12-xl
runs-on: macos-13-xlarge # Apple Silicon Runner
steps:
- uses: actions/checkout@v4
- uses: n1hility/cancel-previous-runs@v3
Expand Down
7 changes: 7 additions & 0 deletions Adyen.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ Pod::Spec.new do |s|
plugin.dependency 'CashAppPayKitUI', '0.5.1'
end

s.subspec 'AdyenTwint' do |plugin|
plugin.source_files = 'AdyenTwint/**/*.swift'
plugin.dependency 'Adyen/Core'
plugin.dependency 'Adyen/Actions'
plugin.vendored_frameworks = 'XCFramework/Dynamic/TwintSDK.xcframework'
end

s.subspec 'Card' do |plugin|
plugin.dependency 'Adyen/Core'
plugin.dependency 'Adyen/Encryption'
Expand Down
462 changes: 399 additions & 63 deletions Adyen.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class PresentableComponentWrapper: PresentableComponent,
/// The wrapped component.
public let component: Component

public let requiresModalPresentation: Bool = true
public var requiresModalPresentation: Bool = true

@_spi(AdyenInternal)
public var navBarType: NavigationBarType
Expand Down
9 changes: 9 additions & 0 deletions Adyen/Core/Components/InstantPaymentComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

import Foundation

@_spi(AdyenInternal)
public protocol PaymentInitiable {
/// Initiate the payment flow
func initiatePayment()
}

/// A component that handles payment methods that don't need any payment detail to be filled.
public final class InstantPaymentComponent: PaymentComponent {

Expand Down Expand Up @@ -62,6 +68,9 @@ public final class InstantPaymentComponent: PaymentComponent {
}
}

@_spi(AdyenInternal)
extension InstantPaymentComponent: PaymentInitiable {}

/// Describes a payment details that contains nothing but the payment method type name.
public struct InstantPaymentDetails: PaymentMethodDetails {

Expand Down
3 changes: 3 additions & 0 deletions Adyen/Core/Core Protocols/PaymentComponentBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public protocol PaymentComponentBuilder: AdyenContextAware {
/// Builds a certain `PaymentComponent` based on a `StoredCashAppPayPaymentMethod`.
func build(paymentMethod: StoredCashAppPayPaymentMethod) -> PaymentComponent?

/// Builds a certain `PaymentComponent` based on a `TwintPaymentMethod`.
func build(paymentMethod: TwintPaymentMethod) -> PaymentComponent?

/// Builds a certain `PaymentComponent` based on any `PaymentMethod`, as a default case.
func build(paymentMethod: PaymentMethod) -> PaymentComponent?

Expand Down
4 changes: 3 additions & 1 deletion Adyen/Core/Payment Methods/Abstract/AnyPaymentMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ internal enum AnyPaymentMethod: Codable {
case onlineBanking(OnlineBankingPaymentMethod)
case upi(UPIPaymentMethod)
case cashAppPay(CashAppPayPaymentMethod)

case twint(TwintPaymentMethod)

case none

internal var value: PaymentMethod? {
Expand Down Expand Up @@ -75,6 +76,7 @@ internal enum AnyPaymentMethod: Codable {
case let .onlineBanking(paymentMethod): return paymentMethod
case let .upi(paymentMethod): return paymentMethod
case let .cashAppPay(paymentMethod): return paymentMethod
case let .twint(paymentMethod): return paymentMethod
case .none: return nil
}
}
Expand Down
23 changes: 21 additions & 2 deletions Adyen/Core/Payment Methods/Abstract/AnyPaymentMethodDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ private struct PaymentMethodField: Decodable {
private enum CodingKeys: String, CodingKey {
case key, type, isOptional = "optional"
}

}

internal enum AnyPaymentMethodDecoder {
Expand Down Expand Up @@ -83,7 +82,8 @@ internal enum AnyPaymentMethodDecoder {
.onlineBankingCZ: OnlineBankingPaymentMethodDecoder(),
.onlineBankingSK: OnlineBankingPaymentMethodDecoder(),
.upi: UPIPaymentMethodDecoder(),
.cashAppPay: CashAppPayPaymentMethodDecoder()
.cashAppPay: CashAppPayPaymentMethodDecoder(),
.twint: TwintPaymentMethodDecoder()
]

private static var defaultDecoder: PaymentMethodDecoder = InstantPaymentMethodDecoder()
Expand Down Expand Up @@ -479,3 +479,22 @@ private struct CashAppPayPaymentMethodDecoder: PaymentMethodDecoder {
return nil
}
}

private struct TwintPaymentMethodDecoder: PaymentMethodDecoder {

func decode(from decoder: Decoder, isStored: Bool) throws -> AnyPaymentMethod {
#if canImport(TwintSDK)
try .twint(TwintPaymentMethod(from: decoder))
#else
return AnyPaymentMethod(InstantPaymentMethod(type: .twint, name: "Twint"))
#endif
}

func anyPaymentMethod(from paymentMethod: any PaymentMethod) -> AnyPaymentMethod? {
#if canImport(TwintSDK)
(paymentMethod as? TwintPaymentMethod).map { .twint($0) }
#else
return nil
#endif
}
}
7 changes: 7 additions & 0 deletions Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
case upi
case cashAppPay
case bizum
case twint
case other(String)

// swiftlint:disable cyclomatic_complexity function_body_length
Expand Down Expand Up @@ -119,6 +120,8 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
case "upi": self = .upi
case "cashapp": self = .cashAppPay
case "bizum": self = .bizum
case "twint": self = .twint

default: self = .other(rawValue)
}
}
Expand Down Expand Up @@ -177,6 +180,8 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
case .upi: return "upi"
case .cashAppPay: return "cashapp"
case .bizum: return "bizum"
case .twint: return "twint"

case let .other(value): return value
}
}
Expand Down Expand Up @@ -242,6 +247,8 @@ extension PaymentMethodType {
case .upi: return "UPI"
case .cashAppPay: return "cash app"
case .bizum: return "bizum"
case .twint: return "twint"

case let .other(name): return name.replacingOccurrences(of: "_", with: " ")
}
}
Expand Down
29 changes: 29 additions & 0 deletions Adyen/Core/Payment Methods/TwintPaymentMethod.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

import Foundation

// Twint payment method
public struct TwintPaymentMethod: PaymentMethod {

public var type: PaymentMethodType

public var name: String

public var merchantProvidedDisplayInformation: MerchantCustomDisplayInformation?

@_spi(AdyenInternal)
public func buildComponent(using builder: PaymentComponentBuilder) -> PaymentComponent? {
builder.build(paymentMethod: self)
}

// MARK: - Private

private enum CodingKeys: String, CodingKey {
case type
case name
}
}
3 changes: 3 additions & 0 deletions AdyenActions/Actions/AwaitAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public enum AwaitPaymentMethod: String, Decodable {

/// upi
case upicollect = "upi_collect"

/// Twint payment method
case twint
}

/// Describes an action in which the SDK is waiting for user action.
Expand Down
6 changes: 6 additions & 0 deletions AdyenActions/Actions/SDKAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ public enum SDKAction: Decodable {
/// Indicates a WeChat Pay SDK action.
case weChatPay(WeChatPaySDKAction)

/// Indicates a Twint SDK action.
case twint(TwintSDKAction)

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let type = try container.decode(SDKType.self, forKey: CodingKeys.type)

switch type {
case .weChatPay:
self = try .weChatPay(WeChatPaySDKAction(from: decoder))
case .twint:
self = try .twint(TwintSDKAction(from: decoder))
}
}

Expand All @@ -28,5 +33,6 @@ public enum SDKAction: Decodable {

private enum SDKType: String, Decodable {
case weChatPay = "wechatpaySDK"
case twint = "twint"
}
}
50 changes: 50 additions & 0 deletions AdyenActions/Actions/TwintSDKAction.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

import Foundation

/// Describes an action in which the user is redirected to the Twint SDK.
public final class TwintSDKAction: PaymentDataAware, Decodable {

/// The TwintSDK specific data.
public let sdkData: TwintSDKData

/// The server-generated payment data that should be submitted to the `/payments/details` endpoint.
public let paymentData: String

// The payment method type
public let paymentMethodType: String

// The payment method subtype
public let type: String

internal enum CodingKeys: CodingKey {
case sdkData
case paymentData
case paymentMethodType
case type
}

public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.sdkData = try container.decode(TwintSDKData.self, forKey: .sdkData)
self.paymentData = try container.decode(String.self, forKey: .paymentData)
self.paymentMethodType = try container.decode(String.self, forKey: .paymentMethodType)
self.type = try container.decode(String.self, forKey: .type)
}

internal init(
sdkData: TwintSDKData,
paymentData: String,
paymentMethodType: String,
type: String
) {
self.sdkData = sdkData
self.paymentData = paymentData
self.paymentMethodType = paymentMethodType
self.type = type
}
}
27 changes: 27 additions & 0 deletions AdyenActions/Actions/TwintSDKData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

import Foundation

/// Describes the data required by the Twint SDK to complete the payment.
public struct TwintSDKData: Decodable {

/// SDK token.
public let token: String

private enum CodingKeys: String, CodingKey {
case token
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
token = try container.decode(String.self, forKey: .token)
}

internal init(token: String) {
self.token = token
}
}
Loading
Loading