Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide default pay button configuration #1701

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4ff6a62
Use card component within non scrollable container view
nauaros May 9, 2024
cca1993
Use card component within non scrollable container view
nauaros May 9, 2024
62ba38a
Update
nauaros May 15, 2024
1db89df
Update publish job
nauaros May 16, 2024
51342ab
Merge branch 'develop' into remove-pay-button-research
nauaros May 16, 2024
32e49b1
Form view changes
nauaros May 27, 2024
41d81e8
Merge branch 'COIOS-382_Configurable_pay_button' into hide-pay-button…
nauaros May 27, 2024
0016ff2
Define hide pay button property
nauaros May 27, 2024
53d302f
Expose function to trigger payment
nauaros May 27, 2024
6d35ab2
Rename hidePayButton property
nauaros May 27, 2024
f7a8f61
Remove UIScrollView from FormView
nauaros May 29, 2024
a0fb9c4
Add UIScrollView to UIFormViewController
nauaros May 29, 2024
5d3fedf
Update form view constrains
nauaros May 30, 2024
c7e5aa4
Refactor FormView
nauaros May 30, 2024
8bbcced
Add logic to add/remove scroll view from view hierarchy in FormViewCo…
nauaros May 30, 2024
903cfad
Update showing/hiding pay button logic
nauaros May 30, 2024
66cbfc0
Add hide pay button flag to CashAppComponent
nauaros Jun 5, 2024
d6d9811
Add hide default pay button flag to GiftCardComponent
nauaros Jun 5, 2024
0b84cf9
Align hide/show pay button with web team
nauaros Jun 6, 2024
8c654d1
Rename showDefaultPayButton to showSubmitButton
nauaros Jun 6, 2024
8f8cf00
Update configurable pay button demo with new APIs
nauaros Jun 10, 2024
d973253
Delete logic in didUpdatePreferredContentSize method
nauaros Jun 10, 2024
febb1d9
Refactor layout method
nauaros Jun 13, 2024
c84f3a0
Update compile error in tests suite
nauaros Jun 13, 2024
67b8d37
Add func keyword to allowed list
nauaros Jun 13, 2024
3de4c07
Merge branch 'COIOS-382_Configurable_pay_button' into hide-pay-button…
nauaros Jun 13, 2024
b510001
Apply styling to FormViewController
nauaros Jun 13, 2024
81c849f
Add missing styling
nauaros Jun 13, 2024
a11e550
Logic to calc intrinsic content size based on scrolling behavior
nauaros Jun 14, 2024
18646d7
Enabled scrolling in FormView for PreSelectedPaymentMethod
nauaros Jun 14, 2024
cfff590
Make scrollView property lazy
nauaros Jun 14, 2024
b347271
Make set private for showSubmitButton property
nauaros Jun 14, 2024
39ec8c5
Update header in FormView
nauaros Jun 14, 2024
84cc79c
Refactor layout code in FormViewController
nauaros Jun 14, 2024
9f19190
Merge branch 'COIOS-382_Configurable_pay_button' into hide-pay-button…
nauaros Jun 24, 2024
9020c8e
Fix scrolling bug in drop-in components
nauaros Jun 24, 2024
ba23c4e
Enabled CashApp Pay by default
nauaros Jun 24, 2024
490e84d
Disable alert when drop-in flow is cancelled
nauaros Jun 24, 2024
f5002ef
Merge branch 'COIOS-382_Configurable_pay_button' into hide-pay-button…
nauaros Jul 11, 2024
3af5bb5
Generate snapshots
nauaros Jul 12, 2024
c6f66a3
Merge branch 'COIOS-382_Configurable_pay_button' into hide-pay-button…
nauaros Jul 12, 2024
8131651
🤖 Generate Snapshots (#1743)
github-actions[bot] Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Adyen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@
C927083E27590BDB00D15EA0 /* BACSInputFormViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C927083D27590BDB00D15EA0 /* BACSInputFormViewControllerTests.swift */; };
C927084027590FE800D15EA0 /* BACSInputPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C927083F27590FE800D15EA0 /* BACSInputPresenterTests.swift */; };
C92708422759106500D15EA0 /* BACSRouterProtocolMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C92708412759106500D15EA0 /* BACSRouterProtocolMock.swift */; };
C927FA0F2BED35B5008A11C6 /* CustomComponentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C927FA0E2BED35B5008A11C6 /* CustomComponentViewController.swift */; };
C92F6DBE26AFF336004BD516 /* PostalAddressMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C92F6DBD26AFF336004BD516 /* PostalAddressMocks.swift */; };
C92F6DC126B04B63004BD516 /* XCTestCase+FormAddressItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = C92F6DC026B04B63004BD516 /* XCTestCase+FormAddressItem.swift */; };
C930FB6E269D79E0006A26D2 /* AffirmDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = C930FB6D269D79E0006A26D2 /* AffirmDetails.swift */; };
Expand All @@ -485,6 +486,8 @@
C95903DE275A48D000E7D3BC /* BACSDirectDebitComponentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C95903DD275A48D000E7D3BC /* BACSDirectDebitComponentTests.swift */; };
C96688BF26A6FC1C00DC7297 /* AffirmComponentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C96688BE26A6FC1C00DC7297 /* AffirmComponentTests.swift */; };
C96E07A3283B92E300345732 /* BACSDirectDebitComponentTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C96E07A1283B92D500345732 /* BACSDirectDebitComponentTrackerTests.swift */; };
C977C62C2C11D27D00B52A90 /* CustomComponentPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C977C62B2C11D27D00B52A90 /* CustomComponentPresenter.swift */; };
C977C62F2C11D5F000B52A90 /* CustomComponentAssembler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C977C62E2C11D5F000B52A90 /* CustomComponentAssembler.swift */; };
C978F5EF2732CD6A00F59B3C /* FormCardSecurityCodeItemViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C978F5EE2732CD6A00F59B3C /* FormCardSecurityCodeItemViewTests.swift */; };
C981254E2851E9AF006D1374 /* PaymentComponentSubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = C981254C2851E903006D1374 /* PaymentComponentSubject.swift */; };
C98125502851E9E4006D1374 /* PaymentComponentSubjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C981254F2851E9E4006D1374 /* PaymentComponentSubjectTests.swift */; };
Expand Down Expand Up @@ -1760,6 +1763,7 @@
C927083D27590BDB00D15EA0 /* BACSInputFormViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BACSInputFormViewControllerTests.swift; sourceTree = "<group>"; };
C927083F27590FE800D15EA0 /* BACSInputPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BACSInputPresenterTests.swift; sourceTree = "<group>"; };
C92708412759106500D15EA0 /* BACSRouterProtocolMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BACSRouterProtocolMock.swift; sourceTree = "<group>"; };
C927FA0E2BED35B5008A11C6 /* CustomComponentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomComponentViewController.swift; sourceTree = "<group>"; };
C92F6DBD26AFF336004BD516 /* PostalAddressMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostalAddressMocks.swift; sourceTree = "<group>"; };
C92F6DC026B04B63004BD516 /* XCTestCase+FormAddressItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+FormAddressItem.swift"; sourceTree = "<group>"; };
C930FB6D269D79E0006A26D2 /* AffirmDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AffirmDetails.swift; sourceTree = "<group>"; };
Expand All @@ -1773,6 +1777,8 @@
C95C89312BF63A3500C47296 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C96688BE26A6FC1C00DC7297 /* AffirmComponentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AffirmComponentTests.swift; sourceTree = "<group>"; };
C96E07A1283B92D500345732 /* BACSDirectDebitComponentTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BACSDirectDebitComponentTrackerTests.swift; sourceTree = "<group>"; };
C977C62B2C11D27D00B52A90 /* CustomComponentPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomComponentPresenter.swift; sourceTree = "<group>"; };
C977C62E2C11D5F000B52A90 /* CustomComponentAssembler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomComponentAssembler.swift; sourceTree = "<group>"; };
C978F5EE2732CD6A00F59B3C /* FormCardSecurityCodeItemViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormCardSecurityCodeItemViewTests.swift; sourceTree = "<group>"; };
C97C16A928059A5A00534419 /* AnalyticsEventTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsEventTests.swift; sourceTree = "<group>"; };
C97C16AB280702B200534419 /* AnalyticsFlavorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsFlavorTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3359,6 +3365,16 @@
path = Trackers;
sourceTree = "<group>";
};
C977C62D2C11D52000B52A90 /* CustomComponent */ = {
isa = PBXGroup;
children = (
C927FA0E2BED35B5008A11C6 /* CustomComponentViewController.swift */,
C977C62B2C11D27D00B52A90 /* CustomComponentPresenter.swift */,
C977C62E2C11D5F000B52A90 /* CustomComponentAssembler.swift */,
);
path = CustomComponent;
sourceTree = "<group>";
};
C978F5EC2732CD0800F59B3C /* CardNumberItem */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3847,6 +3863,7 @@
children = (
E2C0E07F220B0399008616F6 /* AppDelegate.swift */,
E24FECF4226EF9AB00A65122 /* ComponentsViewController.swift */,
C977C62D2C11D52000B52A90 /* CustomComponent */,
E24FECF6226EF9D800A65122 /* ComponentsView.swift */,
F9CFB05C283541DC002F3B72 /* UIView+Helpers.swift */,
E9909FB322B7C815008DE50C /* PaymentMethods.json */,
Expand Down Expand Up @@ -7239,6 +7256,7 @@
B6EE0F392BBE9C4500B9810D /* APIClientHelper.swift in Sources */,
00ED81BD29EEC50B00A6B52C /* CardComponentAdvancedFlowExample.swift in Sources */,
81EF2FDE2AF3AAF1001FE82F /* InstantPaymentComponentExample.swift in Sources */,
C927FA0F2BED35B5008A11C6 /* CustomComponentViewController.swift in Sources */,
F9A53C532549887F009000A7 /* PaymentMethodsRequest.swift in Sources */,
E2C0E080220B0399008616F6 /* AppDelegate.swift in Sources */,
00D5B8662A4C63FE003CFCD0 /* CardComponentSettingsView.swift in Sources */,
Expand All @@ -7251,12 +7269,14 @@
E24FECFC226EFD3C00A65122 /* ComponentsItem.swift in Sources */,
F9CFB05D283541DC002F3B72 /* UIView+Helpers.swift in Sources */,
F9A53C442549887F009000A7 /* DefaultAPIClient.swift in Sources */,
C977C62F2C11D5F000B52A90 /* CustomComponentAssembler.swift in Sources */,
E24FED0D2270915A00A65122 /* CodingHelpers.swift in Sources */,
B6EE0F3A2BBEA2A800B9810D /* APIClientMock.swift in Sources */,
81A48DBB2A5709F600242341 /* DemoAddressLookupProvider.swift in Sources */,
C9454C37276A340B0086C218 /* BACSDirectDebitPresentationDelegate.swift in Sources */,
004BA67B29D427F300A8C69B /* DropInExample.swift in Sources */,
A09ADA112807142600BF6802 /* SessionRequest.swift in Sources */,
C977C62C2C11D27D00B52A90 /* CustomComponentPresenter.swift in Sources */,
F9A53C4A2549887F009000A7 /* Environment.swift in Sources */,
81EF2FE12AF3D75C001FE82F /* InstantPaymentComponentAdvancedFlowExample.swift in Sources */,
81C5D0D02AC428CB002E918F /* IssuerListComponentAdvancedFlowExample.swift in Sources */,
Expand Down
9 changes: 9 additions & 0 deletions Adyen.xcodeproj/xcshareddata/xcschemes/SnapshotTests.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F9CCA3B4296ECB3E00AD643D"
BuildableName = "SnapshotsTests.xctest"
BlueprintName = "SnapshotsTests"
ReferencedContainer = "container:Adyen.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
4 changes: 2 additions & 2 deletions Adyen/Assets/Generated/LocalizationKey.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//
// Copyright (c) 2023 Adyen N.V.
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
// This file is autogenerated. Please do not modify it.
//

// swiftlint:disable all
Expand Down Expand Up @@ -482,4 +481,5 @@ public struct LocalizationKey {
}

}

