iOS-SDK icon indicating copy to clipboard operation
iOS-SDK copied to clipboard

Tapping "Cancel and return to store" while using PayPalWebCheckoutClient returns success instead of cancellation error in Vault flow

Open dg-pd opened this issue 2 months ago • 1 comments

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 PayPalWebCheckoutClient throws back the PayPalError.vaultCanceledError
  • The "Cancel and return to store" button within the web view - Tapping it returns a success event with a PayPalVaultResult that contains the tokenID and approvalSessionID

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.

  1. Tap on PayPal Vaulting -> Create Setup Token -> Vault PayPal
  2. In the presented WebView tap on "Cancel and return to store"
  3. Observe the Status APPROVED
  4. Tap on Create Payment Token
  5. 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

Image Image

dg-pd avatar Oct 22 '25 09:10 dg-pd

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.

sshropshire avatar Oct 22 '25 15:10 sshropshire

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.

sshropshire avatar Nov 03 '25 22:11 sshropshire