-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSupportedChannel.swift
More file actions
50 lines (45 loc) · 1.49 KB
/
Copy pathSupportedChannel.swift
File metadata and controls
50 lines (45 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import SwiftUI
import PaystackCore
/// A resolved payment channel that the SDK is willing to route to for the
/// current transaction. One entry per card option, plus one entry per
/// supported mobile money provider returned by `verifyAccessCode`.
enum SupportedChannel: Equatable, Identifiable {
case card
case mobileMoney(MobileMoneyChannel)
var id: String {
switch self {
case .card:
return "card"
case .mobileMoney(let channel):
return "mobile_money.\(channel.key)"
}
}
var displayTitle: String {
switch self {
case .card:
return "Card"
case .mobileMoney(let channel):
return channel.value
}
}
var image: Image {
switch self {
case .card:
return Image("cardLogo", bundle: .current)
case .mobileMoney(let channel):
return Self.image(forMobileMoneyKey: channel.key)
}
}
/// Maps known Paystack mobile money provider keys to a bundled logo.
/// Falls back to a generic SF Symbol when the SDK has no logo for the
/// provider yet — keeps the channel-selection screen renderable when a
/// future provider lights up via the allowlist.
private static func image(forMobileMoneyKey key: String) -> Image {
switch key.uppercased() {
case "MPESA":
return Image("kenyaSHLogo", bundle: .current)
default:
return Image(systemName: "creditcard")
}
}
}