diff --git a/Sources/ProcessOut/Sources/Api/Models/ProcessOutConfiguration.swift b/Sources/ProcessOut/Sources/Api/Models/ProcessOutConfiguration.swift index a4b4bc665..56b771805 100644 --- a/Sources/ProcessOut/Sources/Api/Models/ProcessOutConfiguration.swift +++ b/Sources/ProcessOut/Sources/Api/Models/ProcessOutConfiguration.swift @@ -7,9 +7,6 @@ import Foundation -@available(*, deprecated, renamed: "ProcessOutConfiguration") -public typealias ProcessOutApiConfiguration = ProcessOutConfiguration - /// Defines configuration parameters that are used to create API singleton. In order to create instance /// of this structure one should use ``ProcessOutConfiguration/production(projectId:appVersion:isDebug:)`` /// method. @@ -35,13 +32,6 @@ public struct ProcessOutConfiguration: Sendable { /// Application name. public let application: Application? - /// Host application version. Providing this value helps ProcessOut to troubleshoot potential - /// issues. - @available(*, deprecated, renamed: "application.version") - public var appVersion: String? { - application?.version - } - /// Session ID is a constant value @_spi(PO) public let sessionId = UUID().uuidString @@ -60,38 +50,33 @@ public struct ProcessOutConfiguration: Sendable { @_spi(PO) public let privateKey: String? - /// Api base URL. - let apiBaseUrl = URL(string: "https://api.processout.com")! // swiftlint:disable:this force_unwrapping - - /// Checkout base URL. - let checkoutBaseUrl = URL(string: "https://checkout.processout.com")! // swiftlint:disable:this force_unwrapping -} - -extension ProcessOutConfiguration { - - /// Creates production configuration. - /// - /// - Parameters: - /// - appVersion: when application parameter is set, it takes precedence over this parameter. - public static func production( + /// Creates configuration. + public init( projectId: String, application: Application? = nil, - appVersion: String? = nil, isDebug: Bool = false, isTelemetryEnabled: Bool = true - ) -> Self { - .init( - projectId: projectId, - application: application ?? .init(name: nil, version: appVersion), - isDebug: isDebug, - isTelemetryEnabled: isTelemetryEnabled, - privateKey: nil - ) + ) { + self.projectId = projectId + self.application = application + self.isDebug = isDebug + self.isTelemetryEnabled = isTelemetryEnabled + self.privateKey = nil } - /// Creates debug production configuration with optional private key. + /// Creates debug configuration. @_spi(PO) - public static func production(projectId: String, privateKey: String? = nil) -> Self { - .init(projectId: projectId, application: nil, isDebug: true, isTelemetryEnabled: false, privateKey: privateKey) + public init(projectId: String, privateKey: String) { + self.projectId = projectId + self.application = nil + self.isDebug = true + self.isTelemetryEnabled = false + self.privateKey = privateKey } + + /// Api base URL. + let apiBaseUrl = URL(string: "https://api.processout.com")! // swiftlint:disable:this force_unwrapping + + /// Checkout base URL. + let checkoutBaseUrl = URL(string: "https://checkout.processout.com")! // swiftlint:disable:this force_unwrapping } diff --git a/Sources/ProcessOut/Sources/Api/ProcessOut.swift b/Sources/ProcessOut/Sources/Api/ProcessOut.swift index 54c782b68..d40821695 100644 --- a/Sources/ProcessOut/Sources/Api/ProcessOut.swift +++ b/Sources/ProcessOut/Sources/Api/ProcessOut.swift @@ -10,9 +10,6 @@ import Foundation import UIKit -@available(*, deprecated, renamed: "ProcessOut") -public typealias ProcessOutApi = ProcessOut - /// Provides access to shared api instance and a way to configure it. /// - NOTE: Instance methods and properties of this class could be access from any thread. public final class ProcessOut: @unchecked Sendable { diff --git a/Sources/ProcessOut/Sources/Core/Cancellable/POCancellable.swift b/Sources/ProcessOut/Sources/Core/Cancellable/POCancellable.swift index a6bb0ceef..6825f0fa2 100644 --- a/Sources/ProcessOut/Sources/Core/Cancellable/POCancellable.swift +++ b/Sources/ProcessOut/Sources/Core/Cancellable/POCancellable.swift @@ -5,9 +5,6 @@ // Created by Andrii Vysotskyi on 21.12.2022. // -@available(*, deprecated, renamed: "POCancellable") -public typealias POCancellableType = POCancellable - /// A protocol indicating that an activity or action supports cancellation. public protocol POCancellable: Sendable { diff --git a/Sources/ProcessOut/Sources/Core/CodingUtils/POFallbackDecodable/POFallbackDecodable.swift b/Sources/ProcessOut/Sources/Core/CodingUtils/POFallbackDecodable/POFallbackDecodable.swift deleted file mode 100644 index cb0a5c66d..000000000 --- a/Sources/ProcessOut/Sources/Core/CodingUtils/POFallbackDecodable/POFallbackDecodable.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// POFallbackDecodable.swift -// ProcessOut -// -// Created by Andrii Vysotskyi on 24.11.2023. -// - -import Foundation - -/// Allows decoding to fallback to default when value is not present. -@propertyWrapper -public struct POFallbackDecodable: Decodable where Provider.Value: Decodable { - - public var wrappedValue: Provider.Value - - public init(wrappedValue: Provider.Value) { - self.wrappedValue = wrappedValue - } -} - -extension KeyedDecodingContainer { - - public func decode

( - _ type: POFallbackDecodable

.Type, forKey key: KeyedDecodingContainer.Key - ) throws -> POFallbackDecodable

