fix(payment): move detectedBrandLogo computed property into correct scope inside PaymentCardView
This commit is contained in:
@@ -928,46 +928,6 @@ struct CardSelectionSheet: View {
|
||||
_selectedCardId = State(initialValue: savedCards.first(where: { $0.isDefault })?.id ?? savedCards.first?.id)
|
||||
}
|
||||
|
||||
private var detectedBrandLogo: String? {
|
||||
let clean = cardNumber.filter(\.isNumber)
|
||||
guard !clean.isEmpty else { return nil }
|
||||
|
||||
// Sodexo
|
||||
if clean.hasPrefix("506766") || clean.hasPrefix("603389") {
|
||||
return "sodexo_logo"
|
||||
}
|
||||
|
||||
// Alelo
|
||||
if clean.hasPrefix("5067") || clean.hasPrefix("5078") || clean.hasPrefix("6278") || clean.hasPrefix("6367") {
|
||||
return "alelocard_logo"
|
||||
}
|
||||
|
||||
// Hipercard
|
||||
if clean.hasPrefix("3841") || clean.hasPrefix("606282") || clean.hasPrefix("637095") || clean.hasPrefix("637568") {
|
||||
return "hipercard_logo"
|
||||
}
|
||||
|
||||
// Visa
|
||||
if clean.hasPrefix("4") {
|
||||
return "visacard_logo"
|
||||
}
|
||||
|
||||
// Mastercard
|
||||
if (51...55).contains(Int(clean.prefix(2)) ?? 0) {
|
||||
return "mastercard_logo"
|
||||
}
|
||||
if let prefix4 = Int(clean.prefix(4)), (2221...2720).contains(prefix4) {
|
||||
return "mastercard_logo"
|
||||
}
|
||||
|
||||
// Amex
|
||||
if clean.hasPrefix("34") || clean.hasPrefix("37") {
|
||||
return "amexcard_logo"
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
// Header
|
||||
@@ -1108,6 +1068,46 @@ struct PaymentCardView: View {
|
||||
@State var nickname = ""
|
||||
@State var isSubmitting = false
|
||||
|
||||
private var detectedBrandLogo: String? {
|
||||
let clean = cardNumber.filter(\.isNumber)
|
||||
guard !clean.isEmpty else { return nil }
|
||||
|
||||
// Sodexo
|
||||
if clean.hasPrefix("506766") || clean.hasPrefix("603389") {
|
||||
return "sodexo_logo"
|
||||
}
|
||||
|
||||
// Alelo
|
||||
if clean.hasPrefix("5067") || clean.hasPrefix("5078") || clean.hasPrefix("6278") || clean.hasPrefix("6367") {
|
||||
return "alelocard_logo"
|
||||
}
|
||||
|
||||
// Hipercard
|
||||
if clean.hasPrefix("3841") || clean.hasPrefix("606282") || clean.hasPrefix("637095") || clean.hasPrefix("637568") {
|
||||
return "hipercard_logo"
|
||||
}
|
||||
|
||||
// Visa
|
||||
if clean.hasPrefix("4") {
|
||||
return "visacard_logo"
|
||||
}
|
||||
|
||||
// Mastercard
|
||||
if (51...55).contains(Int(clean.prefix(2)) ?? 0) {
|
||||
return "mastercard_logo"
|
||||
}
|
||||
if let prefix4 = Int(clean.prefix(4)), (2221...2720).contains(prefix4) {
|
||||
return "mastercard_logo"
|
||||
}
|
||||
|
||||
// Amex
|
||||
if clean.hasPrefix("34") || clean.hasPrefix("37") {
|
||||
return "amexcard_logo"
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
init(context: CardPaymentContext, appState: Binding<AppState>, onOrderCreated: @escaping (String, String?) -> Void) {
|
||||
self.context = context
|
||||
self._appState = appState
|
||||
|
||||
Reference in New Issue
Block a user