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

Revert "Show promo badge in vertical mode form header" #4472

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
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
Revert "Show promo badge in vertical mode form header (#4461)"
This reverts commit da29084.
porter-stripe authored Jan 15, 2025
commit bdfb824940b0f5068ff5225c51be0901152e93e9
Original file line number Diff line number Diff line change
@@ -131,8 +131,7 @@ class EmbeddedFormViewController: UIViewController {
paymentMethodType: paymentMethodType,
// Special case: use "New Card" instead of "Card" if the displayed saved PM is a card
shouldUseNewCardHeader: shouldUseNewCardNewCardHeader,
appearance: configuration.appearance,
incentive: elementsSession.incentive?.takeIfAppliesTo(paymentMethodType)
appearance: configuration.appearance
)

return PaymentMethodFormViewController(
Original file line number Diff line number Diff line change
@@ -34,25 +34,9 @@ final class FormHeaderView: UIView {
return PaymentMethodTypeImageView(paymentMethodType: paymentMethodType, backgroundColor: appearance.colors.background)
}
}()

private lazy var promoBadgeView: PromoBadgeView? = {
guard let incentive else {
return nil
}

return PromoBadgeView(
appearance: appearance,
tinyMode: false,
text: incentive.displayText
)
}()

private lazy var stackView: UIStackView = {
// This spacer makes sure that the promo badge is aligned correctly
let spacerView = UIView()
spacerView.setContentHuggingPriority(.defaultLow, for: .horizontal)

let views = [imageView, label, promoBadgeView, spacerView].compactMap { $0 }
let views = [imageView, label].compactMap { $0 }
let stackView = UIStackView(arrangedSubviews: views)
stackView.spacing = 12
if imageView == nil {
@@ -67,21 +51,13 @@ final class FormHeaderView: UIView {
private let paymentMethodType: PaymentSheet.PaymentMethodType
private let shouldUseNewCardHeader: Bool // true if the customer has a saved payment method that is type card
private let appearance: PaymentSheet.Appearance
private let incentive: PaymentMethodIncentive?

init(
paymentMethodType: PaymentSheet.PaymentMethodType,
shouldUseNewCardHeader: Bool,
appearance: PaymentSheet.Appearance,
incentive: PaymentMethodIncentive?
) {
init(paymentMethodType: PaymentSheet.PaymentMethodType, shouldUseNewCardHeader: Bool, appearance: PaymentSheet.Appearance) {
self.paymentMethodType = paymentMethodType
self.shouldUseNewCardHeader = shouldUseNewCardHeader
self.appearance = appearance
self.incentive = incentive
super.init(frame: .zero)
addAndPinSubview(stackView)

if let imageView {
NSLayoutConstraint.activate([
imageView.widthAnchor.constraint(equalToConstant: 20),
Original file line number Diff line number Diff line change
@@ -745,23 +745,22 @@ extension PaymentSheetVerticalViewController: VerticalPaymentMethodListViewContr
}
}()
let headerView: UIView = {
let incentive = elementsSession.incentive?.takeIfAppliesTo(paymentMethodType)
if shouldDisplayFormOnly, let wallet = makeWalletHeaderView() {
// Special case: if there is only one payment method type and it's not a card and wallet options are available
// Display the wallet, then the FormHeaderView below it
if loadResult.paymentMethodTypes.first != .stripe(.card) {
let containerView = UIStackView(arrangedSubviews: [
wallet,
FormHeaderView(
paymentMethodType: paymentMethodType,
shouldUseNewCardHeader: savedPaymentMethods.first?.type == .card,
appearance: configuration.appearance,
incentive: incentive
),
])
let containerView = UIStackView(arrangedSubviews: [
wallet,
FormHeaderView(
paymentMethodType: paymentMethodType,
shouldUseNewCardHeader: savedPaymentMethods.first?.type == .card,
appearance: configuration.appearance
),
])
containerView.axis = .vertical
containerView.spacing = PaymentSheetUI.defaultPadding
return containerView

return containerView
}

return wallet
@@ -770,8 +769,7 @@ extension PaymentSheetVerticalViewController: VerticalPaymentMethodListViewContr
paymentMethodType: paymentMethodType,
// Special case: use "New Card" instead of "Card" if the displayed saved PM is a card
shouldUseNewCardHeader: savedPaymentMethods.first?.type == .card,
appearance: configuration.appearance,
incentive: incentive
appearance: configuration.appearance
)
}
}()
Original file line number Diff line number Diff line change
@@ -320,24 +320,6 @@ final class PaymentSheetVerticalViewControllerSnapshotTest: STPSnapshotTestCase
listVC.didTap(rowButton: listVC.getRowButton(accessibilityIdentifier: "New card"), selection: .new(paymentMethodType: .stripe(.card)))
verify(sut)
}

func testPromoBadgeInFormTitle() {
let elementsSession = STPElementsSession._testValue(
paymentMethodTypes: ["card"],
hasLinkConsumerIncentive: true
)
let loadResult = PaymentSheetLoader.LoadResult(
intent: ._testPaymentIntent(paymentMethodTypes: [.card]),
elementsSession: elementsSession,
savedPaymentMethods: [],
paymentMethodTypes: [.stripe(.card), .linkCardBrand]
)
let sut = PaymentSheetVerticalViewController(configuration: ._testValue_MostPermissive(), loadResult: loadResult, isFlowController: false, analyticsHelper: ._testValue(), previousPaymentOption: nil)
_ = makeBottomSheetAndLayout(sut) // Laying out before calling `didTap` avoids breaking constraints due to zero size
let listVC = sut.paymentMethodListViewController!
listVC.didTap(rowButton: listVC.getRowButton(accessibilityIdentifier: "Bank"), selection: .new(paymentMethodType: .linkCardBrand))
verify(sut)
}

func testCVCRecollection() {
let savedCard = STPPaymentMethod._testCard()
Original file line number Diff line number Diff line change
@@ -71,8 +71,7 @@ extension STPElementsSession {
defaultPaymentMethod: String? = nil,
paymentMethods: [[AnyHashable: Any]]? = nil,
linkUseAttestation: Bool? = nil,
linkSuppress2FA: Bool? = nil,
hasLinkConsumerIncentive: Bool = false
linkSuppress2FA: Bool? = nil
) -> STPElementsSession {
var json = STPTestUtils.jsonNamed("ElementsSession")!
json[jsonDict: "payment_method_preference"]?["ordered_payment_method_types"] = paymentMethodTypes
@@ -122,18 +121,6 @@ extension STPElementsSession {
if let linkSuppress2FA {
json[jsonDict: "link_settings"]!["link_mobile_suppress_2fa_modal"] = linkSuppress2FA
}

if hasLinkConsumerIncentive {
json[jsonDict: "link_settings"]!["link_consumer_incentive"] = [
"campaign": "bankaccountsignup",
"incentive_display_text": "$5",
"incentive_params": [
"amount_flat": 500,
"currency": "USD",
"payment_method": "link_instant_debits",
]
]
}

json[jsonDict: "link_settings"]!["link_funding_sources"] = linkFundingSources.map(\.rawValue)

Binary file not shown.
Loading