@@ -53,10 +53,10 @@ public class CardClient: NSObject {
53
53
if result. status == " PAYER_ACTION_REQUIRED " ,
54
54
let urlString = result. links. first ( where: { $0. rel == " approve " } ) ? . href {
55
55
guard urlString. contains ( " helios " ) , let url = URL ( string: urlString) else {
56
- self . notifyVaultFailure ( with: CardError . threeDSecureURLError, completion: completion)
56
+ self . notify3dsVaultFailure ( with: CardError . threeDSecureURLError, completion: completion)
57
57
return
58
58
}
59
- analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:challenge-required " )
59
+ analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:auth- challenge-required " )
60
60
startVaultThreeDSecureChallenge ( url: url, setupTokenID: vaultRequest. setupTokenID, completion: completion)
61
61
} else {
62
62
let vaultResult = CardVaultResult ( setupTokenID: result. id, status: result. status, didAttemptThreeDSecureAuthentication: false )
@@ -99,7 +99,7 @@ public class CardClient: NSObject {
99
99
/// if it fails, `CardResult will be `nil` and `error` will describe the failure
100
100
public func approveOrder( request: CardRequest , completion: @escaping ( CardResult ? , CoreSDKError ? ) -> Void ) {
101
101
analyticsService = AnalyticsService ( coreConfig: config, orderID: request. orderID)
102
- analyticsService? . sendEvent ( " card-payments:3ds :started " )
102
+ analyticsService? . sendEvent ( " card-payments:approve-order :started " )
103
103
Task {
104
104
do {
105
105
let result = try await checkoutOrdersAPI. confirmPaymentSource ( cardRequest: request)
@@ -109,23 +109,19 @@ public class CardClient: NSObject {
109
109
guard getQueryStringParameter ( url: url, param: " flow " ) == " 3ds " ,
110
110
url. contains ( " helios " ) ,
111
111
let url = URL ( string: url) else {
112
- self . notifyCheckoutFailure ( with: CardError . threeDSecureURLError, completion: completion)
112
+ self . notify3dsCheckoutFailure ( with: CardError . threeDSecureURLError, completion: completion)
113
113
return
114
114
}
115
115
116
- analyticsService? . sendEvent ( " card-payments:3ds:confirm-payment-source: challenge-required " )
116
+ analyticsService? . sendEvent ( " card-payments:approve-order:auth- challenge-required " )
117
117
startThreeDSecureChallenge ( url: url, orderId: result. id, completion: completion)
118
118
} else {
119
- analyticsService? . sendEvent ( " card-payments:3ds:confirm-payment-source:succeeded " )
120
-
121
119
let cardResult = CardResult ( orderID: result. id, status: result. status, didAttemptThreeDSecureAuthentication: false )
122
120
notifyCheckoutSuccess ( for: cardResult, completion: completion)
123
121
}
124
122
} catch let error as CoreSDKError {
125
- analyticsService? . sendEvent ( " card-payments:3ds:confirm-payment-source:failed " )
126
123
notifyCheckoutFailure ( with: error, completion: completion)
127
124
} catch {
128
- analyticsService? . sendEvent ( " card-payments:3ds:confirm-payment-source:failed " )
129
125
notifyCheckoutFailure ( with: CardError . unknownError, completion: completion)
130
126
}
131
127
}
@@ -161,25 +157,25 @@ public class CardClient: NSObject {
161
157
context: self ,
162
158
sessionDidDisplay: { [ weak self] didDisplay in
163
159
if didDisplay {
164
- self ? . analyticsService? . sendEvent ( " card-payments:3ds: challenge-presentation:succeeded " )
160
+ self ? . analyticsService? . sendEvent ( " card-payments:approve-order:auth- challenge-presentation:succeeded " )
165
161
} else {
166
- self ? . analyticsService? . sendEvent ( " card-payments:3ds: challenge-presentation:failed " )
162
+ self ? . analyticsService? . sendEvent ( " card-payments:approve-order:auth- challenge-presentation:failed " )
167
163
}
168
164
} ,
169
165
sessionDidComplete: { _, error in
170
166
if let error = error {
171
167
switch error {
172
168
case ASWebAuthenticationSessionError . canceledLogin:
173
- self . notifyCheckoutCancelWithError ( with: CardError . threeDSecureCanceledError, completion: completion)
169
+ self . notify3dsCheckoutCancelWithError ( with: CardError . threeDSecureCanceledError, completion: completion)
174
170
return
175
171
default :
176
- self . notifyCheckoutFailure ( with: CardError . threeDSecureError ( error) , completion: completion)
172
+ self . notify3dsCheckoutFailure ( with: CardError . threeDSecureError ( error) , completion: completion)
177
173
return
178
174
}
179
175
}
180
176
181
177
let cardResult = CardResult ( orderID: orderId, status: nil , didAttemptThreeDSecureAuthentication: true )
182
- self . notifyCheckoutSuccess ( for: cardResult, completion: completion)
178
+ self . notify3dsCheckoutSuccess ( for: cardResult, completion: completion)
183
179
}
184
180
)
185
181
}
@@ -201,41 +197,51 @@ public class CardClient: NSObject {
201
197
sessionDidDisplay: { [ weak self] didDisplay in
202
198
if didDisplay {
203
199
// TODO: analytics for card vault
204
- self ? . analyticsService? . sendEvent ( " card-payments:3ds: challenge-presentation:succeeded " )
200
+ self ? . analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:auth- challenge-presentation:succeeded " )
205
201
} else {
206
- self ? . analyticsService? . sendEvent ( " card-payments:3ds: challenge-presentation:failed " )
202
+ self ? . analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:auth- challenge-presentation:failed " )
207
203
}
208
204
} ,
209
205
sessionDidComplete: { _, error in
210
206
if let error = error {
211
207
switch error {
212
208
case ASWebAuthenticationSessionError . canceledLogin:
213
- self . notifyVaultCancelWithError ( with: CardError . threeDSecureCanceledError, completion: completion)
209
+ self . notify3dsVaultCancelWithError ( with: CardError . threeDSecureCanceledError, completion: completion)
214
210
return
215
211
default :
216
- self . notifyVaultFailure ( with: CardError . threeDSecureError ( error) , completion: completion)
212
+ self . notify3dsVaultFailure ( with: CardError . threeDSecureError ( error) , completion: completion)
217
213
return
218
214
}
219
215
}
220
216
221
217
let cardVaultResult = CardVaultResult ( setupTokenID: setupTokenID, status: nil , didAttemptThreeDSecureAuthentication: true )
222
- self . notifyVaultSuccess ( for: cardVaultResult, completion: completion)
218
+ self . notify3dsVaultSuccess ( for: cardVaultResult, completion: completion)
223
219
}
224
220
)
225
221
}
226
222
227
223
private func notifyCheckoutSuccess( for result: CardResult , completion: ( CardResult ? , CoreSDKError ? ) -> Void ) {
228
- analyticsService? . sendEvent ( " card-payments:3ds:succeeded " )
224
+ analyticsService? . sendEvent ( " card-payments:approve-order:succeeded " )
225
+ completion ( result, nil )
226
+ }
227
+
228
+ private func notify3dsCheckoutSuccess( for result: CardResult , completion: ( CardResult ? , CoreSDKError ? ) -> Void ) {
229
+ analyticsService? . sendEvent ( " card-payments:approve-order:auth-challenge:succeeded " )
229
230
completion ( result, nil )
230
231
}
231
232
232
233
private func notifyCheckoutFailure( with error: CoreSDKError , completion: ( CardResult ? , CoreSDKError ? ) -> Void ) {
233
- analyticsService? . sendEvent ( " card-payments:3ds:failed " )
234
+ analyticsService? . sendEvent ( " card-payments:approve-order:failed " )
235
+ completion ( nil , error)
236
+ }
237
+
238
+ private func notify3dsCheckoutFailure( with error: CoreSDKError , completion: ( CardResult ? , CoreSDKError ? ) -> Void ) {
239
+ analyticsService? . sendEvent ( " card-payments:approve-order:auth-challenge:failed " )
234
240
completion ( nil , error)
235
241
}
236
242
237
- private func notifyCheckoutCancelWithError ( with error: CoreSDKError , completion: ( CardResult ? , CoreSDKError ? ) -> Void ) {
238
- analyticsService? . sendEvent ( " card-payments:3ds: challenge:user- canceled " )
243
+ private func notify3dsCheckoutCancelWithError ( with error: CoreSDKError , completion: ( CardResult ? , CoreSDKError ? ) -> Void ) {
244
+ analyticsService? . sendEvent ( " card-payments:approve-order:auth- challenge:canceled " )
239
245
completion ( nil , error)
240
246
}
241
247
@@ -244,13 +250,23 @@ public class CardClient: NSObject {
244
250
completion ( vaultResult, nil )
245
251
}
246
252
253
+ private func notify3dsVaultSuccess( for vaultResult: CardVaultResult , completion: ( CardVaultResult ? , CoreSDKError ? ) -> Void ) {
254
+ analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:auth-challenge:succeeded " )
255
+ completion ( vaultResult, nil )
256
+ }
257
+
247
258
private func notifyVaultFailure( with vaultError: CoreSDKError , completion: ( CardVaultResult ? , CoreSDKError ? ) -> Void ) {
248
259
analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:failed " )
249
260
completion ( nil , vaultError)
250
261
}
251
262
252
- private func notifyVaultCancelWithError( with vaultError: CoreSDKError , completion: ( CardVaultResult ? , CoreSDKError ? ) -> Void ) {
253
- analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:challenge:canceled " )
263
+ private func notify3dsVaultFailure( with vaultError: CoreSDKError , completion: ( CardVaultResult ? , CoreSDKError ? ) -> Void ) {
264
+ analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:auth-challenge:failed " )
265
+ completion ( nil , vaultError)
266
+ }
267
+
268
+ private func notify3dsVaultCancelWithError( with vaultError: CoreSDKError , completion: ( CardVaultResult ? , CoreSDKError ? ) -> Void ) {
269
+ analyticsService? . sendEvent ( " card-payments:vault-wo-purchase:auth-challenge:canceled " )
254
270
completion ( nil , vaultError)
255
271
}
256
272
}
0 commit comments