From 02b4acfd9589f32c1ecd4ead38a4c8a84efd2dfa Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Fri, 4 Aug 2023 13:25:39 -0500 Subject: [PATCH 1/6] add property cardLogosDisabled to BTDropInRequest --- Sources/BraintreeDropIn/Models/BTDropInRequest.m | 1 + .../BraintreeDropIn/Public/BraintreeDropIn/BTDropInRequest.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Sources/BraintreeDropIn/Models/BTDropInRequest.m b/Sources/BraintreeDropIn/Models/BTDropInRequest.m index 513f03ba..7957fe2b 100644 --- a/Sources/BraintreeDropIn/Models/BTDropInRequest.m +++ b/Sources/BraintreeDropIn/Models/BTDropInRequest.m @@ -25,6 +25,7 @@ - (id)copyWithZone:(__unused NSZone *)zone { request.paypalDisabled = self.paypalDisabled; request.venmoDisabled = self.venmoDisabled; request.cardDisabled = self.cardDisabled; + request.cardLogosDisabled = self.cardLogosDisabled; request.threeDSecureRequest = self.threeDSecureRequest; request.cardholderNameSetting = self.cardholderNameSetting; request.shouldMaskSecurityCode = self.shouldMaskSecurityCode; diff --git a/Sources/BraintreeDropIn/Public/BraintreeDropIn/BTDropInRequest.h b/Sources/BraintreeDropIn/Public/BraintreeDropIn/BTDropInRequest.h index 4d3210c2..2aa928d5 100644 --- a/Sources/BraintreeDropIn/Public/BraintreeDropIn/BTDropInRequest.h +++ b/Sources/BraintreeDropIn/Public/BraintreeDropIn/BTDropInRequest.h @@ -40,6 +40,9 @@ typedef NS_ENUM(NSInteger, BTFormFieldSetting) { /// Defaults to false. Set to true to hide the Card option even if enabled for your account. @property (nonatomic, assign) BOOL cardDisabled; +/// Defaults to false. Set to true to hide all card logos for your account. +@property (nonatomic, assign) BOOL cardLogosDisabled; + /// Optional: Enable 3DS verification and specify options and additional information. /// /// Note: To encourage 3DS 2.0 flows, set `billingAddress`, `amount`, `email`, `mobilePhone` for best results. From 6949a04bad1af255eb24709d9d73d30f308f117d Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Fri, 4 Aug 2023 13:26:19 -0500 Subject: [PATCH 2/6] add logic to card form to display logos conditionally --- .../BraintreeDropIn/BTCardFormViewController.m | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Sources/BraintreeDropIn/BTCardFormViewController.m b/Sources/BraintreeDropIn/BTCardFormViewController.m index a739972c..2ef0702a 100644 --- a/Sources/BraintreeDropIn/BTCardFormViewController.m +++ b/Sources/BraintreeDropIn/BTCardFormViewController.m @@ -234,12 +234,15 @@ - (void)setupForm { self.cardNumberFooter.layoutMargins = UIEdgeInsetsMake(0, [BTUIKAppearance verticalFormSpace], 0, [BTUIKAppearance verticalFormSpace]); self.cardNumberFooter.layoutMarginsRelativeArrangement = true; [self.stackView addArrangedSubview:self.cardNumberFooter]; - self.cardList = [BTUIKCardListLabel new]; - self.cardList.translatesAutoresizingMaskIntoConstraints = NO; - self.cardList.availablePaymentOptions = self.supportedCardTypes; - [self.cardNumberFooter addArrangedSubview:self.cardList]; - [BTDropInUIUtilities addSpacerToStackView:self.cardNumberFooter beforeView:self.cardList size: [BTUIKAppearance horizontalFormContentPadding]]; - + + if (!self.dropInRequest.cardLogosDisabled) { + self.cardList = [BTUIKCardListLabel new]; + self.cardList.translatesAutoresizingMaskIntoConstraints = NO; + self.cardList.availablePaymentOptions = self.supportedCardTypes; + [self.cardNumberFooter addArrangedSubview:self.cardList]; + [BTDropInUIUtilities addSpacerToStackView:self.cardNumberFooter beforeView:self.cardList size: [BTUIKAppearance horizontalFormContentPadding]]; + } + NSUInteger indexOfCardNumberField = [self.stackView.arrangedSubviews indexOfObject:self.cardNumberField]; [self.stackView insertArrangedSubview:self.cardNumberFooter atIndex:(indexOfCardNumberField + 1)]; From 68ef9b2f619fe0f17a1c2f2f6bd5d9615b88d1b7 Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Fri, 4 Aug 2023 13:34:14 -0500 Subject: [PATCH 3/6] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32e431bb..484c83f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## unreleased * Require Xcode 14.1+ and Swift 5.7.1+ (per [App Store requirements](https://developer.apple.com/news/?id=jd9wcyov#:~:text=Starting%20April%2025%2C%202023%2C%20iOS,on%20the%20Mac%20App%20Store)) * Add California Privacy Laws notice of collection to credit card form +* Add `BTDropInRequest.self.cardLogosDisabled` to hide card logos on the Drop-in card form view if desired ## 9.8.2 (2023-04-10) * Silence UnionPay related deprecation warnings introduced in `braintree_ios` 5.21.0 and higher. From e3420f084ef5209d43f6bd4843d96fd763a73c7b Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Fri, 4 Aug 2023 13:35:53 -0500 Subject: [PATCH 4/6] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 484c83f4..03d303a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## unreleased * Require Xcode 14.1+ and Swift 5.7.1+ (per [App Store requirements](https://developer.apple.com/news/?id=jd9wcyov#:~:text=Starting%20April%2025%2C%202023%2C%20iOS,on%20the%20Mac%20App%20Store)) * Add California Privacy Laws notice of collection to credit card form -* Add `BTDropInRequest.self.cardLogosDisabled` to hide card logos on the Drop-in card form view if desired +* Add `BTDropInRequest.self.cardLogosDisabled` to hide card logos on the credit card form if desired ## 9.8.2 (2023-04-10) * Silence UnionPay related deprecation warnings introduced in `braintree_ios` 5.21.0 and higher. From 386f41e7f9af703dad2b6ce61238cdb537c0f95f Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Mon, 7 Aug 2023 08:20:03 -0500 Subject: [PATCH 5/6] changelog typo :facepalm: --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03d303a9..b3249cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## unreleased * Require Xcode 14.1+ and Swift 5.7.1+ (per [App Store requirements](https://developer.apple.com/news/?id=jd9wcyov#:~:text=Starting%20April%2025%2C%202023%2C%20iOS,on%20the%20Mac%20App%20Store)) * Add California Privacy Laws notice of collection to credit card form -* Add `BTDropInRequest.self.cardLogosDisabled` to hide card logos on the credit card form if desired +* Add `BTDropInRequest.cardLogosDisabled` to hide card logos on the credit card form if desired ## 9.8.2 (2023-04-10) * Silence UnionPay related deprecation warnings introduced in `braintree_ios` 5.21.0 and higher. From cce90075893b2c5ce88f5f565f195dc9045019a3 Mon Sep 17 00:00:00 2001 From: Jax DesMarais-Leder Date: Wed, 9 Aug 2023 15:46:56 -0500 Subject: [PATCH 6/6] PR feedback - add UI and unit test --- .../DemoDropInViewController.swift | 1 + Demo/UITests/BraintreeDropIn_UITests.swift | 55 +++++++++++++++++++ UnitTests/BTDropInRequestTests.m | 2 + 3 files changed, 58 insertions(+) diff --git a/Demo/Application/DemoDropInViewController.swift b/Demo/Application/DemoDropInViewController.swift index e660f8a9..8ffcccee 100644 --- a/Demo/Application/DemoDropInViewController.swift +++ b/Demo/Application/DemoDropInViewController.swift @@ -44,6 +44,7 @@ class DemoDropInViewController: DemoBaseViewController, DemoDropInViewDelegate { dropInRequest.paypalDisabled = DemoSettings.paypalDisabled dropInRequest.cardDisabled = ProcessInfo.processInfo.arguments.contains("-CardDisabled") + dropInRequest.cardLogosDisabled = ProcessInfo.processInfo.arguments.contains("-CardLogosDisabled") dropInRequest.shouldMaskSecurityCode = DemoSettings.maskSecurityCode dropInRequest.cardholderNameSetting = DemoSettings.cardholderNameSetting dropInRequest.vaultCard = DemoSettings.vaultCardSetting diff --git a/Demo/UITests/BraintreeDropIn_UITests.swift b/Demo/UITests/BraintreeDropIn_UITests.swift index a285eff6..e4342dea 100644 --- a/Demo/UITests/BraintreeDropIn_UITests.swift +++ b/Demo/UITests/BraintreeDropIn_UITests.swift @@ -180,6 +180,61 @@ class BraintreeDropIn_CardDisabled_UITests: XCTestCase { } } +class BraintreeDropIn_CardLogosDisabled_UITests: XCTestCase { + + var app: XCUIApplication! + + override func setUp() { + super.setUp() + continueAfterFailure = false + app = XCUIApplication() + app.launchArguments.append("-EnvironmentSandbox") + app.launchArguments.append("-TokenizationKey") + app.launchArguments.append("-CardLogosDisabled") + app.launch() + sleep(1) + waitForElementToBeHittable(app.buttons["Add Payment Method"]) + app.buttons["Add Payment Method"].tap() + } + + func testDropIn_cardLogosDisabledOption_hidesCardLogos() { + waitForElementToBeHittable(app.staticTexts["Credit or Debit Card"]) + app.staticTexts["Credit or Debit Card"].tap() + + let elementsQuery = app.scrollViews.otherElements + let cardLogoImages = elementsQuery.images.element.exists + + XCTAssertFalse(cardLogoImages) + } +} + +class BraintreeDropIn_CardLogosEnabled_UITests: XCTestCase { + + var app: XCUIApplication! + + override func setUp() { + super.setUp() + continueAfterFailure = false + app = XCUIApplication() + app.launchArguments.append("-EnvironmentSandbox") + app.launchArguments.append("-TokenizationKey") + app.launch() + sleep(1) + waitForElementToBeHittable(app.buttons["Add Payment Method"]) + app.buttons["Add Payment Method"].tap() + } + + func testDropIn_cardLogosEnabledOption_showsCardLogos() { + waitForElementToBeHittable(app.staticTexts["Credit or Debit Card"]) + app.staticTexts["Credit or Debit Card"].tap() + + let elementsQuery = app.scrollViews.otherElements + let cardLogoImages = elementsQuery.images.element.exists + + XCTAssertTrue(cardLogoImages) + } +} + class BraintreeDropIn_CardForm_RequestOptions_UITests: XCTestCase { var app: XCUIApplication! diff --git a/UnitTests/BTDropInRequestTests.m b/UnitTests/BTDropInRequestTests.m index be436f32..58518d46 100644 --- a/UnitTests/BTDropInRequestTests.m +++ b/UnitTests/BTDropInRequestTests.m @@ -45,6 +45,7 @@ - (void)test_copyProperties { originalRequest.paypalDisabled = YES; originalRequest.venmoDisabled = YES; originalRequest.cardDisabled = YES; + originalRequest.cardLogosDisabled = YES; originalRequest.threeDSecureRequest = threeDSecureRequest; originalRequest.cardholderNameSetting = BTFormFieldOptional; originalRequest.shouldMaskSecurityCode = YES; @@ -60,6 +61,7 @@ - (void)test_copyProperties { XCTAssertEqual(originalRequest.paypalDisabled, copiedRequest.paypalDisabled); XCTAssertEqual(originalRequest.venmoDisabled, copiedRequest.venmoDisabled); XCTAssertEqual(originalRequest.cardDisabled, copiedRequest.cardDisabled); + XCTAssertEqual(originalRequest.cardLogosDisabled, copiedRequest.cardLogosDisabled); XCTAssertEqual(originalRequest.cardholderNameSetting, copiedRequest.cardholderNameSetting); XCTAssertEqual(originalRequest.shouldMaskSecurityCode, copiedRequest.shouldMaskSecurityCode); XCTAssertEqual(originalRequest.vaultManager, copiedRequest.vaultManager);