Skip to content

Commit

Permalink
Release 1.18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Adyen-GIT-Manager committed Apr 23, 2018
1 parent 85c54bf commit 9daf90c
Show file tree
Hide file tree
Showing 97 changed files with 4,627 additions and 1,518 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ disabled_rules:
- operator_whitespace
- unused_closure_parameter
- todo
- fallthrough

#Review:
- large_tuple
Expand Down
62 changes: 9 additions & 53 deletions Adyen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@
E20AD0061EFAB0310065B70E /* Headers */,
E20AD0071EFAB0310065B70E /* Resources */,
E226F1431EFCF50A009E04C9 /* SwiftLint */,
02474A22ADD502EEE43DCD38 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -904,7 +903,6 @@
E20AD00F1EFAB0310065B70E /* Frameworks */,
E20AD0101EFAB0310065B70E /* Resources */,
B2D23B80357D0CC2DABA91CB /* [CP] Embed Pods Frameworks */,
8DAFF072F5EADA4FC2A33B45 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -943,7 +941,6 @@
E2E9D0181F0389C80056E0AC /* Frameworks */,
E2E9D0191F0389C80056E0AC /* Resources */,
2DC1652936EDFD1499FBF286 /* [CP] Embed Pods Frameworks */,
6F9EB542D6DFC7ED0AD003A8 /* [CP] Copy Pods Resources */,
E250E1431F0E606000BFFF2F /* Embed Frameworks */,
);
buildRules = (
Expand All @@ -963,7 +960,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0910;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = Adyen;
TargetAttributes = {
E20AD0081EFAB0310065B70E = {
Expand Down Expand Up @@ -1066,21 +1063,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
02474A22ADD502EEE43DCD38 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Adyen/Pods-Adyen-resources.sh\"\n";
showEnvVarsInLog = 0;
};
2DC1652936EDFD1499FBF286 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1117,36 +1099,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
6F9EB542D6DFC7ED0AD003A8 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AdyenUIHost/Pods-AdyenUIHost-resources.sh\"\n";
showEnvVarsInLog = 0;
};
8DAFF072F5EADA4FC2A33B45 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AdyenTests/Pods-AdyenTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
B07087D0BC32240A0F60E2AC /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1405,13 +1357,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -1420,7 +1374,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.17.1;
CURRENT_PROJECT_VERSION = 1.18.0;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -1465,13 +1419,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand All @@ -1480,7 +1436,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.17.1;
CURRENT_PROJECT_VERSION = 1.18.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -1509,7 +1465,7 @@
buildSettings = {
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1.17.1;
DYLIB_CURRENT_VERSION = 1.18.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = Adyen/Info.plist;
Expand All @@ -1528,7 +1484,7 @@
buildSettings = {
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1.17.1;
DYLIB_CURRENT_VERSION = 1.18.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = Adyen/Info.plist;
Expand Down
4 changes: 1 addition & 3 deletions Adyen.xcodeproj/xcshareddata/xcschemes/Adyen.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 1 addition & 3 deletions Adyen.xcodeproj/xcshareddata/xcschemes/AdyenUIHost.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
8 changes: 8 additions & 0 deletions Adyen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
26 changes: 14 additions & 12 deletions Adyen/Core/CurrencyFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@

import Foundation

/// Convenience class to format a number with a given currency.
internal class CurrencyFormatter {
/// Convenience class to format a payment amount for display.
public final class AmountFormatter {

// MARK: - Initialization
// MARK: - Public

private init() {

/// Formats a string based on the provided amount and currency code.
///
/// - Parameters:
/// - amount: Amount in minor units, i.e. 2000.
/// - currencyCode: The currency code, i.e. "USD".
/// - Returns: A formatted string, i.e. "$20.00".
public static func formatted(amount: Int, currencyCode: String) -> String? {
let decimalAmount = AmountFormatter.decimalAmount(amount, currencyCode: currencyCode)
return defaultFormatter(currencyCode: currencyCode).string(from: decimalAmount)
}

// MARK: - Internal

internal static func formatted(amount: Int, currencyCode: String) -> String? {
let decimalAmount = CurrencyFormatter.decimalAmount(amount, currencyCode: currencyCode)
return defaultFormatter(currencyCode: currencyCode).string(from: decimalAmount)
}

internal static func decimalAmount(_ amount: Int, currencyCode: String) -> NSDecimalNumber {
let defaultFormatter = CurrencyFormatter.defaultFormatter(currencyCode: currencyCode)
let maximumFractionDigits = CurrencyFormatter.maximumFractionDigits(for: currencyCode)
let defaultFormatter = AmountFormatter.defaultFormatter(currencyCode: currencyCode)
let maximumFractionDigits = AmountFormatter.maximumFractionDigits(for: currencyCode)
defaultFormatter.maximumFractionDigits = maximumFractionDigits

let decimalMinorAmount = NSDecimalNumber(value: amount)
Expand Down
4 changes: 2 additions & 2 deletions Adyen/Core/Enum/InputType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public enum InputType: RawRepresentable, Equatable {
return true
case (.cvc, .cvc):
return true
case let (.cardToken(a), .cardToken(b)):
return a == b
case let (.cardToken(first), .cardToken(second)):
return first == second
case (.applePayToken, .applePayToken):
return true
case (.address, .address):
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Core/InputDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class InputDetail {
let selectItems: [InputSelectItem]? = items.count > 0 ? items : nil

// Embedded Input Details
let inputDetails = (info["inputDetails"] as? [[String: Any]])?.flatMap { InputDetail(info: $0) }
let inputDetails = (info["inputDetails"] as? [[String: Any]])?.compactMap { InputDetail(info: $0) }

self.init(type: type, key: key, value: value, optional: optional, items: selectItems, inputDetails: inputDetails, configuration: configuration)
}
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Core/PaymentMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class PaymentMethod: Equatable {

let logoURL = URL(string: logoBaseURL + type + UIScreen.retinaExtension() + ".png")
let inputDetailDescriptions = info["inputDetails"] as? [[String: Any]]
let inputDetails = inputDetailDescriptions?.flatMap { InputDetail(info: $0) }
let inputDetails = inputDetailDescriptions?.compactMap { InputDetail(info: $0) }

var group: Group?
if let groupInfo = info["group"] as? [String: Any] {
Expand Down
8 changes: 6 additions & 2 deletions Adyen/Core/PaymentRequestToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ internal struct PaymentRequestToken: Encodable {
/// The version of the device's system.
internal var systemVersion = UIDevice.current.systemVersion

/// The identifier of the device's locale.
internal var localeIdentifier = NSLocale.current.identifier
/// The identifier of the device's locale in the format aa_BB, where "aa" is language code and "BB" is region code.
internal var localeIdentifier: String = {
let languageCode = NSLocale.current.languageCode ?? ""
let regionCode = NSLocale.current.regionCode ?? ""
return "\(languageCode)_\(regionCode)"
}()

/// A string identifying the device.
internal var deviceIdentifier = UIDevice.current.identifierForVendor?.uuidString ?? ""
Expand Down
8 changes: 4 additions & 4 deletions Adyen/Core/PaymentSetup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ internal struct PaymentSetup {
self.paymentData = paymentData

let preferredPaymentMethodDictionaries = dictionary["recurringDetails"] as? [[String: Any]] ?? []
self.preferredPaymentMethods = preferredPaymentMethodDictionaries.flatMap {
self.preferredPaymentMethods = preferredPaymentMethodDictionaries.compactMap {
return PaymentMethod(info: $0, logoBaseURL: logoBaseURL.absoluteString, isOneClick: true)
}

let availablePaymentMethodsDictionaries = dictionary["paymentMethods"] as? [[String: Any]] ?? []
self.availablePaymentMethods = availablePaymentMethodsDictionaries.flatMap {
self.availablePaymentMethods = availablePaymentMethodsDictionaries.compactMap {
return PaymentMethod(info: $0, logoBaseURL: logoBaseURL.absoluteString, isOneClick: false)
}.groupBy {
return $0.group?.type ?? UUID().uuidString
}.flatMap {
}.compactMap {
return $0.count == 1 ? $0.first : PaymentMethod(members: $0)
}

if let lineItemDictionaries = dictionary["lineItems"] as? [[String: Any]] {
lineItems = lineItemDictionaries.flatMap({ item in
lineItems = lineItemDictionaries.compactMap({ item in
let itemId = item["itemId"] as? String
let description = item["description"] as? String
let amountExcludingTax = item["amountExcludingTax"] as? Int
Expand Down
19 changes: 19 additions & 0 deletions Adyen/CoreUI/Appearance/AppearanceConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public final class AppearanceConfiguration {
/// When no type is specified, a default button is used.
public var checkoutButtonType: UIButton.Type = UIButton.self

/// The title of the checkout button.
/// If none provided, the amount in the format "Pay $x.xx" will be used.
public var checkoutButtonTitle: String?

// MARK: - Configuring Safari View Controller

/// The color to tint the background of the Safari View Controller navigation bar and toolbar. Only has an effect on iOS 11 and higher.
Expand Down Expand Up @@ -138,6 +142,7 @@ extension AppearanceConfiguration: NSCopying {
appearanceConfiguration.safariControlTintColor = safariControlTintColor
appearanceConfiguration.tintColor = tintColor
appearanceConfiguration.backgroundColor = backgroundColor
appearanceConfiguration.checkoutButtonTitle = checkoutButtonTitle

appearanceConfiguration.internalCheckoutButtonTitleTextAttributes = internalCheckoutButtonTitleTextAttributes
appearanceConfiguration.internalCheckoutButtonTitleEdgeInsets = internalCheckoutButtonTitleEdgeInsets
Expand Down Expand Up @@ -212,6 +217,20 @@ internal extension AppearanceConfiguration {

private static var _shared = AppearanceConfiguration.default

internal func payActionTitle(forAmount amount: Int?, currencyCode: String?) -> String {
let payActionTitle: String
if let buttonTitle = checkoutButtonTitle {
payActionTitle = buttonTitle
} else if let amount = amount, let currencyCode = currencyCode {
let formattedAmount = AmountFormatter.formatted(amount: amount, currencyCode: currencyCode) ?? ""
payActionTitle = ADYLocalizedString("payButton.formatted", formattedAmount)
} else {
payActionTitle = ADYLocalizedString("payButton.formatted")
}

return payActionTitle
}

internal func cancelButtonItem(target: Any, selector: Selector) -> UIBarButtonItem {
var cancelButtonItem: UIBarButtonItem!
if let cancelButtonImage = navigationBarCancelButtonImage {
Expand Down
2 changes: 1 addition & 1 deletion Adyen/CoreUI/Container/ContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal class ContainerView: UIScrollView {

}

fileprivate class ContainerContentBackgroundView: UIView {
private class ContainerContentBackgroundView: UIView {

override func draw(_ rect: CGRect) {
// Draw background color.
Expand Down
2 changes: 1 addition & 1 deletion Adyen/CoreUI/Plugins/PaymentDetailsPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
internal protocol PaymentDetailsPresenter: class {

/// The delegate of the details presenter.
weak var delegate: PaymentDetailsPresenterDelegate? { get set }
var delegate: PaymentDetailsPresenterDelegate? { get set }

/// Requests the user to enter the payment details.
func start()
Expand Down
Loading

0 comments on commit 9daf90c

Please sign in to comment.