Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Cancel Errors #296

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Add `vault(vaultRequest:completion(PayPalVaultResult?, Error?) -> Void)` to `PayPalWebCheckoutClient`
* Add `start(request:) async throws -> PayPalCheckoutResult`
* Add `vault(vaultRequest:) async throws -> PayPalVaultResult`
* Add `.checkoutCanceled` and `.vaultCanceled` to `PayPalWebCheckoutClientError`
* CardPayments
* Replace delegate pattern with completion handlers and Swift concurrency
* Remove `CardDelegate` and `CardVaultDelegate`
Expand All @@ -22,7 +23,8 @@
* Add `approveOrder(request:completion:(CardResult?, Error?) -> Void)` to `CardClient`
* Add `vault(request:completion:(CardVaultResult?, Error?) -> Void)` to `CardClient`
* Add `approveOrder(request:) async throws -> CardResult`
* Add `vault(vaultRequest:) async throws -> CardVaultResult`
* Add `vault(vaultRequest:) async throws -> CardVaultResult`
* Add `.threeDSecureCanceled` to `CardClientError`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, these are a rename vs an add. In case a merchant expects the old ones to still be there

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to show that a new async/await function was added.
I think rename might confuse them because it really is a new function.

* PayPalWebPayments
* Deprecate `PayPalVaultRequest(url:setupTokenID:)`
* Add `PayPalVaultRequest(setupTokenID:)`
Expand Down
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.threeDSecureCanceled, 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.threeDSecureCanceled, 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 threeDSCancellationError
}

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 threeDSecureCanceled = CoreSDKError(
code: Code.threeDSCancellationError.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.threeDSCancellationError.rawValue)
XCTAssertEqual(error.localizedDescription, CardClientError.threeDSecureCanceled.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.threeDSecureCanceled.code)
XCTAssertEqual(error.localizedDescription, CardClientError.threeDSecureCanceled.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
Loading