Skip to content

Commit 55180da

Browse files
authored
fix: Add CARTES_BANCAIRES DSID Mapping (#60)
* Add CARTES_BANCAIRES and route MAESTRO to MASTERCARD * Review feedback * Correct capitalization * Clean up switch
1 parent 9ead777 commit 55180da

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

Sources/Primer3DS/Classes/Primer3DSStructures.swift

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ public enum Environment: String, Codable {
1313

1414
public enum DirectoryServerNetwork: String {
1515
case masterCard = "MASTERCARD"
16+
case maestro = "MAESTRO"
1617
case visa = "VISA"
1718
case amex = "AMEX"
1819
case jcb = "JCB"
1920
case diners = "DINERS_CLUB"
2021
case discover = "DISCOVER"
2122
case unionpay = "UNIONPAY"
23+
case cartesBancaires = "CARTES_BANCAIRES"
2224
case unknown = "UNKNOWN"
2325

2426
var directoryServerId: String? {
2527
switch self {
2628
case .visa:
2729
return DsRidValues.visa
28-
case .masterCard:
30+
case .masterCard, .maestro:
2931
return DsRidValues.mastercard
3032
case .amex:
3133
return DsRidValues.amex
@@ -35,6 +37,8 @@ public enum DirectoryServerNetwork: String {
3537
return DsRidValues.diners
3638
case .unionpay:
3739
return DsRidValues.union
40+
case .cartesBancaires:
41+
return DsRidValues.cartesBancaires
3842
case .unknown:
3943
return nil
4044
}
@@ -45,72 +49,63 @@ public enum DirectoryServerNetwork: String {
4549
}
4650
}
4751

48-
@objc internal class SDKAuthData: NSObject, Primer3DSSDKGeneratedAuthData {
49-
52+
@objc final class SDKAuthData: NSObject, Primer3DSSDKGeneratedAuthData {
5053
var sdkAppId: String
5154
var sdkTransactionId: String
5255
var sdkTimeout: Int
5356
var sdkEncData: String
5457
var sdkEphemPubKey: String
5558
var sdkReferenceNumber: String
56-
59+
5760
init(sdkAppId: String, sdkTransactionId: String, sdkTimeout: Int, sdkEncData: String, sdkEphemPubKey: String, sdkReferenceNumber: String) {
5861
self.sdkAppId = sdkAppId
5962
self.sdkTransactionId = sdkTransactionId
6063
self.sdkTimeout = sdkTimeout
6164
self.sdkEncData = sdkEncData
6265
self.sdkEphemPubKey = sdkEphemPubKey
63-
self.sdkEphemPubKey = sdkEphemPubKey
6466
self.sdkReferenceNumber = sdkReferenceNumber
6567
super.init()
6668
}
6769
}
6870

6971
@objc public class SDKAuthResult: NSObject {
70-
7172
static let sdkMaxTimeout: Int = 10
72-
73+
7374
public var authData: Primer3DSSDKGeneratedAuthData
7475
public var maxSupportedThreeDsProtocolVersion: String
75-
76+
7677
init(authData: Primer3DSSDKGeneratedAuthData, maxSupportedThreeDsProtocolVersion: String) {
7778
self.authData = authData
7879
self.maxSupportedThreeDsProtocolVersion = maxSupportedThreeDsProtocolVersion
7980
super.init()
8081
}
8182
}
8283

83-
@objc internal class AuthCompletion: NSObject, Primer3DSCompletion {
84+
@objc class AuthCompletion: NSObject, Primer3DSCompletion {
8485
public let sdkTransactionId: String
8586
public let transactionStatus: String
86-
87+
8788
init(sdkTransactionId: String, transactionStatus: String) {
8889
self.sdkTransactionId = sdkTransactionId
8990
self.transactionStatus = transactionStatus
9091
}
9192
}
9293

93-
internal enum AuthenticationStatus: String {
94+
enum AuthenticationStatus: String {
9495
case y, a, n, u, e
95-
96+
9697
init(rawValue: String) {
9798
switch rawValue.lowercased() {
98-
case "y":
99-
self = AuthenticationStatus.y
100-
case "a":
101-
self = AuthenticationStatus.a
102-
case "n":
103-
self = AuthenticationStatus.n
104-
case "u":
105-
self = AuthenticationStatus.u
106-
case "e":
107-
self = AuthenticationStatus.e
108-
default:
109-
self = AuthenticationStatus.e
99+
case "y": self = .y
100+
case "a": self = .a
101+
case "n": self = .n
102+
case "u": self = .u
103+
case "e": self = .e
104+
default: self = .e
110105
}
111106
}
112-
113-
var `description`: String {
107+
108+
var description: String {
114109
switch self {
115110
case .y:
116111
return "Authentication successful"
@@ -124,7 +119,7 @@ internal enum AuthenticationStatus: String {
124119
return "Error"
125120
}
126121
}
127-
122+
128123
var recommendation: AuthenticationRecommendation {
129124
switch self {
130125
case .y,
@@ -139,7 +134,6 @@ internal enum AuthenticationStatus: String {
139134
}
140135
}
141136

142-
internal enum AuthenticationRecommendation {
137+
enum AuthenticationRecommendation {
143138
case proceed, stop, merchantDecision
144139
}
145-

0 commit comments

Comments
 (0)