{ - POFallbackDecodable(wrappedValue: try decodeIfPresent(P.Value.self, forKey: key) ?? P.defaultValue) - } -} - -extension POFallbackDecodable: Hashable, Equatable where Provider.Value: Hashable { } diff --git a/Sources/ProcessOut/Sources/Core/CodingUtils/POFallbackDecodable/POFallbackValueProvider.swift b/Sources/ProcessOut/Sources/Core/CodingUtils/POFallbackDecodable/POFallbackValueProvider.swift deleted file mode 100644 index b83a87c2c..000000000 --- a/Sources/ProcessOut/Sources/Core/CodingUtils/POFallbackDecodable/POFallbackValueProvider.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// POFallbackValueProvider.swift -// ProcessOut -// -// Created by Andrii Vysotskyi on 24.11.2023. -// - -import Foundation - -/// Contract for providing a default value of a Type. -public protocol POFallbackValueProvider: Sendable { - - associatedtype Value - - /// Default value. - static var defaultValue: Value { get } -} - -/// Provides empty string as a fallback. -public struct POEmptyStringProvider: POFallbackValueProvider { - - public static let defaultValue = "" -} diff --git a/Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableExcludedCodable.swift b/Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableExcludedCodable.swift deleted file mode 100644 index 755370a1f..000000000 --- a/Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableExcludedCodable.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// POImmutableExcludedCodable.swift -// ProcessOut -// -// Created by Andrii Vysotskyi on 25.10.2022. -// - -import Foundation - -/// Property wrapper that allows to exclude property from being encoded without forcing owning parent to define -/// custom `CodingKeys`. -/// -/// - NOTE: Wrapped value is immutable. -@propertyWrapper -public struct POImmutableExcludedCodable: Encodable { - - public let wrappedValue: Value - - /// Creates property wrapper instance. - public init(value: Value) { - self.wrappedValue = value - } - - public func encode(to encoder: Encoder) throws { } -} - -extension KeyedEncodingContainer { - - public mutating func encode( - _ value: POImmutableExcludedCodable, forKey key: KeyedEncodingContainer.Key - ) throws { /* Ignored */ } -} - -extension POImmutableExcludedCodable: Sendable where Value: Sendable { } diff --git a/Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableStringCodableDecimal.swift b/Sources/ProcessOut/Sources/Core/CodingUtils/POStringCodableDecimal.swift similarity index 80% rename from Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableStringCodableDecimal.swift rename to Sources/ProcessOut/Sources/Core/CodingUtils/POStringCodableDecimal.swift index 5b6b1abf5..ded89c1cc 100644 --- a/Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableStringCodableDecimal.swift +++ b/Sources/ProcessOut/Sources/Core/CodingUtils/POStringCodableDecimal.swift @@ -1,5 +1,5 @@ // -// POImmutableStringCodableDecimal.swift +// POStringCodableDecimal.swift // ProcessOut // // Created by Andrii Vysotskyi on 30.11.2022. @@ -12,9 +12,9 @@ import Foundation /// Property wrapper that allows to encode and decode `Decimal` to/from string representation. Value is coded /// in en_US locale. @propertyWrapper -public struct POImmutableStringCodableDecimal: Codable, Sendable { +public struct POStringCodableDecimal: Codable, Sendable { - public let wrappedValue: Decimal + public var wrappedValue: Decimal public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() @@ -50,7 +50,7 @@ public struct POImmutableStringCodableDecimal: Codable, Sendable { extension KeyedEncodingContainer { public mutating func encode( - _ value: POImmutableStringCodableDecimal, forKey key: KeyedEncodingContainer.Key + _ value: POStringCodableDecimal, forKey key: KeyedEncodingContainer.Key ) throws { try value.encode(to: superEncoder(forKey: key)) } @@ -59,8 +59,8 @@ extension KeyedEncodingContainer { extension KeyedDecodingContainer { public func decode( - _ type: POImmutableStringCodableDecimal.Type, forKey key: KeyedDecodingContainer.Key - ) throws -> POImmutableStringCodableDecimal { + _ type: POStringCodableDecimal.Type, forKey key: KeyedDecodingContainer.Key + ) throws -> POStringCodableDecimal { try type.init(from: try superDecoder(forKey: key)) } } diff --git a/Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableStringCodableOptionalDecimal.swift b/Sources/ProcessOut/Sources/Core/CodingUtils/POStringCodableOptionalDecimal.swift similarity index 79% rename from Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableStringCodableOptionalDecimal.swift rename to Sources/ProcessOut/Sources/Core/CodingUtils/POStringCodableOptionalDecimal.swift index a5b710029..fcd840376 100644 --- a/Sources/ProcessOut/Sources/Core/CodingUtils/POImmutableStringCodableOptionalDecimal.swift +++ b/Sources/ProcessOut/Sources/Core/CodingUtils/POStringCodableOptionalDecimal.swift @@ -1,5 +1,5 @@ // -// POImmutableStringCodableOptionalDecimal.swift +// POStringCodableOptionalDecimal.swift // ProcessOut // // Created by Andrii Vysotskyi on 18.10.2022. @@ -12,9 +12,9 @@ import Foundation /// Property wrapper that allows to encode and decode optional `Decimal` to/from string representation. Value is coded /// in en_US locale. @propertyWrapper -public struct POImmutableStringCodableOptionalDecimal: Codable, Sendable { +public struct POStringCodableOptionalDecimal: Codable, Sendable { - public let wrappedValue: Decimal? + public var wrappedValue: Decimal? public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() @@ -54,7 +54,7 @@ public struct POImmutableStringCodableOptionalDecimal: Codable, Sendable { extension KeyedEncodingContainer { public mutating func encode( - _ value: POImmutableStringCodableOptionalDecimal, forKey key: KeyedEncodingContainer.Key + _ value: POStringCodableOptionalDecimal, forKey key: KeyedEncodingContainer.Key ) throws { try value.encode(to: superEncoder(forKey: key)) } @@ -63,8 +63,8 @@ extension KeyedEncodingContainer { extension KeyedDecodingContainer { public func decode( - _ type: POImmutableStringCodableOptionalDecimal.Type, forKey key: KeyedDecodingContainer.Key - ) throws -> POImmutableStringCodableOptionalDecimal { + _ type: POStringCodableOptionalDecimal.Type, forKey key: KeyedDecodingContainer.Key + ) throws -> POStringCodableOptionalDecimal { try type.init(from: try superDecoder(forKey: key)) } } diff --git a/Sources/ProcessOut/Sources/Core/DeviceMetadata/DefaultDeviceMetadataProvider.swift b/Sources/ProcessOut/Sources/Core/DeviceMetadata/DefaultDeviceMetadataProvider.swift index a7232cf28..f42464c3f 100644 --- a/Sources/ProcessOut/Sources/Core/DeviceMetadata/DefaultDeviceMetadataProvider.swift +++ b/Sources/ProcessOut/Sources/Core/DeviceMetadata/DefaultDeviceMetadataProvider.swift @@ -21,10 +21,10 @@ actor DefaultDeviceMetadataProvider: DeviceMetadataProvider { @MainActor var deviceMetadata: DeviceMetadata { get async { let metadata = DeviceMetadata( - id: .init(value: await deviceId), - installationId: .init(value: device.identifierForVendor?.uuidString), - systemVersion: .init(value: device.systemVersion), - model: .init(value: await machineName), + id: await deviceId, + installationId: device.identifierForVendor?.uuidString, + systemVersion: device.systemVersion, + model: await machineName, appLanguage: bundle.preferredLocalizations.first!, // swiftlint:disable:this force_unwrapping appScreenWidth: Int(screen.nativeBounds.width), // Specified in pixels appScreenHeight: Int(screen.nativeBounds.height), diff --git a/Sources/ProcessOut/Sources/Core/DeviceMetadata/DeviceMetadata.swift b/Sources/ProcessOut/Sources/Core/DeviceMetadata/DeviceMetadata.swift index 58fe897d0..a8baed17a 100644 --- a/Sources/ProcessOut/Sources/Core/DeviceMetadata/DeviceMetadata.swift +++ b/Sources/ProcessOut/Sources/Core/DeviceMetadata/DeviceMetadata.swift @@ -7,23 +7,19 @@ import Foundation -struct DeviceMetadata: Encodable, Sendable { +struct DeviceMetadata: Encodable, Sendable { // sourcery: AutoCodingKeys /// Current device identifier. - @POImmutableExcludedCodable - var id: String? + let id: String? // sourcery:coding: skip /// Installation identifier. Value changes if host application is reinstalled. - @POImmutableExcludedCodable - var installationId: String? + let installationId: String? // sourcery:coding: skip /// Device system version. - @POImmutableExcludedCodable - var systemVersion: String + let systemVersion: String // sourcery:coding: skip /// Device model. - @POImmutableExcludedCodable - var model: String? + let model: String? // sourcery:coding: skip /// Default app language. let appLanguage: String diff --git a/Sources/ProcessOut/Sources/Core/Utils/POTypedRepresentation.swift b/Sources/ProcessOut/Sources/Core/Utils/POTypedRepresentation.swift deleted file mode 100644 index 47d57d842..000000000 --- a/Sources/ProcessOut/Sources/Core/Utils/POTypedRepresentation.swift +++ /dev/null @@ -1,106 +0,0 @@ -// -// POTypedRepresentation.swift -// ProcessOut -// -// Created by Andrii Vysotskyi on 11.06.2024. -// - -// todo(andrii-vysotskyi): remove when updating to 5.0.0 - -import Foundation - -/// Introduces typed version of a property in a backward compatible way. -@propertyWrapper -public struct POTypedRepresentation { - - public init(wrappedValue: Wrapped) { - self._wrappedValue = wrappedValue - } - - @available(*, deprecated, message: "Use typed representation accessible via projectedValue.typed instead.") - public var wrappedValue: Wrapped { - get { _wrappedValue } - set { _wrappedValue = newValue } - } - - public var projectedValue: Self { - self - } - - // MARK: - Private Properties - - private var _wrappedValue: Wrapped -} - -extension POTypedRepresentation where Representation.RawValue == Wrapped { - - /// Returns typed representation of self. - public var typed: Representation { - Representation(rawValue: _wrappedValue)! // swiftlint:disable:this force_unwrapping - } -} - -extension POTypedRepresentation where Representation.RawValue? == Wrapped { - - /// Returns typed representation of self. - public var typed: Representation? { - _wrappedValue.flatMap { Representation(rawValue: $0) } - } -} - -extension POTypedRepresentation { - - /// Returns typed representation of self. - public func typed(wrappedType: T.Type = T.self) -> Representation? where Wrapped == T?, T: RawRepresentable, T.RawValue == Representation.RawValue { // swiftlint:disable:this line_length - _wrappedValue.flatMap { Representation(rawValue: $0.rawValue) } - } -} - -extension POTypedRepresentation: Hashable where Wrapped: Hashable { - - public func hash(into hasher: inout Hasher) { - _wrappedValue.hash(into: &hasher) - } -} - -extension POTypedRepresentation: Equatable where Wrapped: Equatable { - - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs._wrappedValue == rhs._wrappedValue - } -} - -extension POTypedRepresentation: Encodable where Wrapped: Encodable { - - public func encode(to encoder: any Encoder) throws { - try _wrappedValue.encode(to: encoder) - } -} - -extension POTypedRepresentation: Decodable where Wrapped: Decodable { - - public init(from decoder: any Decoder) throws { - let wrappedValue = try Wrapped(from: decoder) - self = .init(wrappedValue: wrappedValue) - } -} - -extension KeyedEncodingContainer { - - public mutating func encode( - _ value: POTypedRepresentation, forKey key: KeyedEncodingContainer.Key - ) throws { - try value.encode(to: superEncoder(forKey: key)) - } -} - -extension KeyedDecodingContainer { - - public func decode( - _ type: POTypedRepresentation.Type, forKey key: KeyedDecodingContainer.Key - ) throws -> POTypedRepresentation { - try type.init(from: try superDecoder(forKey: key)) - } -} - -extension POTypedRepresentation: Sendable where Wrapped: Sendable { } diff --git a/Sources/ProcessOut/Sources/Core/Utils/UnfairlyLocked/POUnfairlyLocked.swift b/Sources/ProcessOut/Sources/Core/Utils/UnfairlyLocked/POUnfairlyLocked.swift index 266ed092e..43429859e 100644 --- a/Sources/ProcessOut/Sources/Core/Utils/UnfairlyLocked/POUnfairlyLocked.swift +++ b/Sources/ProcessOut/Sources/Core/Utils/UnfairlyLocked/POUnfairlyLocked.swift @@ -9,7 +9,6 @@ import os /// A thread-safe wrapper around a value. @_spi(PO) -@propertyWrapper public final class POUnfairlyLocked: @unchecked Sendable { public init(wrappedValue: Value) { diff --git a/Sources/ProcessOut/Sources/Generated/Sourcery+Generated.swift b/Sources/ProcessOut/Sources/Generated/Sourcery+Generated.swift index 293024b92..f74d9e2de 100644 --- a/Sources/ProcessOut/Sources/Generated/Sourcery+Generated.swift +++ b/Sources/ProcessOut/Sources/Generated/Sourcery+Generated.swift @@ -6,6 +6,24 @@ import UIKit // MARK: - AutoCodingKeys +extension DeviceMetadata { + + enum CodingKeys: String, CodingKey { + case appLanguage + case appScreenWidth + case appScreenHeight + case appTimeZoneOffset + case channel + } +} + +extension NativeAlternativePaymentCaptureRequest { + + enum CodingKeys: String, CodingKey { + case source + } +} + extension POAssignCustomerTokenRequest { enum CodingKeys: String, CodingKey { @@ -13,9 +31,25 @@ extension POAssignCustomerTokenRequest { case preferredScheme case verify case invoiceId - case enableThreeDS2 = "enable_three_d_s_2" case thirdPartySdkVersion case metadata + case enableThreeDS2 = "enable_three_d_s_2" + } +} + +extension POCardUpdateRequest { + + enum CodingKeys: String, CodingKey { + case cvc + case preferredScheme + } +} + +extension POCreateCustomerTokenRequest { + + enum CodingKeys: String, CodingKey { + case verify + case invoiceReturnUrl } } @@ -57,7 +91,6 @@ extension POInvoiceAuthorizationRequest { enum CodingKeys: String, CodingKey { case source case incremental - case enableThreeDS2 = "enable_three_d_s_2" case preferredScheme case thirdPartySdkVersion case invoiceDetailIds @@ -68,6 +101,7 @@ extension POInvoiceAuthorizationRequest { case authorizeOnly case allowFallbackToSale case metadata + case enableThreeDS2 = "enable_three_d_s_2" } } diff --git a/Sources/ProcessOut/Sources/Repositories/Cards/HttpCardsRepository.swift b/Sources/ProcessOut/Sources/Repositories/Cards/HttpCardsRepository.swift index a822a2ffb..694c1b4f7 100644 --- a/Sources/ProcessOut/Sources/Repositories/Cards/HttpCardsRepository.swift +++ b/Sources/ProcessOut/Sources/Repositories/Cards/HttpCardsRepository.swift @@ -16,7 +16,7 @@ final class HttpCardsRepository: CardsRepository { // MARK: - CardsRepository func issuerInformation(iin: String) async throws -> POCardIssuerInformation { - struct Response: Decodable, Sendable { + struct Response: Decodable { let cardInformation: POCardIssuerInformation } let httpRequest = HttpConnectorRequest.get(path: "/iins/" + iin) @@ -24,21 +24,30 @@ final class HttpCardsRepository: CardsRepository { } func tokenize(request: POCardTokenizationRequest) async throws -> POCard { - let httpRequest = HttpConnectorRequest.post( + struct Response: Decodable { + let card: POCard + } + let httpRequest = HttpConnectorRequest.post( path: "/cards", body: request, includesDeviceMetadata: true ) return try await connector.execute(request: httpRequest).card } func updateCard(request: POCardUpdateRequest) async throws -> POCard { - let httpRequest = HttpConnectorRequest.put( + struct Response: Decodable { + let card: POCard + } + let httpRequest = HttpConnectorRequest.put( path: "/cards/" + request.cardId, body: request, includesDeviceMetadata: true ) return try await connector.execute(request: httpRequest).card } func tokenize(request: ApplePayCardTokenizationRequest) async throws -> POCard { - let httpRequest = HttpConnectorRequest.post( + struct Response: Decodable { + let card: POCard + } + let httpRequest = HttpConnectorRequest.post( path: "/cards", body: request, includesDeviceMetadata: true ) return try await connector.execute(request: httpRequest).card diff --git a/Sources/ProcessOut/Sources/Repositories/Cards/Requests/POCardTokenizationRequest.swift b/Sources/ProcessOut/Sources/Repositories/Cards/Requests/POCardTokenizationRequest.swift index 3263a0cae..5b4b0825b 100644 --- a/Sources/ProcessOut/Sources/Repositories/Cards/Requests/POCardTokenizationRequest.swift +++ b/Sources/ProcessOut/Sources/Repositories/Cards/Requests/POCardTokenizationRequest.swift @@ -29,8 +29,7 @@ public struct POCardTokenizationRequest: Encodable, Sendable { public let contact: POContact? /// Preferred scheme defined by the Customer. - @POTypedRepresentation - public private(set) var preferredScheme: String? + public let preferredScheme: POCardScheme? /// Metadata related to the card. public let metadata: [String: String]? @@ -42,7 +41,7 @@ public struct POCardTokenizationRequest: Encodable, Sendable { cvc: String? = nil, name: String? = nil, contact: POContact? = nil, - preferredScheme: String? = nil, + preferredScheme: POCardScheme? = nil, metadata: [String: String]? = nil ) { self.number = number @@ -51,7 +50,7 @@ public struct POCardTokenizationRequest: Encodable, Sendable { self.cvc = cvc self.name = name self.contact = contact - self._preferredScheme = .init(wrappedValue: preferredScheme) + self.preferredScheme = preferredScheme self.metadata = metadata } } diff --git a/Sources/ProcessOut/Sources/Repositories/Cards/Requests/POCardUpdateRequest.swift b/Sources/ProcessOut/Sources/Repositories/Cards/Requests/POCardUpdateRequest.swift index 8c0653694..d75893cdc 100644 --- a/Sources/ProcessOut/Sources/Repositories/Cards/Requests/POCardUpdateRequest.swift +++ b/Sources/ProcessOut/Sources/Repositories/Cards/Requests/POCardUpdateRequest.swift @@ -6,11 +6,10 @@ // /// Updated card details. -public struct POCardUpdateRequest: Encodable, Sendable { +public struct POCardUpdateRequest: Encodable, Sendable { // sourcery: AutoCodingKeys /// Card id. - @POImmutableExcludedCodable - public var cardId: String + public let cardId: String // sourcery:coding: skip /// New cvc. /// Pass `nil` to keep existing value. @@ -18,13 +17,12 @@ public struct POCardUpdateRequest: Encodable, Sendable { /// Preferred scheme defined by the Customer. This gets priority when processing the Transaction. /// Pass `nil` to keep existing value. - @POTypedRepresentation - public private(set) var preferredScheme: String? + public let preferredScheme: POCardScheme? /// Creates request instance. - public init(cardId: String, cvc: String? = nil, preferredScheme: String? = nil) { - self._cardId = .init(value: cardId) + public init(cardId: String, cvc: String? = nil, preferredScheme: POCardScheme? = nil) { + self.cardId = cardId self.cvc = cvc - self._preferredScheme = .init(wrappedValue: preferredScheme) + self.preferredScheme = preferredScheme } } diff --git a/Sources/ProcessOut/Sources/Repositories/Cards/Responses/CardTokenizationResponse.swift b/Sources/ProcessOut/Sources/Repositories/Cards/Responses/CardTokenizationResponse.swift deleted file mode 100644 index d54e9f857..000000000 --- a/Sources/ProcessOut/Sources/Repositories/Cards/Responses/CardTokenizationResponse.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// CardTokenizationResponse.swift -// ProcessOut -// -// Created by Julien.Rodrigues on 20/10/2022. -// - -import Foundation - -struct CardTokenizationResponse: Decodable, Sendable { - let card: POCard -} diff --git a/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCard.swift b/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCard.swift index 322762bd1..b522c04c8 100644 --- a/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCard.swift +++ b/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCard.swift @@ -18,20 +18,16 @@ public struct POCard: Decodable, Hashable, @unchecked Sendable { public let projectId: String /// Scheme of the card. - @POTypedRepresentation - public private(set) var scheme: String + public let scheme: POCardScheme /// Co-scheme of the card, such as Carte Bancaire. - @POTypedRepresentation - public private(set) var coScheme: String? + public let coScheme: POCardScheme? /// Preferred scheme defined by the Customer. - @POTypedRepresentation - public private(set) var preferredScheme: String? + public let preferredScheme: POCardScheme? /// Card type. - @POFallbackDecodable - public private(set) var type: String + public let type: String? /// Name of the card’s issuing bank. public let bankName: String? @@ -50,8 +46,7 @@ public struct POCard: Decodable, Hashable, @unchecked Sendable { /// Hash value that remains the same for this card even if it is tokenized several times. /// - NOTE: fingerprint is empty string for Apple and Google Pay cards. - @POFallbackDecodable - public private(set) var fingerprint: String + public let fingerprint: String? /// Month of the expiration date. public let expMonth: Int @@ -60,8 +55,7 @@ public struct POCard: Decodable, Hashable, @unchecked Sendable { public let expYear: Int /// CVC check status. - @POTypedRepresentation - public var cvcCheck: String + public var cvcCheck: POCardCvcCheck /// AVS check status. public let avsCheck: String diff --git a/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCardIssuerInformation.swift b/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCardIssuerInformation.swift index 89b06d80d..65c485c0f 100644 --- a/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCardIssuerInformation.swift +++ b/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCardIssuerInformation.swift @@ -9,12 +9,10 @@ public struct POCardIssuerInformation: Decodable, Sendable { /// Scheme of the card. - @POTypedRepresentation - public private(set) var scheme: String + public let scheme: POCardScheme /// Co-scheme of the card, such as Carte Bancaire. - @POTypedRepresentation - public private(set) var coScheme: String? + public let coScheme: POCardScheme? /// Card type. public let type: String? @@ -36,8 +34,8 @@ public struct POCardIssuerInformation: Decodable, Sendable { brand: String? = nil, category: String? = nil ) { - self._scheme = .init(wrappedValue: scheme.rawValue) - self._coScheme = .init(wrappedValue: coScheme?.rawValue) + self.scheme = scheme + self.coScheme = coScheme self.type = type self.bankName = bankName self.brand = brand diff --git a/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCardScheme.swift b/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCardScheme.swift index f310bc307..87d9a79f5 100644 --- a/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCardScheme.swift +++ b/Sources/ProcessOut/Sources/Repositories/Cards/Responses/POCardScheme.swift @@ -176,10 +176,15 @@ extension POCardScheme { public static let mir: POCardScheme = "nspk mir" } -extension POCardScheme: Decodable { +extension POCardScheme: Codable { public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() rawValue = try container.decode(String.self) } + + public func encode(to encoder: any Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(self.rawValue) + } } diff --git a/Sources/ProcessOut/Sources/Repositories/CustomerTokens/Requests/POAssignCustomerTokenRequest.swift b/Sources/ProcessOut/Sources/Repositories/CustomerTokens/Requests/POAssignCustomerTokenRequest.swift index 24b924516..a53ce3f18 100644 --- a/Sources/ProcessOut/Sources/Repositories/CustomerTokens/Requests/POAssignCustomerTokenRequest.swift +++ b/Sources/ProcessOut/Sources/Repositories/CustomerTokens/Requests/POAssignCustomerTokenRequest.swift @@ -21,8 +21,7 @@ public struct POAssignCustomerTokenRequest: Encodable, Sendable { // sourcery: A public let source: String /// Card scheme or co-scheme that should get priority if it is available. - @POTypedRepresentation - public private(set) var preferredScheme: String? + public let preferredScheme: POCardScheme? /// Boolean value that indicates whether token should be verified. Make sure to also pass valid /// ``POAssignCustomerTokenRequest/invoiceId`` if you want verification to happen. Default value @@ -32,35 +31,33 @@ public struct POAssignCustomerTokenRequest: Encodable, Sendable { // sourcery: A /// Invoice identifier that will be used for token verification. public let invoiceId: String? - /// Boolean value used as flag that when set to `true` indicates that a request is coming directly - /// from the frontend. It is used to understand if we can instantly step-up to 3DS or not. - /// - /// Value is hardcoded to `true`. - @available(*, deprecated, message: "Property is an implementation detail and shouldn't be used.") - public let enableThreeDS2 = true // sourcery:coding: key="enable_three_d_s_2" - /// Can be used for a 3DS2 request to indicate which third party SDK is used for the call. public let thirdPartySdkVersion: String? /// Additional metadata. public let metadata: [String: String]? + /// Boolean value used as flag that when set to `true` indicates that a request is coming directly + /// from the frontend. It is used to understand if we can instantly step-up to 3DS or not. + /// + /// Value is hardcoded to `true`. + let enableThreeDS2 = true // sourcery:coding: key="enable_three_d_s_2" + /// Creates request instance. public init( customerId: String, tokenId: String, source: String, - preferredScheme: String? = nil, + preferredScheme: POCardScheme? = nil, verify: Bool = false, invoiceId: String? = nil, - enableThreeDS2 _: Bool = true, thirdPartySdkVersion: String? = nil, metadata: [String: String]? = nil ) { self.customerId = customerId self.tokenId = tokenId self.source = source - self._preferredScheme = .init(wrappedValue: preferredScheme) + self.preferredScheme = preferredScheme self.verify = verify self.invoiceId = invoiceId self.thirdPartySdkVersion = thirdPartySdkVersion diff --git a/Sources/ProcessOut/Sources/Repositories/CustomerTokens/Requests/POCreateCustomerTokenRequest.swift b/Sources/ProcessOut/Sources/Repositories/CustomerTokens/Requests/POCreateCustomerTokenRequest.swift index 5e3da407c..112b5e018 100644 --- a/Sources/ProcessOut/Sources/Repositories/CustomerTokens/Requests/POCreateCustomerTokenRequest.swift +++ b/Sources/ProcessOut/Sources/Repositories/CustomerTokens/Requests/POCreateCustomerTokenRequest.swift @@ -8,11 +8,10 @@ import Foundation @_spi(PO) -public struct POCreateCustomerTokenRequest: Encodable, Sendable { +public struct POCreateCustomerTokenRequest: Encodable, Sendable { // sourcery: AutoCodingKeys /// Customer id to associate created token with. - @POImmutableExcludedCodable - public var customerId: String + public let customerId: String // sourcery:coding: skip /// Flag if you wish to verify the customer token by making zero value transaction. Applicable for cards only. public let verify: Bool @@ -24,7 +23,7 @@ public struct POCreateCustomerTokenRequest: Encodable, Sendable { public let returnUrl: URL? public init(customerId: String, verify: Bool = false, returnUrl: URL? = nil) { - self._customerId = .init(value: customerId) + self.customerId = customerId self.verify = verify self.invoiceReturnUrl = returnUrl self.returnUrl = returnUrl diff --git a/Sources/ProcessOut/Sources/Repositories/GatewayConfigurations/POGatewayConfigurationsRepository.swift b/Sources/ProcessOut/Sources/Repositories/GatewayConfigurations/POGatewayConfigurationsRepository.swift index 5611c8ca7..1e42879d9 100644 --- a/Sources/ProcessOut/Sources/Repositories/GatewayConfigurations/POGatewayConfigurationsRepository.swift +++ b/Sources/ProcessOut/Sources/Repositories/GatewayConfigurations/POGatewayConfigurationsRepository.swift @@ -7,9 +7,6 @@ import Foundation -@available(*, deprecated, renamed: "POGatewayConfigurationsRepository") -public typealias POGatewayConfigurationsRepositoryType = POGatewayConfigurationsRepository - public protocol POGatewayConfigurationsRepository: PORepository { // sourcery: AutoCompletion /// Returns available gateway configurations. diff --git a/Sources/ProcessOut/Sources/Repositories/GatewayConfigurations/Responses/POGatewayConfiguration.swift b/Sources/ProcessOut/Sources/Repositories/GatewayConfigurations/Responses/POGatewayConfiguration.swift index 3105905b3..59adac0bf 100644 --- a/Sources/ProcessOut/Sources/Repositories/GatewayConfigurations/Responses/POGatewayConfiguration.swift +++ b/Sources/ProcessOut/Sources/Repositories/GatewayConfigurations/Responses/POGatewayConfiguration.swift @@ -37,10 +37,6 @@ public struct POGatewayConfiguration: Decodable, Sendable { /// Boolean flag that indicates whether gateway supports refunds. public let canRefund: Bool - - /// Native alternative payment method configuration. - @available(*, deprecated, message: "Use POInvoicesService/nativeAlternativePaymentMethodTransactionDetails(request:) instead.") // swiftlint:disable:this line_length - public let nativeApmConfig: NativeAlternativePaymentMethodConfig? } /// String value that uniquely identifies the configuration. diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/HttpInvoicesRepository.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/HttpInvoicesRepository.swift index 56c7b224d..c531d18b8 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/HttpInvoicesRepository.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/HttpInvoicesRepository.swift @@ -30,14 +30,24 @@ final class HttpInvoicesRepository: InvoicesRepository { func initiatePayment( request: PONativeAlternativePaymentMethodRequest ) async throws -> PONativeAlternativePaymentMethodResponse { - let requestBox = NativeAlternativePaymentRequestBox( + struct Request: Encodable { + struct NativeApm: Encodable { // swiftlint:disable:this nesting + let parameterValues: [String: String] + } + let gatewayConfigurationId: String + let nativeApm: NativeApm + } + struct Response: Decodable { + let nativeApm: PONativeAlternativePaymentMethodResponse + } + let requestBox = Request( gatewayConfigurationId: request.gatewayConfigurationId, nativeApm: .init(parameterValues: request.parameters) ) - let httpRequest = HttpConnectorRequest.post( + let httpRequest = HttpConnectorRequest.post( path: "/invoices/\(request.invoiceId)/native-payment", body: requestBox ) - return try await connector.execute(request: httpRequest) + return try await connector.execute(request: httpRequest).nativeApm } func invoice(request: POInvoiceRequest) async throws -> POInvoice { @@ -66,11 +76,17 @@ final class HttpInvoicesRepository: InvoicesRepository { func captureNativeAlternativePayment( request: NativeAlternativePaymentCaptureRequest - ) async throws -> PONativeAlternativePaymentMethodResponse { - let httpRequest = HttpConnectorRequest.post( + ) async throws -> PONativeAlternativePaymentMethodState { + struct Response: Decodable { + struct NativeApm: Decodable { // swiftlint:disable:this nesting + let state: PONativeAlternativePaymentMethodState + } + let nativeApm: NativeApm + } + let httpRequest = HttpConnectorRequest.post( path: "/invoices/\(request.invoiceId)/capture", body: request ) - return try await connector.execute(request: httpRequest) + return try await connector.execute(request: httpRequest).nativeApm.state } func createInvoice(request: POInvoiceCreationRequest) async throws -> POInvoice { @@ -85,16 +101,6 @@ final class HttpInvoicesRepository: InvoicesRepository { return response.value.invoice.replacing(clientSecret: clientSecret) } - // MARK: - Private Nested Types - - private struct NativeAlternativePaymentRequestBox: Encodable { - struct NativeApm: Encodable { // swiftlint:disable:this nesting - let parameterValues: [String: String] - } - let gatewayConfigurationId: String - let nativeApm: NativeApm - } - // MARK: - Private Properties private let connector: HttpConnector diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/InvoicesRepository.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/InvoicesRepository.swift index 00950168a..281c4ae5a 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/InvoicesRepository.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/InvoicesRepository.swift @@ -29,7 +29,7 @@ protocol InvoicesRepository: PORepository { /// Captures native alternative payment. func captureNativeAlternativePayment( request: NativeAlternativePaymentCaptureRequest - ) async throws -> PONativeAlternativePaymentMethodResponse + ) async throws -> PONativeAlternativePaymentMethodState /// Creates invoice with given parameters. func createInvoice(request: POInvoiceCreationRequest) async throws -> POInvoice diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/Requests/AlternativePayment/NativeAlternativePaymentCaptureRequest.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/Requests/AlternativePayment/NativeAlternativePaymentCaptureRequest.swift index 6f487da18..473097984 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/Requests/AlternativePayment/NativeAlternativePaymentCaptureRequest.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/Requests/AlternativePayment/NativeAlternativePaymentCaptureRequest.swift @@ -5,17 +5,11 @@ // Created by Andrii Vysotskyi on 16.12.2022. // -struct NativeAlternativePaymentCaptureRequest: Encodable, Sendable { +struct NativeAlternativePaymentCaptureRequest: Encodable, Sendable { // sourcery: AutoCodingKeys /// Invoice identifier. - @POImmutableExcludedCodable - var invoiceId: String + let invoiceId: String // sourcery:coding: skip /// Source must be set to gateway configuration id that was used to initiate native alternative payment. let source: String - - init(invoiceId: String, source: String) { - self._invoiceId = .init(value: invoiceId) - self.source = source - } } diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/Requests/POInvoiceAuthorizationRequest.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/Requests/POInvoiceAuthorizationRequest.swift index 6f452ac4b..8241acb26 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/Requests/POInvoiceAuthorizationRequest.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/Requests/POInvoiceAuthorizationRequest.swift @@ -18,16 +18,8 @@ public struct POInvoiceAuthorizationRequest: Encodable, Sendable { // sourcery: /// Boolean value indicating if authorization is incremental. Default value is `false`. public let incremental: Bool - /// Boolean value used as flag that when set to `true` indicates that a request is coming directly - /// from the frontend. It is used to understand if we can instantly step-up to 3DS or not. - /// - /// Value is hardcoded to `true`. - @available(*, deprecated, message: "Property is an implementation detail and shouldn't be used.") - public let enableThreeDS2 = true // sourcery:coding: key="enable_three_d_s_2" - /// Card scheme or co-scheme that should get priority if it is available. - @POTypedRepresentation - public private(set) var preferredScheme: String? + public let preferredScheme: POCardScheme? /// Can be used for a 3DS2 request to indicate which third party SDK is used for the call. public let thirdPartySdkVersion: String? @@ -48,8 +40,8 @@ public struct POInvoiceAuthorizationRequest: Encodable, Sendable { // sourcery: /// Amount of money to capture when partial captures are available. Note that this only applies if you are /// also using the `autoCaptureAt` option. - @POImmutableStringCodableOptionalDecimal - public var captureAmount: Decimal? + @POStringCodableOptionalDecimal + public private(set) var captureAmount: Decimal? /// Set to true if you want to authorize payment without capturing. Note that you must capture the payment on /// the server if you use this option. Default value is `true`. @@ -63,12 +55,17 @@ public struct POInvoiceAuthorizationRequest: Encodable, Sendable { // sourcery: /// Operation metadata. public let metadata: [String: String]? + /// Boolean value used as flag that when set to `true` indicates that a request is coming directly + /// from the frontend. It is used to understand if we can instantly step-up to 3DS or not. + /// + /// Value is hardcoded to `true`. + let enableThreeDS2 = true // sourcery:coding: key="enable_three_d_s_2" + public init( invoiceId: String, source: String, incremental: Bool = false, - enableThreeDS2 _: Bool = true, - preferredScheme: String? = nil, + preferredScheme: POCardScheme? = nil, thirdPartySdkVersion: String? = nil, invoiceDetailIds: [String]? = nil, overrideMacBlocking: Bool = false, @@ -82,7 +79,7 @@ public struct POInvoiceAuthorizationRequest: Encodable, Sendable { // sourcery: self.invoiceId = invoiceId self.source = source self.incremental = incremental - self._preferredScheme = .init(wrappedValue: preferredScheme) + self.preferredScheme = preferredScheme self.thirdPartySdkVersion = thirdPartySdkVersion self.invoiceDetailIds = invoiceDetailIds self.overrideMacBlocking = overrideMacBlocking diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/AlternativePayment/PONativeAlternativePaymentMethodResponse.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/AlternativePayment/PONativeAlternativePaymentMethodResponse.swift index aa12839cc..142ffd3d5 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/AlternativePayment/PONativeAlternativePaymentMethodResponse.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/AlternativePayment/PONativeAlternativePaymentMethodResponse.swift @@ -9,22 +9,13 @@ import Foundation public struct PONativeAlternativePaymentMethodResponse: Decodable, Sendable { - @available(*, deprecated, message: "Use PONativeAlternativePaymentMethodParameterValues directly.") - public typealias NativeAlternativePaymentMethodParameterValues = PONativeAlternativePaymentMethodParameterValues + /// Payment's state. + public let state: PONativeAlternativePaymentMethodState - public struct NativeApm: Decodable, Sendable { + /// Contains details about the additional information you need to collect from your customer before creating the + /// payment request. + public let parameterDefinitions: [PONativeAlternativePaymentMethodParameter]? - /// Payment's state. - public let state: PONativeAlternativePaymentMethodState - - /// Contains details about the additional information you need to collect from your customer before creating the - /// payment request. - public let parameterDefinitions: [PONativeAlternativePaymentMethodParameter]? - - /// Additional information about payment step. - public let parameterValues: PONativeAlternativePaymentMethodParameterValues? - } - - /// Details for alternative payment method. - public let nativeApm: NativeApm + /// Additional information about payment step. + public let parameterValues: PONativeAlternativePaymentMethodParameterValues? } diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/AlternativePayment/PONativeAlternativePaymentMethodTransactionDetails.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/AlternativePayment/PONativeAlternativePaymentMethodTransactionDetails.swift index 9c07a70ae..075402b85 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/AlternativePayment/PONativeAlternativePaymentMethodTransactionDetails.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/AlternativePayment/PONativeAlternativePaymentMethodTransactionDetails.swift @@ -30,8 +30,8 @@ public struct PONativeAlternativePaymentMethodTransactionDetails: Decodable, Sen public struct Invoice: Decodable, Sendable { /// Invoice amount. - @POImmutableStringCodableDecimal - public var amount: Decimal + @POStringCodableDecimal + public private(set) var amount: Decimal /// Invoice currency code. public let currencyCode: String diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/DynamicCheckout/PODynamicCheckoutPaymentMethod.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/DynamicCheckout/PODynamicCheckoutPaymentMethod.swift index 7e1a6706b..411266fe9 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/DynamicCheckout/PODynamicCheckoutPaymentMethod.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/DynamicCheckout/PODynamicCheckoutPaymentMethod.swift @@ -42,7 +42,7 @@ public enum PODynamicCheckoutPaymentMethod: Sendable { /// Merchant capabilities. @POStringDecodableMerchantCapability - public var merchantCapabilities: PKMerchantCapability + public private(set) var merchantCapabilities: PKMerchantCapability /// The payment methods that are supported. public let supportedNetworks: Set diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/DynamicCheckout/POStringDecodableMerchantCapability.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/DynamicCheckout/POStringDecodableMerchantCapability.swift index b7d1a9cfd..47c58a0bf 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/DynamicCheckout/POStringDecodableMerchantCapability.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/DynamicCheckout/POStringDecodableMerchantCapability.swift @@ -11,7 +11,7 @@ import PassKit @propertyWrapper public struct POStringDecodableMerchantCapability: Decodable, Sendable { - public let wrappedValue: PKMerchantCapability + public var wrappedValue: PKMerchantCapability // MARK: - Decodable diff --git a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/POInvoice.swift b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/POInvoice.swift index bd7af52d1..becca98d0 100644 --- a/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/POInvoice.swift +++ b/Sources/ProcessOut/Sources/Repositories/Invoices/Responses/POInvoice.swift @@ -13,8 +13,8 @@ public struct POInvoice: Decodable, Sendable { /// String value that uniquely identifies this invoice. public let id: String - @POImmutableStringCodableDecimal - public var amount: Decimal + @POStringCodableDecimal + public private(set) var amount: Decimal /// Invoice currency. public let currency: String diff --git a/Sources/ProcessOut/Sources/Repositories/Shared/PORepository.swift b/Sources/ProcessOut/Sources/Repositories/Shared/PORepository.swift index a1b8efa46..156f2e818 100644 --- a/Sources/ProcessOut/Sources/Repositories/Shared/PORepository.swift +++ b/Sources/ProcessOut/Sources/Repositories/Shared/PORepository.swift @@ -5,9 +5,6 @@ // Created by Andrii Vysotskyi on 12.10.2022. // -@available(*, deprecated, renamed: "PORepository") -public typealias PORepositoryType = PORepository - /// Common protocol that all repositories conform to. public protocol PORepository: Sendable { diff --git a/Sources/ProcessOut/Sources/Services/3DS/PO3DSService.swift b/Sources/ProcessOut/Sources/Services/3DS/PO3DSService.swift index 15352d77a..2ca761429 100644 --- a/Sources/ProcessOut/Sources/Services/3DS/PO3DSService.swift +++ b/Sources/ProcessOut/Sources/Services/3DS/PO3DSService.swift @@ -5,9 +5,6 @@ // Created by Andrii Vysotskyi on 03.11.2022. // -@available(*, deprecated, renamed: "PO3DSService") -public typealias PO3DSServiceType = PO3DSService - /// This interface provides methods to process 3-D Secure transactions. public protocol PO3DSService: AnyObject, Sendable { diff --git a/Sources/ProcessOut/Sources/Services/AlternativePayments/POAlternativePaymentsService.swift b/Sources/ProcessOut/Sources/Services/AlternativePayments/POAlternativePaymentsService.swift index 65dd0990f..18c78cd5b 100644 --- a/Sources/ProcessOut/Sources/Services/AlternativePayments/POAlternativePaymentsService.swift +++ b/Sources/ProcessOut/Sources/Services/AlternativePayments/POAlternativePaymentsService.swift @@ -7,9 +7,6 @@ import Foundation -@available(*, deprecated, renamed: "POAlternativePaymentsService") -public typealias POAlternativePaymentMethodsServiceType = POAlternativePaymentsService - /// Service that provides set of methods to work with alternative payments. public protocol POAlternativePaymentsService: POService { diff --git a/Sources/ProcessOut/Sources/Services/Cards/POCardsService.swift b/Sources/ProcessOut/Sources/Services/Cards/POCardsService.swift index 9140848b9..ac4f457f7 100644 --- a/Sources/ProcessOut/Sources/Services/Cards/POCardsService.swift +++ b/Sources/ProcessOut/Sources/Services/Cards/POCardsService.swift @@ -5,9 +5,6 @@ // Created by Andrii Vysotskyi on 17.03.2023. // -@available(*, deprecated, renamed: "POCardsService") -public typealias POCardsServiceType = POCardsService - /// Provides set of methods to tokenize and manipulate cards. public protocol POCardsService: POService { // sourcery: AutoCompletion diff --git a/Sources/ProcessOut/Sources/Services/CustomerTokens/POCustomerTokensService.swift b/Sources/ProcessOut/Sources/Services/CustomerTokens/POCustomerTokensService.swift index 311d24520..7373522da 100644 --- a/Sources/ProcessOut/Sources/Services/CustomerTokens/POCustomerTokensService.swift +++ b/Sources/ProcessOut/Sources/Services/CustomerTokens/POCustomerTokensService.swift @@ -5,9 +5,6 @@ // Created by Andrii Vysotskyi on 02.11.2022. // -@available(*, deprecated, renamed: "POCustomerTokensService") -public typealias POCustomerTokensServiceType = POCustomerTokensService - /// Provides an ability to interact with customer tokens. /// /// You can only use a card or APM token once but you can make payments as many times as necessary with a customer diff --git a/Sources/ProcessOut/Sources/Services/Invoices/DefaultInvoicesService.swift b/Sources/ProcessOut/Sources/Services/Invoices/DefaultInvoicesService.swift index 72ce58170..cb5db421b 100644 --- a/Sources/ProcessOut/Sources/Services/Invoices/DefaultInvoicesService.swift +++ b/Sources/ProcessOut/Sources/Services/Invoices/DefaultInvoicesService.swift @@ -59,8 +59,8 @@ final class DefaultInvoicesService: POInvoicesService { }, while: { result in switch result { - case let .success(response): - return response.nativeApm.state != .captured + case let .success(state): + return state != .captured case let .failure(failure as POFailure): let retriableCodes: [POFailure.Code] = [ .networkUnreachable, .timeout(.mobile), .internal(.mobile) diff --git a/Sources/ProcessOut/Sources/Services/Invoices/POInvoicesService.swift b/Sources/ProcessOut/Sources/Services/Invoices/POInvoicesService.swift index 6ded8428c..448f64992 100644 --- a/Sources/ProcessOut/Sources/Services/Invoices/POInvoicesService.swift +++ b/Sources/ProcessOut/Sources/Services/Invoices/POInvoicesService.swift @@ -5,9 +5,6 @@ // Created by Andrii Vysotskyi on 02.11.2022. // -@available(*, deprecated, renamed: "POInvoicesService") -public typealias POInvoicesServiceType = POInvoicesService - public protocol POInvoicesService: POService { // sourcery: AutoCompletion /// Requests information needed to continue existing payment or start new one. diff --git a/Sources/ProcessOut/Sources/Services/Shared/POService.swift b/Sources/ProcessOut/Sources/Services/Shared/POService.swift index ffdd68cc2..bc34254e5 100644 --- a/Sources/ProcessOut/Sources/Services/Shared/POService.swift +++ b/Sources/ProcessOut/Sources/Services/Shared/POService.swift @@ -11,6 +11,3 @@ public protocol POService: Sendable { /// Service's failure type. typealias Failure = POFailure } - -@available(*, deprecated, renamed: "POService") -public typealias POServiceType = POService diff --git a/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Configuration/POBillingAddressConfiguration.swift b/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Configuration/POBillingAddressConfiguration.swift index 31e8c4cf0..b5f06aa11 100644 --- a/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Configuration/POBillingAddressConfiguration.swift +++ b/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Configuration/POBillingAddressConfiguration.swift @@ -10,9 +10,6 @@ import ProcessOut /// Billing address collection configuration. public struct POBillingAddressConfiguration: Sendable { - @available(*, deprecated, message: "Use POBillingAddressCollectionMode directly.") - public typealias CollectionMode = POBillingAddressCollectionMode - /// Billing address collection mode. public let mode: POBillingAddressCollectionMode diff --git a/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Delegate/POCardTokenizationDelegate.swift b/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Delegate/POCardTokenizationDelegate.swift index e4cec010f..1fc132fe7 100644 --- a/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Delegate/POCardTokenizationDelegate.swift +++ b/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Delegate/POCardTokenizationDelegate.swift @@ -24,7 +24,7 @@ public protocol POCardTokenizationDelegate: AnyObject, Sendable { /// Allows to choose preferred scheme that will be selected by default based on issuer information. Default /// implementation returns primary scheme. @MainActor - func preferredScheme(issuerInformation: POCardIssuerInformation) -> String? + func preferredScheme(issuerInformation: POCardIssuerInformation) -> POCardScheme? /// Asks delegate whether user should be allowed to continue after failure or module should complete. /// Default implementation returns `true`. @@ -44,7 +44,7 @@ extension POCardTokenizationDelegate { } @MainActor - public func preferredScheme(issuerInformation: POCardIssuerInformation) -> String? { + public func preferredScheme(issuerInformation: POCardIssuerInformation) -> POCardScheme? { issuerInformation.scheme } diff --git a/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Interactor/DefaultCardTokenizationInteractor.swift b/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Interactor/DefaultCardTokenizationInteractor.swift index abb43fb59..131ac0106 100644 --- a/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Interactor/DefaultCardTokenizationInteractor.swift +++ b/Sources/ProcessOutUI/Sources/Modules/CardTokenization/Interactor/DefaultCardTokenizationInteractor.swift @@ -88,8 +88,8 @@ final class DefaultCardTokenizationInteractor: return } let supportedSchemes = [ - startedState.issuerInformation?.$scheme.typed, - startedState.issuerInformation?.$coScheme.typed + startedState.issuerInformation?.scheme, + startedState.issuerInformation?.coScheme ] logger.debug("Will change card scheme to \(scheme)") guard supportedSchemes.contains(scheme) else { @@ -132,7 +132,7 @@ final class DefaultCardTokenizationInteractor: cvc: startedState.cvc.value, name: startedState.cardholderName.value, contact: convertToContact(addressParameters: startedState.address), - preferredScheme: startedState.preferredScheme?.rawValue, + preferredScheme: startedState.preferredScheme, metadata: configuration.metadata ) Task { @@ -295,13 +295,12 @@ final class DefaultCardTokenizationInteractor: if !resolvePreferredScheme { startedState.preferredScheme = nil } else if let issuerInformation, let delegate = delegate { - let rawScheme = delegate.preferredScheme(issuerInformation: issuerInformation) - startedState.preferredScheme = rawScheme.map(POCardScheme.init) + startedState.preferredScheme = delegate.preferredScheme(issuerInformation: issuerInformation) } else { - startedState.preferredScheme = issuerInformation?.$scheme.typed + startedState.preferredScheme = issuerInformation?.scheme } let securityCodeFormatter = CardSecurityCodeFormatter() - securityCodeFormatter.scheme = issuerInformation?.$scheme.typed + securityCodeFormatter.scheme = issuerInformation?.scheme startedState.cvc.value = securityCodeFormatter.string(from: startedState.cvc.value) startedState.cvc.formatter = securityCodeFormatter } diff --git a/Sources/ProcessOutUI/Sources/Modules/CardTokenization/ViewModel/DefaultCardTokenizationViewModel.swift b/Sources/ProcessOutUI/Sources/Modules/CardTokenization/ViewModel/DefaultCardTokenizationViewModel.swift index 7428ddfab..47da08f3a 100644 --- a/Sources/ProcessOutUI/Sources/Modules/CardTokenization/ViewModel/DefaultCardTokenizationViewModel.swift +++ b/Sources/ProcessOutUI/Sources/Modules/CardTokenization/ViewModel/DefaultCardTokenizationViewModel.swift @@ -158,7 +158,7 @@ final class DefaultCardTokenizationViewModel: ViewModel { private func cardNumberIcon(startedState: InteractorState.Started) -> Image? { let scheme = startedState.issuerInformation?.coScheme != nil ? startedState.preferredScheme - : startedState.issuerInformation?.$scheme.typed + : startedState.issuerInformation?.scheme return scheme.flatMap(CardSchemeImageProvider.shared.image) } @@ -175,14 +175,14 @@ final class DefaultCardTokenizationViewModel: ViewModel { let pickerItem = State.PickerItem( id: ItemId.scheme, options: [ - .init(id: issuerInformation.scheme, title: issuerInformation.scheme.capitalized), - .init(id: coScheme, title: coScheme.capitalized) + .init(id: issuerInformation.scheme.rawValue, title: issuerInformation.scheme.rawValue.capitalized), + .init(id: coScheme.rawValue, title: coScheme.rawValue.capitalized) ], selectedOptionId: .init( get: { startedState.preferredScheme?.rawValue }, set: { [weak self] newValue in let newScheme = newValue.map(POCardScheme.init) - self?.interactor.setPreferredScheme(newScheme ?? issuerInformation.$scheme.typed) + self?.interactor.setPreferredScheme(newScheme ?? issuerInformation.scheme) } ), preferrsInline: true diff --git a/Sources/ProcessOutUI/Sources/Modules/CardUpdate/Delegate/POCardUpdateInformation.swift b/Sources/ProcessOutUI/Sources/Modules/CardUpdate/Delegate/POCardUpdateInformation.swift index c52b52dd3..7e423a4fa 100644 --- a/Sources/ProcessOutUI/Sources/Modules/CardUpdate/Delegate/POCardUpdateInformation.swift +++ b/Sources/ProcessOutUI/Sources/Modules/CardUpdate/Delegate/POCardUpdateInformation.swift @@ -22,28 +22,25 @@ public struct POCardUpdateInformation: Sendable { public let iin: String? /// Scheme of the card. - @POTypedRepresentation - public private(set) var scheme: String? + public let scheme: POCardScheme? /// Co-scheme of the card, such as Carte Bancaire. - @POTypedRepresentation - public private(set) var coScheme: String? + public let coScheme: POCardScheme? /// Preferred scheme previously selected by customer if any. - @POTypedRepresentation - public private(set) var preferredScheme: String? + public let preferredScheme: POCardScheme? public init( maskedNumber: String? = nil, iin: String? = nil, - scheme: String? = nil, - coScheme: String? = nil, - preferredScheme: String? = nil + scheme: POCardScheme? = nil, + coScheme: POCardScheme? = nil, + preferredScheme: POCardScheme? = nil ) { self.maskedNumber = maskedNumber self.iin = iin - self._scheme = .init(wrappedValue: scheme) - self._coScheme = .init(wrappedValue: coScheme) - self._preferredScheme = .init(wrappedValue: preferredScheme) + self.scheme = scheme + self.coScheme = coScheme + self.preferredScheme = preferredScheme } } diff --git a/Sources/ProcessOutUI/Sources/Modules/CardUpdate/Interactor/DefaultCardUpdateInteractor.swift b/Sources/ProcessOutUI/Sources/Modules/CardUpdate/Interactor/DefaultCardUpdateInteractor.swift index b5d43e28f..99beb2c9e 100644 --- a/Sources/ProcessOutUI/Sources/Modules/CardUpdate/Interactor/DefaultCardUpdateInteractor.swift +++ b/Sources/ProcessOutUI/Sources/Modules/CardUpdate/Interactor/DefaultCardUpdateInteractor.swift @@ -91,9 +91,7 @@ final class DefaultCardUpdateInteractor: BaseInteractor POCardScheme? { - if let scheme = cardInfo?.$preferredScheme.typed { + if let scheme = cardInfo?.preferredScheme { return scheme } guard configuration.isSchemeSelectionAllowed else { return nil } - return cardInfo?.$scheme.typed ?? issuerInformation?.$scheme.typed + return cardInfo?.scheme ?? issuerInformation?.scheme } } diff --git a/Sources/ProcessOutUI/Sources/Modules/DynamicCheckout/Delegate/PODynamicCheckoutDelegate.swift b/Sources/ProcessOutUI/Sources/Modules/DynamicCheckout/Delegate/PODynamicCheckoutDelegate.swift index 0109a026f..c525d6b5f 100644 --- a/Sources/ProcessOutUI/Sources/Modules/DynamicCheckout/Delegate/PODynamicCheckoutDelegate.swift +++ b/Sources/ProcessOutUI/Sources/Modules/DynamicCheckout/Delegate/PODynamicCheckoutDelegate.swift @@ -43,7 +43,7 @@ public protocol PODynamicCheckoutDelegate: AnyObject, Sendable { /// Allows to choose preferred scheme that will be selected by default based on issuer information. Default /// implementation returns primary scheme. @MainActor - func dynamicCheckout(preferredSchemeFor issuerInformation: POCardIssuerInformation) -> String? + func dynamicCheckout(preferredSchemeFor issuerInformation: POCardIssuerInformation) -> POCardScheme? // MARK: - Alternative Payment @@ -88,7 +88,7 @@ extension PODynamicCheckoutDelegate { } @MainActor - public func dynamicCheckout(preferredSchemeFor issuerInformation: POCardIssuerInformation) -> String? { + public func dynamicCheckout(preferredSchemeFor issuerInformation: POCardIssuerInformation) -> POCardScheme? { issuerInformation.scheme } diff --git a/Sources/ProcessOutUI/Sources/Modules/DynamicCheckout/Interactor/DynamicCheckout/DynamicCheckoutDefaultInteractor.swift b/Sources/ProcessOutUI/Sources/Modules/DynamicCheckout/Interactor/DynamicCheckout/DynamicCheckoutDefaultInteractor.swift index e27accac9..eb6a163e0 100644 --- a/Sources/ProcessOutUI/Sources/Modules/DynamicCheckout/Interactor/DynamicCheckout/DynamicCheckoutDefaultInteractor.swift +++ b/Sources/ProcessOutUI/Sources/Modules/DynamicCheckout/Interactor/DynamicCheckout/DynamicCheckoutDefaultInteractor.swift @@ -729,7 +729,7 @@ extension DynamicCheckoutDefaultInteractor: POCardTokenizationDelegate { try await authorizeInvoice(source: card.id, startedState: currentState.snapshot) } - func preferredScheme(issuerInformation: POCardIssuerInformation) -> String? { + func preferredScheme(issuerInformation: POCardIssuerInformation) -> POCardScheme? { delegate?.dynamicCheckout(preferredSchemeFor: issuerInformation) } diff --git a/Sources/ProcessOutUI/Sources/Modules/NativeAlternativePayment/Configuration/PONativeAlternativePaymentConfiguration.swift b/Sources/ProcessOutUI/Sources/Modules/NativeAlternativePayment/Configuration/PONativeAlternativePaymentConfiguration.swift index ad9b4bba8..e663adb89 100644 --- a/Sources/ProcessOutUI/Sources/Modules/NativeAlternativePayment/Configuration/PONativeAlternativePaymentConfiguration.swift +++ b/Sources/ProcessOutUI/Sources/Modules/NativeAlternativePayment/Configuration/PONativeAlternativePaymentConfiguration.swift @@ -61,58 +61,6 @@ public struct PONativeAlternativePaymentConfiguration { /// Payment confirmation configuration. public let paymentConfirmation: PONativeAlternativePaymentConfirmationConfiguration - /// Boolean value that specifies whether module should wait for payment confirmation from PSP or will - /// complete right after all user's input is submitted. Default value is `true`. - @available(*, deprecated, renamed: "paymentConfirmation.waitsConfirmation") - public var waitsPaymentConfirmation: Bool { - paymentConfirmation.waitsConfirmation - } - - /// Amount of time (in seconds) that module is allowed to wait before receiving final payment confirmation. - /// Default timeout is 3 minutes while maximum value is 15 minutes. - @available(*, deprecated, renamed: "paymentConfirmation.timeout") - public var paymentConfirmationTimeout: TimeInterval { - paymentConfirmation.timeout - } - - /// Action that could be optionally presented to user during payment confirmation stage. To remove action - /// use `nil`, this is default behaviour. - @available(*, deprecated, renamed: "paymentConfirmation.secondaryAction") - public var paymentConfirmationSecondaryAction: SecondaryAction? { - paymentConfirmation.secondaryAction - } - - /// Creates configuration instance. - @available(*, deprecated) - public init( - invoiceId: String, - gatewayConfigurationId: String, - title: String? = nil, - successMessage: String? = nil, - primaryActionTitle: String? = nil, - secondaryAction: SecondaryAction? = nil, - inlineSingleSelectValuesLimit: Int = 5, - skipSuccessScreen: Bool = false, - waitsPaymentConfirmation: Bool = true, - paymentConfirmationTimeout: TimeInterval = 180, - paymentConfirmationSecondaryAction: SecondaryAction? = nil - ) { - self.invoiceId = invoiceId - self.gatewayConfigurationId = gatewayConfigurationId - self.title = title - self.shouldHorizontallyCenterCodeInput = true - self.successMessage = successMessage - self.primaryActionTitle = primaryActionTitle - self.secondaryAction = secondaryAction - self.inlineSingleSelectValuesLimit = inlineSingleSelectValuesLimit - self.skipSuccessScreen = skipSuccessScreen - self.paymentConfirmation = .init( - waitsConfirmation: waitsPaymentConfirmation, - timeout: paymentConfirmationTimeout, - secondaryAction: paymentConfirmationSecondaryAction - ) - } - /// Creates configuration instance. public init( invoiceId: String, diff --git a/Sources/ProcessOutUI/Sources/Modules/NativeAlternativePayment/Interactor/NativeAlternativePaymentDefaultInteractor.swift b/Sources/ProcessOutUI/Sources/Modules/NativeAlternativePayment/Interactor/NativeAlternativePaymentDefaultInteractor.swift index 0bb589187..d1af2cd2f 100644 --- a/Sources/ProcessOutUI/Sources/Modules/NativeAlternativePayment/Interactor/NativeAlternativePaymentDefaultInteractor.swift +++ b/Sources/ProcessOutUI/Sources/Modules/NativeAlternativePayment/Interactor/NativeAlternativePaymentDefaultInteractor.swift @@ -178,19 +178,19 @@ final class NativeAlternativePaymentDefaultInteractor: restoreStartedStateAfterSubmissionFailureIfPossible(error, replaceErrorMessages: true) return } - switch response.nativeApm.state { + switch response.state { case .pendingCapture: send(event: .didSubmitParameters(additionalParametersExpected: false)) await setAwaitingCaptureStateUnchecked( - gateway: startedState.gateway, parameterValues: response.nativeApm.parameterValues + gateway: startedState.gateway, parameterValues: response.parameterValues ) case .captured: send(event: .didSubmitParameters(additionalParametersExpected: false)) await setCapturedStateUnchecked( - gateway: startedState.gateway, parameterValues: response.nativeApm.parameterValues + gateway: startedState.gateway, parameterValues: response.parameterValues ) case .customerInput: - await restoreStartedStateAfterSubmission(nativeApm: response.nativeApm) + await restoreStartedStateAfterSubmission(nativeApm: response) case .failed: fallthrough // swiftlint:disable:this fallthrough @unknown default: @@ -327,9 +327,7 @@ final class NativeAlternativePaymentDefaultInteractor: logger.debug("One or more parameters are not valid: \(invalidFields), waiting for parameters to update") } - private func restoreStartedStateAfterSubmission( - nativeApm: PONativeAlternativePaymentMethodResponse.NativeApm - ) async { + private func restoreStartedStateAfterSubmission(nativeApm: PONativeAlternativePaymentMethodResponse) async { guard case var .submitting(startedState) = state else { return }