// swiftlint:enable all
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ open class AbstractPersonalInformationComponent: PaymentComponent, PresentableCo

internal lazy var formViewController: FormViewController = {
let formViewController = FormViewController(
scrollEnabled: configuration.showSubmitButton,
style: configuration.style,
localizationParameters: configuration.localizationParameters
)
Expand Down Expand Up @@ -73,7 +74,7 @@ open class AbstractPersonalInformationComponent: PaymentComponent, PresentableCo
}
formViewController.append(FormSpacerItem())
formViewController.append(button)
formViewController.append(FormSpacerItem(numberOfSpaces: 2))
formViewController.append(FormSpacerItem(numberOfSpaces: 4))
}

private func add(
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Core/Components/AnyCashAppPayConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation

/// Describes any configuration for the Cash App Pay component.
public protocol AnyCashAppPayConfiguration {

/// The URL for Cash App to call in order to redirect back to your application.
var redirectURL: URL { get }

Expand Down
22 changes: 18 additions & 4 deletions Adyen/Core/Components/Base/BasicComponentConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@ public struct BasicComponentConfiguration: AnyBasicComponentConfiguration {

/// The UI style of the component.
public var style: FormComponentStyle


/// A Boolean value that determines whether the payment button is displayed. Defaults to `true`.
public private(set) var showSubmitButton: Bool

public var localizationParameters: LocalizationParameters?

/// Initializes a new instance of `BasicComponentConfiguration`
///
/// - Parameters:
/// - style: The form style.
/// - showSubmitButton: Boolean value that determines whether the payment button is displayed.
/// Defaults to `true`.
/// - localizationParameters: The localization parameters.
public init(style: FormComponentStyle = FormComponentStyle(),
showSubmitButton: Bool = true,
localizationParameters: LocalizationParameters? = nil) {
self.style = style
self.localizationParameters = localizationParameters
self.showSubmitButton = showSubmitButton
}

}
Expand All @@ -42,21 +49,28 @@ public struct PersonalInformationConfiguration: AnyPersonalInformationConfigurat

/// The UI style of the component.
public var style: FormComponentStyle


/// A Boolean value that determines whether the payment button is displayed. Defaults to `true`.
public private(set) var showSubmitButton: Bool

public var shopperInformation: PrefilledShopperInformation?

public var localizationParameters: LocalizationParameters?

/// Initializes a new instance of `PersonalInformationConfiguration`
///
/// - Parameters:
/// - style: The form style.
/// - showSubmitButton: Boolean value that determines whether the payment button is displayed.
/// Defaults to `true`.
/// - shopperInformation: The shopper information to be prefilled.
/// - localizationParameters: The localization parameters.
public init(style: FormComponentStyle = FormComponentStyle(),
showSubmitButton: Bool = true,
shopperInformation: PrefilledShopperInformation? = nil,
localizationParameters: LocalizationParameters? = nil) {
self.style = style
self.showSubmitButton = showSubmitButton
self.shopperInformation = shopperInformation
self.localizationParameters = localizationParameters
}
Expand Down
9 changes: 8 additions & 1 deletion Adyen/Core/Components/StoredPaymentMethodComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,19 @@ extension StoredPaymentMethodComponent {
/// Configuration for Stored Payment type components.
public struct Configuration: AnyBasicComponentConfiguration {

/// A Boolean value that determines whether the payment button is displayed. Defaults to `true`.
public private(set) var showSubmitButton: Bool

public var localizationParameters: LocalizationParameters?

/// Initializes the configuration for Issuer list type components.
/// - Parameters:
/// - showSubmitButton: Boolean value that determines whether the payment button is displayed.
/// Defaults to `true`.
/// - localizationParameters: Localization parameters.
public init(localizationParameters: LocalizationParameters? = nil) {
public init(showSubmitButton: Bool = true,
localizationParameters: LocalizationParameters? = nil) {
self.showSubmitButton = showSubmitButton
self.localizationParameters = localizationParameters
}
}
Expand Down
3 changes: 0 additions & 3 deletions Adyen/Core/Payment Methods/Abstract/PaymentMethodType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public enum PaymentMethodType: RawRepresentable, Hashable, Codable {
case "cashapp": self = .cashAppPay
case "bizum": self = .bizum
case "twint": self = .twint

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

case let .other(value): return value
}
}
Expand Down Expand Up @@ -262,7 +260,6 @@ extension PaymentMethodType {
case .cashAppPay: return "cash app"
case .bizum: return "bizum"
case .twint: return "twint"

case let .other(name): return name.replacingOccurrences(of: "_", with: " ")
}
}
Expand Down
55 changes: 34 additions & 21 deletions Adyen/UI/Form/FormView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,27 @@
import UIKit

/// Displays a form for the user to enter details.
internal final class FormView: UIScrollView {
internal final class FormView: UIView {
descorp marked this conversation as resolved.
Show resolved Hide resolved

// MARK: - UI elements

private let stackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.alignment = .fill
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()

// MARK: - Properties

/// A Boolean value that determines whether the `FormView` is embedded in a `UIScrollView`
internal var isEmbeddedInScrollView: Bool = true

/// Initializes the form view.
internal init() {
super.init(frame: .zero)

preservesSuperviewLayoutMargins = true
addSubview(stackView)

configureConstraints()
setup()
}

@available(*, unavailable)
Expand All @@ -25,7 +36,7 @@ internal final class FormView: UIScrollView {
}

override internal var intrinsicContentSize: CGSize {
stackView.adyen.minimalSize
isEmbeddedInScrollView ? stackView.adyen.minimalSize : super.intrinsicContentSize
}

// MARK: - Item Views
Expand All @@ -37,21 +48,23 @@ internal final class FormView: UIScrollView {
stackView.addArrangedSubview(itemView)
}

// MARK: - Stack View

private lazy var stackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.alignment = .fill
stackView.preservesSuperviewLayoutMargins = true
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()
// MARK: - Private

private func setup() {
addSubviews()
setupLayout()
}

// MARK: - Layout
private func addSubviews() {
nauaros marked this conversation as resolved.
Show resolved Hide resolved
addSubview(stackView)
}

private func configureConstraints() {
stackView.adyen.anchor(inside: self)
stackView.widthAnchor.constraint(equalTo: widthAnchor).isActive = true
private func setupLayout() {
NSLayoutConstraint.activate([
nauaros marked this conversation as resolved.
Show resolved Hide resolved
stackView.topAnchor.constraint(equalTo: topAnchor),
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
stackView.bottomAnchor.constraint(lessThanOrEqualTo: bottomAnchor)
])
}
}
Loading
Loading