Skip to content

Commit

Permalink
Moved field visibility check into an extension method
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-SD committed Oct 2, 2023
1 parent e714a16 commit 0647667
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions ios/Classes/utils/ConfigurationMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class ConfigurationMapper {
allowPreselectedPaymentView: dropInConfigurationDTO.showPreselectedStoredPaymentMethod ?? false)

if let cardsConfigurationDTO = dropInConfigurationDTO.cardsConfigurationDTO {
let koreanAuthenticationMode = determineFieldVisibility(fieldVisibility: cardsConfigurationDTO.kcpFieldVisibility)
let socialSecurityNumberMode = determineFieldVisibility(fieldVisibility: cardsConfigurationDTO.socialSecurityNumberFieldVisibility)
let koreanAuthenticationMode = cardsConfigurationDTO.kcpFieldVisibility.toCardFieldVisibility()
let socialSecurityNumberMode = cardsConfigurationDTO.socialSecurityNumberFieldVisibility.toCardFieldVisibility()
let storedCardConfiguration = createStoredCardConfiguration(showCvcForStoredCard: cardsConfigurationDTO.showCvcForStoredCard)
let allowedCardTypes = determineAllowedCardTypes(cardTypes: cardsConfigurationDTO.supportedCardTypes)
let billingAddressConfiguration = determineBillingAddressConfiguration(addressMode: cardsConfigurationDTO.addressMode)
Expand Down Expand Up @@ -40,15 +40,6 @@ class ConfigurationMapper {
return dropInConfiguration
}

private func determineFieldVisibility(fieldVisibility: FieldVisibility) -> CardComponent.FieldVisibility {
switch (fieldVisibility) {
case .show:
return .show
case .hide:
return .hide
}
}

private func createStoredCardConfiguration(showCvcForStoredCard: Bool?) -> StoredCardConfiguration {
var storedCardConfiguration = StoredCardConfiguration()
storedCardConfiguration.showsSecurityCodeField = showCvcForStoredCard ?? false
Expand Down Expand Up @@ -99,3 +90,16 @@ class ConfigurationMapper {
merchantIdentifier: applePayConfigurationDTO.merchantId)
}
}


extension FieldVisibility {

func toCardFieldVisibility() -> CardComponent.FieldVisibility {
switch self {
case .show:
return .show
case .hide:
return .hide
}
}
}

0 comments on commit 0647667

Please sign in to comment.