braintree / braintree-android-drop-in

Braintree Drop-In SDK for Android
https://developers.braintreepayments.com/guides/drop-in/android/v2
MIT License
124 stars 79 forks source link

Regarding integrating both DropIn and Paypal as standlone option #415

Open rohitgarg29 opened 1 year ago

rohitgarg29 commented 1 year ago

Hi Team,

I want to add paypal option in both DropIn client and Paypal as standlone integration.

For Paypal Standlone, I have to add the following to my activity:

<activity
            android:name=".bookingflow.ordersummary.ReviewAndPayActivity"
            android:configChanges="orientation"
            android:exported="true"
            android:label="@string/order_summary_activity_label"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar">
            <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>

For DropIn, I will have to add the following:

<activity
            android:name="com.braintreepayments.api.DropInActivity"
            android:exported="true"
            tools:node="merge">
            <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>

Because of this, when I am coming back from paypal, i have to choose from the picker, Is there a work around or way to resolve it?

sshropshire commented 1 year ago

Hi @rohitgarg29 thanks for using the Braintree SDK for Android. We do have a constructor for BraintreeClient that allows you to specify a custom return url. In the AndroidManifest.xml for your standalone integration, you can then specify a custom url scheme instead of using the applicationId manifest placeholder.

rohitgarg29 commented 1 year ago

Hi @sshropshire Thanks for replying. I tried your way but getting the error message "Paypal is not enabled" in onPayPalFailure method and it does not even launch the paypal payment UI.

braintreeClient = new BraintreeClient(requireContext(), clientTokenResponse.getClientTokenData().getClientToken(), "myapp");
        payPalClient = new PayPalClient(this, braintreeClient);
        payPalClient.setListener(this);
        PayPalCheckoutRequest request = new PayPalCheckoutRequest(getAmount());
        request.setCurrencyCode(PAYPAL_CURRENCY_CODE);
        paypalContainer.setVisibility(GONE);
        payPalClient.tokenizePayPalAccount(requireActivity(), request);
sshropshire commented 1 year ago

@rohitgarg29 have you followed this guide to enable PayPal as a payment source?

rohitgarg29 commented 1 year ago

@sshropshire yes it is enabled. Without drop-in it was working fine.

sshropshire commented 1 year ago

@rohitgarg29 does your manifest for for the ReviewAndPayActivity now contain:

<data android:scheme="myapp" />

?

rohitgarg29 commented 1 year ago

@sshropshire it has this value as well. Can you please test it at your end with drop and standlone both options?