braintree / braintree_android

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

Paypal in dropin not working with braintree #185

Closed avnishebizon closed 6 years ago

avnishebizon commented 6 years ago

My code was working fine previously, but now it seems something changed in Braintree system so that its not working for selecting Paypal from drop-in menu for payments. ts simple to reproduce because I haven't changed anything in code and this issue happens every time.

Issue description -

After selecting the Braintree payment method, we get the brainTreeToken using brainTreeTokenListener execute the Android SDK for Braintree to proceed further with the payment using code :

DropInRequest dropInRequest = new DropInRequest()
.clientToken(token);
startActivityForResult(dropInRequest.getIntent(MainActivity.INSTANCE), ConstantDataMember.BRAINTREECODE);

it will opens up a window with payment options : "Paypal & Credit card" in my case. When selecting paypal, nothings works. Actually after startActivityForResult, the Braintree sdk returns the resultcode '0', which in my case is handleded as below :

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
DropInResult result = data.getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT);
sendBrainTreeNonceToServer(result);
// use the result to update your UI and send the payment method nonce to your server
} else if (resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(MainActivity.INSTANCE, MainActivity.INSTANCE.getResources().getString(R.string.payment_cancel), Toast.LENGTH_SHORT).show();
// the user canceled
} else {
// handle errors here, an exception may be available in
Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR);
Toast.makeText(MainActivity.INSTANCE, MainActivity.INSTANCE.getResources().getString(R.string.payment_cancel), Toast.LENGTH_SHORT).show();
}
}

}

so definitely, braintree SDK is returning just the cancel result code in onActivityResult method, with data=null.

I am using gradle - compile 'com.braintreepayments.api:drop-in:3.0.0' Also tried updating gradle version for this dependency still same problem exists.

Also tried above mentioned solution, even changed the bundle id to a fresh in case other device using same bundle id just for checking, but nothing works. If anyone found any fix, please post the fix.

kenny128 commented 6 years ago

@avnishebizon can you check if there is an exception set in the cancelled case by adding Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR); before the toast and see if it is set to anything

sdcoffey commented 6 years ago

Hey @avnishebizon,

Sorry for letting you hang for 3 days. I would definitely try @kenny128's suggestion, as there's likely an error being returned. Let us know what the error is and we'll assist in debugging. If it's something you can handle without further help, please close this issue. Thanks!

avnishebizon commented 6 years ago

Hi Guys,

As I have mentioned in the above problem - so definitely, braintree SDK is returning just the cancel result code in onActivityResult method, with data=null

So, as because data is null, using this solution - Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR); it will just give null pointer exception.

I have verified again, app is crashing using this statement in 'resultCode == Activity.RESULT_CANCELED' code block.

jaypatel512 commented 6 years ago

Hey @avnishebizon !

I see we have version 3.2.1 of our Android DropIn. Would you mind updating to latest and verify if you still facing the same issue.

I would also recommend just running our sample app, and see if this works on your emulator/device. This should help us identify the issue a bit more easily.

quinnjn commented 6 years ago

Hi @avnishebizon

Let us know if you're still experiencing the issue with Android Drop-in 3.2.1. Otherwise we will close the issue.

pateljigar7210 commented 5 years ago

BraintreeDropIn when select paypal genrate error : Parsing error response failed

sestevens commented 5 years ago

@pateljigar7210 If this is related to the above issue, could you elaborate on the problem you're seeing and let us know which version of the Braintree Drop-in SDK you're using? If this is a new issue, please open a new GitHub Issue.

VikramSN commented 3 years ago

Facing same issue, When click Paypal Dropin UI its giving error -> ErrorWithResponse (422): Parsing error response failed []