Skip to content

Commit

Permalink
add changes for cancellation helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
KunJeongPark committed Nov 13, 2024
1 parent 7e99123 commit 51daa8e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions v2_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ Version 2.0-beta of the SDK transitions from the delgate-based flows to completi
### Key Changes

### Important Change: Cancellation Handling
In v2.0-beta, cancellations (e.g., 3DS cancellations, PayPal web flow cancellations) are now returned as errors rather than as separate delegate methods.
In v2.0-beta, cancellations (e.g., 3DS cancellations, PayPal web flow cancellations) are now returned as errors rather than as separate delegate methods. There are new helper methods, static functions, to help you discern threeDSecure cancellation errors and PayPal web flow cancellation errors.
- `CardError.threeDSecureCanceled(Error)` will return true for user cancellation during 3DS verification during card payment or card vaulting flows.
- `PayPalError.isCheckoutCaceled(Error)` will return true for user cancellation during PayPalWebCheckout session.
- `PayPalError.isVaultCanceled(Error)` will return true for user cancellation during PayPal vault session.

### CardClient Changes

Expand Down Expand Up @@ -38,9 +41,14 @@ class MyViewController {
let cardClient = CardClient(config: config)
cardClient.approveOrder(request: cardRequest) { [weak self] result, error in
if let error = error {
// handle error
// if threeDSecure is canceled by user
if CardError.isThreeDSecureCanceled(error) {
// handle cancel error
} else {
// handle other errors
}
return
}
}
if let result = result {
// handle success
}
Expand Down Expand Up @@ -79,7 +87,12 @@ class MyViewController {
let payPalClient = PayPalWebCheckoutClient(config: config)
payPalClient.start(request: paypalRequest) { [weak self] result, error in
if let error = error {
// handle error
// if PayPal webflow is canceled by user
if PayPalError.isCheckoutCanceled(error) {
// handle cancel error
} else {
// handle all other errors
}
return
}
if let result = result {
Expand Down

0 comments on commit 51daa8e

Please sign in to comment.