Skip to content

Migration paypal v5: PayPalPaymentAuthResult - NoResult  #1184

@javier-28

Description

@javier-28

Braintree SDK Version

5.0

Environment

Sandbox

Android Version & Device

Pixel 4 XL API 34

Braintree dependencies

com.braintreepayments.api:paypal

Describe the bug

I am in the process of updating the PayPal library to version 5.0. I am founding the following issue:

The WebView is displayed, and we can authenticate on the PayPal platform. You can select the payment method and press continue.
The deeplink opens, and it redirects back to the app, but the success case is not reached. The result of the method is PayPalPaymentAuthResult.NoResult.

I don't understand why it's always reaching this scenario.

I would like to know at least what situations cause the result of the payPalLauncher.handleReturnToApp() function to be PayPalPaymentAuthResult.NoResult
so I can follow that thread and review the implementation.

The project is a React native application with a Native module for braintree payments

To reproduce

I have been able to reproduce it in two different ways.

The first one by launching a new activity from the native RN module, and the second by implementing the PayPal flow within an RN module.

The fact that I can reproduce the issue from two different scenarios makes me think that the problem might be caused by some external factor that I am not seeing.
I can provide the full code for both scenarios if you think it’s necessary.

        payPalClient.createPaymentAuthRequest(reCurrentActivity!!, request) { paymentAuthRequest ->
            when (paymentAuthRequest) {
                is PayPalPaymentAuthRequest.ReadyToLaunch -> {
                    val pendingRequest = payPalLauncher.launch(reCurrentActivity!!, paymentAuthRequest)
                    when (pendingRequest) {
                        is PayPalPendingRequest.Started -> {
                            pendingString = pendingRequest.pendingRequestString
                        }

                        is PayPalPendingRequest.Failure -> {
                            mPromise.reject("BraintreeSDK Error", pendingRequest.error.message)
                        }
                    }
                }

                is PayPalPaymentAuthRequest.Failure -> {
                    mPromise.reject("BraintreeSDK Error",paymentAuthRequest.error.message)

                }
            }
        }


    private fun handleReturnToApp(intent: Intent) {
        // fetch stored PayPalPendingRequest.Success
        if(this::pendingString.isInitialized){
            when (val paymentAuthResult = payPalLauncher.handleReturnToApp(PayPalPendingRequest.Started(pendingString), intent)) {
                is PayPalPaymentAuthResult.Success -> {
                    completePayPalFlow(paymentAuthResult)
                    // clear stored PayPalPendingRequest.Success
                }
                is PayPalPaymentAuthResult.NoResult -> {
                    // user returned to app without completing PayPal flow, handle accordingly
                    mPromise.reject("BraintreeSDK Error","NO RESULT")

                }
                is PayPalPaymentAuthResult.Failure ->  {

                    mPromise.reject("BraintreeSDK Error", paymentAuthResult.error.message)
                    // handle error case
                }
            }
        }
    }

Expected behavior

Enter the Success case of PayPalPaymentAuthResult.

Screenshots

paypalAndroidFlow.mov

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions