braintree / braintree_ios

Braintree SDK for iOS
https://developer.paypal.com/braintree/docs/start/hello-client/ios/v5
MIT License
557 stars 293 forks source link

PayPal Vault Crash using v6 #1368

Closed tiagoalexbastos closed 3 weeks ago

tiagoalexbastos commented 1 month ago

Braintree SDK Version

6.23.0

Environment

Sandbox

Xcode Version

Xcode 15.4

OS Version & Device

iPhone 15 Pro - 17.5

Integration type

Swfit Package Manager

Development Processor

Apple Silicon (M-series chips)

Describe the bug

Hey!

While bumping the SDK to the latest version and converting our existing code (that was deprecated), to the new iOS Vault API as described here (https://developer.paypal.com/braintree/docs/guides/paypal/vault/ios/v6/) we are getting crashes on the tokenise function.

I've tried the 2 versions of the tokenise function, the async and the completionHandler version of it, and both versions I can replicate the same crash.

For reference, the deprecated APIs I mention we were using (and that were working fine, without any crashes) are:

To these deprecated APIs we pass the exact same parameters

This is the crash that we are observing: Thread 1: "-[BraintreeCore.BTJSON asPayPalCreditFinancing]: unrecognized selector sent to instance 0x600000ded4d0"

image

image

This is the exact code that we are using:

func presentNativeCheckoutFlow(
        clientToken: String,
        source: Source
    ) async throws -> CheckoutResponse {
        guard let apiClient = BTAPIClient(authorization: clientToken) else {
            throw BraintreeDropInError.noClient
        }

        let payPalNativeCheckoutClient = BTPayPalClient(apiClient: apiClient)
        let request = BraintreePayPal.BTPayPalVaultRequest()

        do {
            let checkoutResult = try await payPalNativeCheckoutClient.tokenize(request)
            remoteLogger.logBreadcrumb(with: BraintreeBreadcrumbs.nativeCheckoutFlowSucceeded)
            logSuccess(source: source.loggingIdentifier)

            return CheckoutResponse(
                nonce: checkoutResult.nonce,
                countryCode: checkoutResult.billingAddress?.countryCodeAlpha2
            )

        } catch {
            if let error = error as? CustomNSError {
                logCustomError(error, source: source.loggingIdentifier)
                guard error.errorCode == PayPalNativeErrorCode.cancelled.rawValue else {
                    throw BraintreeDropInError.unknown
                }
                throw BraintreeDropInError.cancelled
            } else {
                throw BraintreeDropInError.unknown
            }
        }
    }

To reproduce

Try to vault a PayPal account using: https://developer.paypal.com/braintree/docs/guides/paypal/vault/ios/v6/

Expected behavior

App should not crash when tokenising with Vault using the new APIs.

Screenshots

No response

jaxdesmarais commented 1 month ago

Hey @tiagoalexbastos -

Thanks for reaching out and sorry to hear that you are running into a crash when attempting to move to the Vault flow. I have attempted to replicate the crash using the code you sent over in our Demo app but the flow is completing without issue.

Are you able to either send a small sample app where we can replicate the error or create a fork from our demo app and send a branch over where we can replicate this crash? From there we'd be happy to troubleshoot further and help you get a resolution for this crash.

jaxdesmarais commented 3 weeks ago

Closing due to inactivity, please feel free to respond with the above details and we'd be happy to reopen this to troubleshoot further.