Skip to content

Commit

Permalink
Simplify cancel errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KunJeongPark committed Nov 7, 2024
1 parent 6030da7 commit d6cde54
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Sources/CardPayments/CardClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public class CardClient: NSObject {
if let error = error {
switch error {
case ASWebAuthenticationSessionError.canceledLogin:
self.notifyCheckoutCancelWithError(with: CardClientError.threeDSecureCancellation, completion: completion)
self.notifyCheckoutCancelWithError(with: CardClientError.canceled, completion: completion)
return
default:
self.notifyCheckoutFailure(with: CardClientError.threeDSecureError(error), completion: completion)
Expand Down Expand Up @@ -206,7 +206,7 @@ public class CardClient: NSObject {
if let error = error {
switch error {
case ASWebAuthenticationSessionError.canceledLogin:
self.notifyVaultCancelWithError(with: CardClientError.threeDSecureCancellation, completion: completion)
self.notifyVaultCancelWithError(with: CardClientError.canceled, completion: completion)
return
default:
self.notifyVaultFailure(with: CardClientError.threeDSecureError(error), completion: completion)
Expand Down
8 changes: 4 additions & 4 deletions Sources/CardPayments/CardClientError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum CardClientError {
case malformedDeeplinkURLError

/// 10. Cancellation from 3DS verification
case threeDSCancellation
case canceledError
}

static let unknownError = CoreSDKError(
Expand Down Expand Up @@ -68,10 +68,10 @@ enum CardClientError {
errorDescription: "An invalid 3DS URL was returned. Contact developer.paypal.com/support."
)

static let threeDSecureCancellation = CoreSDKError(
code: Code.threeDSCancellation.rawValue,
static let canceled = CoreSDKError(
code: Code.canceledError.rawValue,
domain: domain,
errorDescription: "3DS verification has been cancelled by the user."
errorDescription: "3DS verification has been canceled by the user."
)

static let noVaultTokenDataError = CoreSDKError(
Expand Down
4 changes: 2 additions & 2 deletions Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class PayPalWebCheckoutClient: NSObject {
switch error {
case ASWebAuthenticationSessionError.canceledLogin:
self.notifyCheckoutCancelWithError(
with: PayPalWebCheckoutClientError.payPalCancellationError,
with: PayPalWebCheckoutClientError.checkoutCanceled,
completion: completion
)
return
Expand Down Expand Up @@ -153,7 +153,7 @@ public class PayPalWebCheckoutClient: NSObject {
switch error {
case ASWebAuthenticationSessionError.canceledLogin:
self.notifyVaultCancelWithError(
with: PayPalWebCheckoutClientError.payPalVaultCancellationError,
with: PayPalWebCheckoutClientError.vaultCanceled,
completion: completion
)
return
Expand Down
8 changes: 4 additions & 4 deletions Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ enum PayPalWebCheckoutClientError {
errorDescription: "Error parsing PayPal vault response"
)

static let payPalCancellationError = CoreSDKError(
static let checkoutCanceled = CoreSDKError(
code: Code.payPalCancellationError.rawValue,
domain: domain,
errorDescription: "PayPal checkout has been cancelled by the user"
errorDescription: "PayPal checkout has been canceled by the user"
)

static let payPalVaultCancellationError = CoreSDKError(
static let vaultCanceled = CoreSDKError(
code: Code.payPalVaultCancellationError.rawValue,
domain: domain,
errorDescription: "PayPal vault has been cancelled by the user"
errorDescription: "PayPal vault has been canceled by the user"
)
}
8 changes: 4 additions & 4 deletions UnitTests/CardPaymentsTests/CardClient_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ class CardClient_Tests: XCTestCase {
XCTAssertNil(result)
if let error = error as? CoreSDKError {
XCTAssertEqual(error.domain, CardClientError.domain)
XCTAssertEqual(error.code, CardClientError.Code.threeDSCancellation.rawValue)
XCTAssertEqual(error.localizedDescription, CardClientError.threeDSecureCancellation.localizedDescription)
XCTAssertEqual(error.code, CardClientError.Code.canceledError.rawValue)
XCTAssertEqual(error.localizedDescription, CardClientError.canceled.localizedDescription)
} else {
XCTFail("Expected error to be of type CoreSDKError")
}
Expand Down Expand Up @@ -361,8 +361,8 @@ class CardClient_Tests: XCTestCase {
XCTAssertNil(result)
if let error = error as? CoreSDKError {
XCTAssertEqual(error.domain, CardClientError.domain)
XCTAssertEqual(error.code, CardClientError.threeDSecureCancellation.code)
XCTAssertEqual(error.localizedDescription, CardClientError.threeDSecureCancellation.localizedDescription)
XCTAssertEqual(error.code, CardClientError.canceled.code)
XCTAssertEqual(error.localizedDescription, CardClientError.canceled.localizedDescription)
} else {
XCTFail("Expected error to be of type CoreSDKError")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class PayPalClient_Tests: XCTestCase {
if let error = error as? CoreSDKError {
XCTAssertEqual(error.domain, PayPalWebCheckoutClientError.domain)
XCTAssertEqual(error.code, PayPalWebCheckoutClientError.Code.payPalVaultCancellationError.rawValue)
XCTAssertEqual(error.localizedDescription, "PayPal vault has been cancelled by the user")
XCTAssertEqual(error.localizedDescription, "PayPal vault has been canceled by the user")
} else {
XCTFail("Expected error to be of type CoreSDKError")
}
Expand Down Expand Up @@ -159,8 +159,8 @@ class PayPalClient_Tests: XCTestCase {
XCTAssertNil(result)
if let error = error as? CoreSDKError {
XCTAssertEqual(error.domain, PayPalWebCheckoutClientError.domain)
XCTAssertEqual(error.code, PayPalWebCheckoutClientError.payPalCancellationError.code)
XCTAssertEqual(error.localizedDescription, PayPalWebCheckoutClientError.payPalCancellationError.localizedDescription)
XCTAssertEqual(error.code, PayPalWebCheckoutClientError.checkoutCanceled.code)
XCTAssertEqual(error.localizedDescription, PayPalWebCheckoutClientError.checkoutCanceled.localizedDescription)
} else {
XCTFail("Expected error to be of type CoreSDKError")
}
Expand Down

0 comments on commit d6cde54

Please sign in to comment.