braintree / braintree_android

Braintree SDK for Android
https://developer.paypal.com/braintree/docs/start/hello-client/android/v4
MIT License
409 stars 235 forks source link

Paypal Browser stuck in the last step #745

Closed caijunjieNick closed 1 year ago

caijunjieNick commented 1 year ago

Braintree SDK Version

4.31.0

Environment

Production

Android Version & Device

No response

Braintree dependencies

implementation 'com.braintreepayments.api:paypal:4.31.0' implementation 'com.braintreepayments.api:paypal-data-collector:4.31.0'

Describe the bug

After entering the account credentials, I reach the final payment page. However, when I click the button, it shows "One more step" and stays stuck there. The payment interface doesn't disappear.

To reproduce

private void startPaypal(String token) { braintreeClient = new BraintreeClient(requireContext(), token); payPalClient = new PayPalClient(requireActivity(), braintreeClient); payPalClient.setListener(this); payPalDataCollector = new PayPalDataCollector(braintreeClient); collectDeviceData(); myTokenizePayPalAccountWithCheckoutMethod(); } i add paypallistener to the fragment

Expected behavior

The payment interface should disappear and the result should be returned via the payment method listener to the method onPayPalSuccess

Screenshots

MicrosoftTeams-image

caijunjieNick commented 1 year ago

i replaced the data android:scheme="${applicationId}.braintree"/ with data android:scheme="custom-url-scheme-1"/. The issue has been resolved. But why? I just follow the v4.9.0+_MIGRATION_GUIDE.md. Can someone explain it?

sshropshire commented 1 year ago

@caijunjieNick did you set a custom returnUrlScheme using the BraintreeClient constructor to make it work? Whichever scheme you choose, it should match the scheme set in your AndroidManifest.xml.

caijunjieNick commented 1 year ago

@sshropshire yes, i set it by using the BraintreeClient constructo and in the AndroidManifest.xml at same time

sshropshire commented 1 year ago

@caijunjieNick that'll do it yeah. If you like you can post the snippet of your AndroidManifest.xml where the intent is declared. It should work using the default manifest placeholder we mention in the migration guide.

sshropshire commented 1 year ago

Also, I've seen it break in the past when a merchant app's package name contains underscores.

caijunjieNick commented 1 year ago

@sshropshire yes, it really breaks when i reach the final payment page at the second time ` <activity android:label="Apotheke" android:name="Apotheke" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" android:launchMode="singleTask" android:alwaysRetainTaskState="true" android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden|screenSize" android:exported="true">

        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <data android:scheme="custom-url-scheme-1"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
        </intent-filter>
    </activity>`

`braintreeClient = new BraintreeClient(getContext(), token,"custom-url-scheme-1");

payPalClient = new PayPalClient(getActivity(), braintreeClient);

payPalClient.setListener(this); payPalDataCollector = new PayPalDataCollector(braintreeClient); collectDeviceData(); myTokenizePayPalAccountWithCheckoutMethod();`

at first i used <data android:scheme="${applicationId}.braintree" />. i can reach the final payment page but it will stuck in the last step and not go back to the app. ` <activity android:label="Apotheke" android:name="Apotheke" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" android:launchMode="singleTask" android:alwaysRetainTaskState="true" android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden|screenSize" android:exported="true">

        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <data android:scheme="${applicationId}.braintree"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
        </intent-filter>
    </activity>`
caijunjieNick commented 1 year ago

@sshropshire i just set it with "com.your-company.your-app.braintree" (not ${applicationId}.braintree) and also set it in BraintreeClient constructor. I also did some test. It works fine at first. But later it still break

caijunjieNick commented 1 year ago

@sshropshire hello, i found the problem. I write braintreeClient = new BraintreeClient(this, MerchantClientTokenProvider()); payPalClient = new PayPalClient(this, braintreeClient); payPalClient.setListener(this); collectDeviceData(); myTokenizePayPalAccountWithCheckoutMethod() in a method startPaypal() and invoke this method in handleMessage() by using final OrderConfirmationFragment myAct = mAct.get(); myAct.startPaypal(). Right now i just modified: myAct.braintreeClient = new BraintreeClient(myAct.requireContext(), token,"com.akami.apotheke.braintree"); myAct.payPalClient = new PayPalClient(myAct, myAct.braintreeClient); myAct.payPalClient.setListener(myAct); myAct.payPalDataCollector = new PayPalDataCollector(myAct.braintreeClient); myAct.collectDeviceData(); myAct.myTokenizePayPalAccountWithCheckoutMethod(); And doesn't break anymore