From d6cde54904de3c317c9fe4ea17f451f81c4cab33 Mon Sep 17 00:00:00 2001 From: Victoria Park Date: Wed, 6 Nov 2024 22:37:45 -0800 Subject: [PATCH] Simplify cancel errors --- Sources/CardPayments/CardClient.swift | 4 ++-- Sources/CardPayments/CardClientError.swift | 8 ++++---- Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift | 4 ++-- .../PayPalWebPayments/PayPalWebCheckoutClientError.swift | 8 ++++---- UnitTests/CardPaymentsTests/CardClient_Tests.swift | 8 ++++---- .../PayPalWebCheckoutClient_Tests.swift | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Sources/CardPayments/CardClient.swift b/Sources/CardPayments/CardClient.swift index ab042b1d..66ab9b2c 100644 --- a/Sources/CardPayments/CardClient.swift +++ b/Sources/CardPayments/CardClient.swift @@ -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) @@ -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) diff --git a/Sources/CardPayments/CardClientError.swift b/Sources/CardPayments/CardClientError.swift index d068833b..6c5f4206 100644 --- a/Sources/CardPayments/CardClientError.swift +++ b/Sources/CardPayments/CardClientError.swift @@ -39,7 +39,7 @@ enum CardClientError { case malformedDeeplinkURLError /// 10. Cancellation from 3DS verification - case threeDSCancellation + case canceledError } static let unknownError = CoreSDKError( @@ -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( diff --git a/Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift b/Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift index 4f1bde35..228424ed 100644 --- a/Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift +++ b/Sources/PayPalWebPayments/PayPalWebCheckoutClient.swift @@ -64,7 +64,7 @@ public class PayPalWebCheckoutClient: NSObject { switch error { case ASWebAuthenticationSessionError.canceledLogin: self.notifyCheckoutCancelWithError( - with: PayPalWebCheckoutClientError.payPalCancellationError, + with: PayPalWebCheckoutClientError.checkoutCanceled, completion: completion ) return @@ -153,7 +153,7 @@ public class PayPalWebCheckoutClient: NSObject { switch error { case ASWebAuthenticationSessionError.canceledLogin: self.notifyVaultCancelWithError( - with: PayPalWebCheckoutClientError.payPalVaultCancellationError, + with: PayPalWebCheckoutClientError.vaultCanceled, completion: completion ) return diff --git a/Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift b/Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift index 8fc0146c..48f32bb0 100644 --- a/Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift +++ b/Sources/PayPalWebPayments/PayPalWebCheckoutClientError.swift @@ -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" ) } diff --git a/UnitTests/CardPaymentsTests/CardClient_Tests.swift b/UnitTests/CardPaymentsTests/CardClient_Tests.swift index e23065c7..2985a174 100644 --- a/UnitTests/CardPaymentsTests/CardClient_Tests.swift +++ b/UnitTests/CardPaymentsTests/CardClient_Tests.swift @@ -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") } @@ -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") } diff --git a/UnitTests/PayPalWebPaymentsTests/PayPalWebCheckoutClient_Tests.swift b/UnitTests/PayPalWebPaymentsTests/PayPalWebCheckoutClient_Tests.swift index 6b43fa9b..12ca902b 100644 --- a/UnitTests/PayPalWebPaymentsTests/PayPalWebCheckoutClient_Tests.swift +++ b/UnitTests/PayPalWebPaymentsTests/PayPalWebCheckoutClient_Tests.swift @@ -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") } @@ -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") }