From 817be5c7a1069dc152dd4c0fadf8f1b5e42c1157 Mon Sep 17 00:00:00 2001 From: Nick Porter Date: Tue, 5 Nov 2024 17:32:47 -0700 Subject: [PATCH] Fix removal dialog showing incorrect brand --- CHANGELOG.md | 1 + .../SavedPaymentOptionsViewController.swift | 2 +- .../SavedPaymentOptionsViewControllerTests.swift | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5569457bec2..6f4ad2c91fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## x.x.x yyyy-yy-yy ### PaymentSheet * [Fixed] Fixed an issue with the vertical list with 3 or more saved payment methods where tapping outside the screen sometimes drops changes that were made (e.g. removal or update of PMs). +* [Fixed] Fixed an issue where the dialog when removing a co-branded card may show the incorrect card brand. ## 24.0.0 2024-11-04 ### PaymentSheet diff --git a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Saved Payment Method Screen/SavedPaymentOptionsViewController.swift b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Saved Payment Method Screen/SavedPaymentOptionsViewController.swift index 551959bf178..9a1718348bd 100644 --- a/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Saved Payment Method Screen/SavedPaymentOptionsViewController.swift +++ b/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/Saved Payment Method Screen/SavedPaymentOptionsViewController.swift @@ -682,7 +682,7 @@ extension STPPaymentMethod { var removalMessage: (title: String, message: String) { switch type { case .card: - let brandString = STPCardBrandUtilities.stringFrom(card?.networks?.preferred?.toCardBrand ?? card?.brand ?? .unknown) ?? "" + let brandString = STPCardBrandUtilities.stringFrom(card?.preferredDisplayBrand ?? .unknown) ?? "" let last4 = card?.last4 ?? "" let formattedMessage = STPLocalizedString( "%1$@ •••• %2$@", diff --git a/StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/SavedPaymentOptionsViewControllerTests.swift b/StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/SavedPaymentOptionsViewControllerTests.swift index bbee84bb23e..9dec04ccc72 100644 --- a/StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/SavedPaymentOptionsViewControllerTests.swift +++ b/StripePaymentSheet/StripePaymentSheetTests/PaymentSheet/SavedPaymentOptionsViewControllerTests.swift @@ -318,4 +318,13 @@ class SavedPaymentOptionsViewControllerTests: XCTestCase { analyticsHelper: ._testValue(), delegate: nil) } + + // Test case for when the preferred brand of a card is nil that we look at the display brand + func testRemovalMessagePreferredBrand_nilPreferredBrand() { + let coBrandedCard = STPPaymentMethod._testCardCoBranded(displayBrand: "cartes_bancaires") + XCTAssertNil(coBrandedCard.card?.networks?.preferred) + let removalMessage = coBrandedCard.removalMessage + + XCTAssertEqual(removalMessage.message, "Cartes Bancaires •••• 4242") + } }