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

COIOS-774: Pay by Bank #1878

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
4 changes: 4 additions & 0 deletions Adyen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
81A6B4E32AD53E3300A089A1 /* OpenExternalAppDetector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81A6B4E22AD53E3300A089A1 /* OpenExternalAppDetector.swift */; };
81A6B4E72AD54F6C00A089A1 /* OpenExternalAppDetector+Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81A6B4E52AD54F4F00A089A1 /* OpenExternalAppDetector+Mock.swift */; };
81A6B4EB2AD5546500A089A1 /* AdyenDependencies.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81A6B4EA2AD5546500A089A1 /* AdyenDependencies.swift */; };
81A741212C8B1E5700EB393D /* StoredPayByBankPaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81A741202C8B1E5700EB393D /* StoredPayByBankPaymentMethod.swift */; };
81A91AB72BEBEA21001E00C8 /* OpenExternalAppDetectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81A91AB62BEBEA21001E00C8 /* OpenExternalAppDetectorTests.swift */; };
81A91AC02BEC129D001E00C8 /* TwintSDK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00E5D6602AF527C200CDE118 /* TwintSDK.xcframework */; };
81A91AC12BEC129D001E00C8 /* TwintSDK.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 00E5D6602AF527C200CDE118 /* TwintSDK.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -1642,6 +1643,7 @@
81A6B4E22AD53E3300A089A1 /* OpenExternalAppDetector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenExternalAppDetector.swift; sourceTree = "<group>"; };
81A6B4E52AD54F4F00A089A1 /* OpenExternalAppDetector+Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OpenExternalAppDetector+Mock.swift"; sourceTree = "<group>"; };
81A6B4EA2AD5546500A089A1 /* AdyenDependencies.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdyenDependencies.swift; sourceTree = "<group>"; };
81A741202C8B1E5700EB393D /* StoredPayByBankPaymentMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoredPayByBankPaymentMethod.swift; sourceTree = "<group>"; };
81A91AB62BEBEA21001E00C8 /* OpenExternalAppDetectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenExternalAppDetectorTests.swift; sourceTree = "<group>"; };
81AA3B332ACD9CE800F5719D /* AddressLookupProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressLookupProvider.swift; sourceTree = "<group>"; };
81AA3B352AD02EAE00F5719D /* AddressLookupSearchViewController+ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AddressLookupSearchViewController+ViewModel.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3708,6 +3710,7 @@
E224088622AFA3A80058923E /* StoredInstantPaymentMethod.swift */,
F9D57529237C6084009C18B5 /* StoredBCMCPaymentMethod.swift */,
E71E8F3D257921D10054B03D /* StoredBLIKPaymentMethod.swift */,
81A741202C8B1E5700EB393D /* StoredPayByBankPaymentMethod.swift */,
E224088C22B0FD220058923E /* StoredPayPalPaymentMethod.swift */,
F9620D9E23C7457F005209FC /* WeChatPayPaymentMethod.swift */,
F926D52B23F59ABE00D058D3 /* QiwiWalletPaymentMethod.swift */,
Expand Down Expand Up @@ -7027,6 +7030,7 @@
F9FE253B2625AED6001874BB /* PartialPaymentComponent.swift in Sources */,
A001297C2C0DF2E0009EF80C /* StoredPaymentMethodsDelegate.swift in Sources */,
81C4006D2A41A2BC007EC51C /* FormAddressPickerItemView.swift in Sources */,
81A741212C8B1E5700EB393D /* StoredPayByBankPaymentMethod.swift in Sources */,
E9E3DB03222548E100697074 /* AdyenCoder.swift in Sources */,
A0C9B59B288AE34600D6BDAB /* InstallmentOptions.swift in Sources */,
81BA08412A4AD97400308160 /* FormValidatableValueItemView.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions Adyen/Core/Payment Methods/Abstract/AnyPaymentMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal enum AnyPaymentMethod: Codable {
case storedPayPal(StoredPayPalPaymentMethod)
case storedBCMC(StoredBCMCPaymentMethod)
case storedBlik(StoredBLIKPaymentMethod)
case storedPayByBankPlaid(StoredPayByBankPlaidPaymentMethod)
case storedAchDirectDebit(StoredACHDirectDebitPaymentMethod)
case storedCashAppPay(StoredCashAppPayPaymentMethod)
case storedTwint(StoredTwintPaymentMethod)
Expand Down Expand Up @@ -79,6 +80,7 @@ internal enum AnyPaymentMethod: Codable {
case let .upi(paymentMethod): return paymentMethod
case let .cashAppPay(paymentMethod): return paymentMethod
case let .twint(paymentMethod): return paymentMethod
case let .storedPayByBankPlaid(paymentMethod): return paymentMethod
case .none: return nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ internal enum AnyPaymentMethodDecoder {
.onlineBankingSK: OnlineBankingPaymentMethodDecoder(),
.upi: UPIPaymentMethodDecoder(),
.cashAppPay: CashAppPayPaymentMethodDecoder(),
.twint: TwintPaymentMethodDecoder()
.twint: TwintPaymentMethodDecoder(),
.payByBankPlaid: PayByBankPlaidPaymentMethodDecoder()
]

private static var defaultDecoder: PaymentMethodDecoder = InstantPaymentMethodDecoder()
Expand Down Expand Up @@ -340,6 +341,26 @@ private struct BLIKPaymentMethodDecoder: PaymentMethodDecoder {
}
}

private struct PayByBankPlaidPaymentMethodDecoder: PaymentMethodDecoder {
func decode(from decoder: Decoder, isStored: Bool) throws -> AnyPaymentMethod {
if isStored {
return try .storedPayByBankPlaid(StoredPayByBankPlaidPaymentMethod(from: decoder))
} else {
return try .instant(InstantPaymentMethod(from: decoder))
}
}

func anyPaymentMethod(from paymentMethod: any PaymentMethod) -> AnyPaymentMethod? {
if let method = paymentMethod as? StoredPayByBankPlaidPaymentMethod {
return .storedPayByBankPlaid(method)
}
if let method = paymentMethod as? InstantPaymentMethod {
return .instant(method)
}
return nil
}
}

private struct DokuPaymentMethodDecoder: PaymentMethodDecoder {
func decode(from decoder: Decoder, isStored: Bool) throws -> AnyPaymentMethod {
try .doku(DokuPaymentMethod(from: decoder))
Expand Down
4 changes: 4 additions & 0 deletions Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
case upi
case cashAppPay
case twint
case payByBankPlaid
case other(String)

// Unsupported
Expand Down Expand Up @@ -129,6 +130,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
case "cashapp": self = .cashAppPay
case "bizum": self = .bizum
case "twint": self = .twint
case "paybybank_AIS_DD": self = .payByBankPlaid
default: self = .other(rawValue)
}
}
Expand Down Expand Up @@ -191,6 +193,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
case .cashAppPay: return "cashapp"
case .bizum: return "bizum"
case .twint: return "twint"
case .payByBankPlaid: return "paybybank_AIS_DD"
case let .other(value): return value
}
}
Expand Down Expand Up @@ -260,6 +263,7 @@ extension PaymentMethodType {
case .cashAppPay: return "cash app"
case .bizum: return "bizum"
case .twint: return "twint"
case .payByBankPlaid: return "Pay By Bank using Plaid"
case let .other(name): return name.replacingOccurrences(of: "_", with: " ")
}
}
Expand Down
55 changes: 55 additions & 0 deletions Adyen/Core/Payment Methods/StoredPayByBankPaymentMethod.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// 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

/// Stored PayByBank payment.
public struct StoredPayByBankPlaidPaymentMethod: StoredPaymentMethod {

public let type: PaymentMethodType

public let name: String

public let label: String?

public var merchantProvidedDisplayInformation: MerchantCustomDisplayInformation?

public let identifier: String

public let supportedShopperInteractions: [ShopperInteraction]

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

@_spi(AdyenInternal)
public func defaultDisplayInformation(using parameters: LocalizationParameters?) -> DisplayInformation {
let title: String
let subtitle: String?

if let label {
title = label
subtitle = name
} else {
title = name
subtitle = nil
}

return DisplayInformation(title: title, subtitle: subtitle, logoName: type.rawValue)
}

// MARK: - Decoding

private enum CodingKeys: String, CodingKey {
case type
case name
case label
case identifier = "id"
case supportedShopperInteractions
}

}
Loading