From f3b71b99929f93263ef96cf67e4dc8bd6e55fcb4 Mon Sep 17 00:00:00 2001 From: vladimir Date: Fri, 3 Nov 2023 13:13:00 +0100 Subject: [PATCH 1/6] feat: disable bizum PM --- .../Payment Methods/Abstract/AnyPaymentMethodDecoder.swift | 3 ++- Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Adyen/Core/Payment Methods/Abstract/AnyPaymentMethodDecoder.swift b/Adyen/Core/Payment Methods/Abstract/AnyPaymentMethodDecoder.swift index a9dbd29428..d030477092 100644 --- a/Adyen/Core/Payment Methods/Abstract/AnyPaymentMethodDecoder.swift +++ b/Adyen/Core/Payment Methods/Abstract/AnyPaymentMethodDecoder.swift @@ -42,7 +42,8 @@ internal enum AnyPaymentMethodDecoder { .afterpay: UnsupportedPaymentMethodDecoder(), .androidPay: UnsupportedPaymentMethodDecoder(), .amazonPay: UnsupportedPaymentMethodDecoder(), - + .bizum: UnsupportedPaymentMethodDecoder(), + // Supported payment methods .card: CardPaymentMethodDecoder(), .scheme: CardPaymentMethodDecoder(), diff --git a/Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift b/Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift index 5dcd7111ba..e05a52da0e 100644 --- a/Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift +++ b/Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift @@ -59,6 +59,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable { case mealVoucherSodexo case upi case cashAppPay + case bizum case other(String) // swiftlint:disable cyclomatic_complexity function_body_length @@ -117,6 +118,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable { case "mealVoucher_FR_sodexo": self = .mealVoucherSodexo case "upi": self = .upi case "cashapp": self = .cashAppPay + case "bizum": self = .bizum default: self = .other(rawValue) } } @@ -174,6 +176,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable { case .mealVoucherSodexo: return "mealVoucher_FR_sodexo" case .upi: return "upi" case .cashAppPay: return "cashapp" + case .bizum: return "bizum" case let .other(value): return value } } @@ -235,6 +238,7 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable { case .mealVoucherSodexo: return "meal voucher sodexo" case .upi: return "UPI" case .cashAppPay: return "cash app" + case .bizum: return "bizum" case let .other(name): return name.replacingOccurrences(of: "_", with: " ") } } From b926b4b72dc39fdf2ec1cb56db0754656fcb6f8d Mon Sep 17 00:00:00 2001 From: Vladimir Abramichev <2648655+descorp@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:03:50 +0100 Subject: [PATCH 2/6] chore: cleanup Update PaymentMethodType.swift --- Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift b/Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift index 5dcd7111ba..7fdd2fe07f 100644 --- a/Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift +++ b/Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift @@ -238,8 +238,6 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable { case let .other(name): return name.replacingOccurrences(of: "_", with: " ") } } - // swiftlint:enable cyclomatic_complexity - // swiftlint:enable cyclomatic_complexity function_body_length } From 312d5c057c5e960aecab628499ca3ad4e66426de Mon Sep 17 00:00:00 2001 From: Alex Guretzki Date: Tue, 7 Nov 2023 14:21:26 +0100 Subject: [PATCH 3/6] reusing encoded header to prevent signature mismatch --- .../JSONWebEncryption.swift | 19 ++++++++----------- .../JSONWebEncryptionGenerator.swift | 12 ++++++------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/AdyenEncryption/JOSE/Encryption Algorithms/JSON Web Encryption/JSONWebEncryption.swift b/AdyenEncryption/JOSE/Encryption Algorithms/JSON Web Encryption/JSONWebEncryption.swift index af829907b7..5e581a0aa5 100644 --- a/AdyenEncryption/JOSE/Encryption Algorithms/JSON Web Encryption/JSONWebEncryption.swift +++ b/AdyenEncryption/JOSE/Encryption Algorithms/JSON Web Encryption/JSONWebEncryption.swift @@ -1,5 +1,5 @@ // -// Copyright (c) 2021 Adyen N.V. +// Copyright (c) 2023 Adyen N.V. // // This file is open source and available under the MIT license. See the LICENSE file for more info. // @@ -48,8 +48,6 @@ internal struct JSONWebEncryption { } } - internal let header: Header - internal let encryptedKey: Data internal let encryptedPayload: Data @@ -60,21 +58,20 @@ internal struct JSONWebEncryption { internal let compactRepresentation: String - internal init(header: Header, + internal init(encodedHeader: Data, encryptedKey: Data, encryptedPayload: Data, initializationVector: Data, - authenticationTag: Data) throws { - self.header = header + authenticationTag: Data) { self.encryptedKey = encryptedKey self.encryptedPayload = encryptedPayload self.initializationVector = initializationVector self.authenticationTag = authenticationTag - self.compactRepresentation = try [AdyenCoder.encode(header).base64URLString(), - encryptedKey.base64URLString(), - initializationVector.base64URLString(), - encryptedPayload.base64URLString(), - authenticationTag.base64URLString()].joined(separator: ".") + self.compactRepresentation = [encodedHeader.base64URLString(), + encryptedKey.base64URLString(), + initializationVector.base64URLString(), + encryptedPayload.base64URLString(), + authenticationTag.base64URLString()].joined(separator: ".") } } diff --git a/AdyenEncryption/JOSE/Encryption Algorithms/JSON Web Encryption/JSONWebEncryptionGenerator.swift b/AdyenEncryption/JOSE/Encryption Algorithms/JSON Web Encryption/JSONWebEncryptionGenerator.swift index c0fc9613f7..11c4a204f7 100644 --- a/AdyenEncryption/JOSE/Encryption Algorithms/JSON Web Encryption/JSONWebEncryptionGenerator.swift +++ b/AdyenEncryption/JOSE/Encryption Algorithms/JSON Web Encryption/JSONWebEncryptionGenerator.swift @@ -1,5 +1,5 @@ // -// Copyright (c) 2021 Adyen N.V. +// Copyright (c) 2023 Adyen N.V. // // This file is open source and available under the MIT license. See the LICENSE file for more info. // @@ -36,10 +36,10 @@ internal struct JSONWebEncryptionGenerator: AnyJSONWebEncryptionGenerator { additionalAuthenticationData: additionalAuthenticationData) let contentEncryptionOutput = try contentEncryptionAlgorithm.encrypt(input: contentEncryptionInput) - return try JSONWebEncryption(header: header, - encryptedKey: encryptedKey, - encryptedPayload: contentEncryptionOutput.encryptedPayload, - initializationVector: initializationVector, - authenticationTag: contentEncryptionOutput.authenticationTag) + return JSONWebEncryption(encodedHeader: encodedHeader, + encryptedKey: encryptedKey, + encryptedPayload: contentEncryptionOutput.encryptedPayload, + initializationVector: initializationVector, + authenticationTag: contentEncryptionOutput.authenticationTag) } } From 34b70d6cd219d2d231e1ec8adba58ce4a8465bb2 Mon Sep 17 00:00:00 2001 From: Alex Guretzki Date: Wed, 8 Nov 2023 16:57:02 +0100 Subject: [PATCH 4/6] Fixing a bug that did not allow overriding localizations from main bundle --- Adyen/Utilities/Localization.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Adyen/Utilities/Localization.swift b/Adyen/Utilities/Localization.swift index 80455b0088..3e57bdd917 100644 --- a/Adyen/Utilities/Localization.swift +++ b/Adyen/Utilities/Localization.swift @@ -34,10 +34,8 @@ public func localizedString(_ key: LocalizationKey, _ parameters: LocalizationPa switch parameters?.mode { case let .enforced(locale: enforcedLocale): translationAttempt = enforceLocalizedString(key: key.key, locale: enforcedLocale) - case .natural: + case .natural, .none: translationAttempt = attempt(buildPossibleInputs(key.key, parameters)) - case .none: - break } // Use fallback in case attempt result is nil or empty From 1dce22795c9a98154b7e435bf77e3e6132587a1c Mon Sep 17 00:00:00 2001 From: vladimir Date: Thu, 9 Nov 2023 10:42:25 +0100 Subject: [PATCH 5/6] chore: add bizum tests --- Tests/Adyen Tests/Core/PaymentMethodTests.swift | 3 ++- Tests/DummyData/DummyPaymentMethods.swift | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Tests/Adyen Tests/Core/PaymentMethodTests.swift b/Tests/Adyen Tests/Core/PaymentMethodTests.swift index 4f6171cb70..1da6ce7b24 100644 --- a/Tests/Adyen Tests/Core/PaymentMethodTests.swift +++ b/Tests/Adyen Tests/Core/PaymentMethodTests.swift @@ -74,7 +74,8 @@ class PaymentMethodTests: XCTestCase { bacsDirectDebit, giftCard1, givexGiftCard, - mealVoucherSodexo + mealVoucherSodexo, + bizum ] ] return try AdyenCoder.decode(dictionary) as PaymentMethods diff --git a/Tests/DummyData/DummyPaymentMethods.swift b/Tests/DummyData/DummyPaymentMethods.swift index dba3870da2..5c4c9b7ed4 100644 --- a/Tests/DummyData/DummyPaymentMethods.swift +++ b/Tests/DummyData/DummyPaymentMethods.swift @@ -549,3 +549,8 @@ let cashAppPay: [String: Any] = [ "clientId": "testClient" ] ] + +let bizum: [String: Any] = [ + "type": "bizum", + "name": "Bizum", +] From afd8da85ec8f1fe6b734ffbbb71b7e8f98efb43b Mon Sep 17 00:00:00 2001 From: Vladimir Abramichev <2648655+descorp@users.noreply.github.com> Date: Thu, 9 Nov 2023 11:19:10 +0100 Subject: [PATCH 6/6] chore: exclude bizum from spellcheck --- spell-check-word-allow-list.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/spell-check-word-allow-list.yaml b/spell-check-word-allow-list.yaml index b7ea3fc4e7..8d0c01d7b5 100644 --- a/spell-check-word-allow-list.yaml +++ b/spell-check-word-allow-list.yaml @@ -188,3 +188,4 @@ whiteList: - domainname - appname - mapkit + - bizum