Tapping "Cancel and return to store" while using PayPalWebCheckoutClient returns success instead of cancellation error in Vault flow
PayPal SDK Version
1.5.0, 2.0.0
Environment
Sandbox
Xcode Version
26.0.1
OS Version & Device
iOS 18.0, iOS 26.0 - every tested device
Integration type
Swfit Package Manager
Development Processor
Apple Silicon (M-series chips)
Describe the bug
After launching the PayPalWebCheckoutClient with a PayPalVaultRequest, a web view is presented.
The web view provides two cancellation options:
- "X" Button in the web view navigation bar - works as expected. When tapped, the
PayPalWebCheckoutClientthrows back thePayPalError.vaultCanceledError - The "Cancel and return to store" button within the web view - Tapping it returns a success event with a
PayPalVaultResultthat contains thetokenIDandapprovalSessionID
The result contains the same data as if the flow was successful, however the token ID is not valid as the Vault flow was never completed and any calls to create payment token will fail.
As of right now it's not possible to detect the cancellation if the user cancels using the second approach as the web view will always return a success.
To reproduce
Option 1: Using the provided Demo app for the paypal-ios-sdk.
- Tap on PayPal Vaulting -> Create Setup Token -> Vault PayPal
- In the presented WebView tap on "Cancel and return to store"
- Observe the Status APPROVED
- Tap on Create Payment Token
- Observe the error as the token couldn't be generated as the Vault flow was never completed.
Option 2: Launch PayPal Vault flow:
let vaultRequest = PayPalVaultRequest(setupTokenID: "Your token ID")
let payPalConfig = CoreConfig(clientID: "Your client ID", environment: .sandbox)
let payPalClient = PayPalWebCheckoutClient(config: payPalConfig)
do {
let vaultResult = try await payPalClient.vault(vaultRequest)
print(vaultResult)
} catch {
print(error)
}
When tapping on the "Cancel and return to store" in the presented web view it will print the vaultResult with the tokenID and approvalSessionID.
Expected behavior
Tapping "Cancel and return to store" should return the same PayPalError.vaultCanceledError that is returned when tapping the "X" button in the WebView navigation bar.
Screenshots
Hi @dg-pd thanks for this detailed bug report. I am able to reproduce this issue on my end. We'll work on a fix and notify you once it's been released.
Hi @dg-pd this has been fixed in version 2.0.1.
The release is only available via Swift Package Manager at the moment. We ran into some issues trying to get the release into CocoaPods, we're hoping to resolve these issues soon.
Feel free to re-open if you're still experiencing issues.