Skip to content

Commit

Permalink
Steven PR feedback: separate 3ds success/fail events
Browse files Browse the repository at this point in the history
  • Loading branch information
KunJeongPark committed Dec 6, 2024
1 parent a11d283 commit 182cd0c
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions Sources/CardPayments/CardClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ public class CardClient: NSObject {
self.notifyCheckoutCancelWithError(with: CardError.threeDSecureCanceledError, completion: completion)
return
default:
self.notifyCheckoutFailure(with: CardError.threeDSecureError(error), completion: completion)
self.notifyCheckout3dsFailure(with: CardError.threeDSecureError(error), completion: completion)
return
}
}

let cardResult = CardResult(orderID: orderId, status: nil, didAttemptThreeDSecureAuthentication: true)
self.notifyCheckoutSuccess(for: cardResult, completion: completion)
self.notifyCheckout3dsSuccess(for: cardResult, completion: completion)
}
)
}
Expand Down Expand Up @@ -209,13 +209,13 @@ public class CardClient: NSObject {
self.notifyVaultCancelWithError(with: CardError.threeDSecureCanceledError, completion: completion)
return
default:
self.notifyVaultFailure(with: CardError.threeDSecureError(error), completion: completion)
self.notifyVault3dsFailure(with: CardError.threeDSecureError(error), completion: completion)
return
}
}

let cardVaultResult = CardVaultResult(setupTokenID: setupTokenID, status: nil, didAttemptThreeDSecureAuthentication: true)
self.notifyVaultSuccess(for: cardVaultResult, completion: completion)
self.notifyVault3dsSuccess(for: cardVaultResult, completion: completion)
}
)
}
Expand All @@ -225,11 +225,21 @@ public class CardClient: NSObject {
completion(result, nil)
}

private func notifyCheckout3dsSuccess(for result: CardResult, completion: (CardResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:approve-order:auth-challenge:succeeded")
completion(result, nil)
}

private func notifyCheckoutFailure(with error: CoreSDKError, completion: (CardResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:approve-order:failed")
completion(nil, error)
}

private func notifyCheckout3dsFailure(with error: CoreSDKError, completion: (CardResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:approve-order:auth-challenge:failed")
completion(nil, error)
}

private func notifyCheckoutCancelWithError(with error: CoreSDKError, completion: (CardResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:approve-order:auth-challenge:canceled")
completion(nil, error)
Expand All @@ -240,11 +250,21 @@ public class CardClient: NSObject {
completion(vaultResult, nil)
}

private func notifyVault3dsSuccess(for vaultResult: CardVaultResult, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:vault:auth-challenge:succeeded")
completion(vaultResult, nil)
}

private func notifyVaultFailure(with vaultError: CoreSDKError, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:vault:failed")
completion(nil, vaultError)
}

private func notifyVault3dsFailure(with vaultError: CoreSDKError, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:vault:auth-challenge:failed")
completion(nil, vaultError)
}

private func notifyVaultCancelWithError(with vaultError: CoreSDKError, completion: (CardVaultResult?, CoreSDKError?) -> Void) {
analyticsService?.sendEvent("card-payments:vault:auth-challenge:canceled")
completion(nil, vaultError)
Expand Down

0 comments on commit 182cd0c

Please sign in to comment.