braintree-android-drop-in
braintree-android-drop-in copied to clipboard
Handle both card payment and paypal payment in using drop-in
General information
- SDK/Library version: 4.5.0
- Environment: SandBox
- Android Version and Device: Android 10, Samsung A20
Issue description
I have incorporated braintree payment solution in my application. I want to make use of both card and PayPal.
build.gradle --> implementation 'com.braintreepayments.api:drop-in:4.5.0' "The latest version is failing"
code implementation:
public void onBraintreeSubmit(View v) {
MyRestClient.get("/client_token", null, new TextHttpResponseHandler() {
String clientToken;
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
}
@Override
public void onSuccess(int statusCode, Header[] headers, String clientToken) {
Log.d(TAG, "onSuccess: token generation successful");
this.clientToken = clientToken;
PayPalRequest request = new PayPalRequest("1")
.currencyCode("USD")
.intent(PayPalRequest.INTENT_AUTHORIZE);
DropInRequest dropInRequest = new DropInRequest().clientToken(this.clientToken)
.clientToken(this.clientToken)
.paypalRequest(request);
startActivityForResult(dropInRequest.getIntent(GooglePayActivity.this), REQUEST_CODE);
Log.d(TAG, "onSuccess: clientToken: " + clientToken);
}
});
}
============== onActivityResult @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE) { if (resultCode == RESULT_OK) { DropInResult result = data.getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT); // use the result to update your UI and send the payment method nonce to your server Log.d(TAG, "onActivityResult: all is well, send payment nonce to server");
} else if (resultCode == RESULT_CANCELED) {
Log.d(TAG, "onActivityResult: user cancelled");
// the user canceled
} else {
Log.d(TAG, "onActivityResult: exception is thrown");
// handle errors here, an exception may be available in
Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR);
Log.d(TAG, "onActivityResult: exception is --->>>> " + error.getMessage());
}
}
}
=== Logcat result 2021-05-16 12:45:54.391 18421-18421/my.package.name D/PaymentActivity: onActivityResult: exception is thrown 2021-05-16 12:45:54.393 18421-18421/my.package.name D/PaymentActivity: onActivityResult: exception is --->>>> Parsing error response failed
Hey @Joesta thanks for using the Braintree SDK for Android. Does Error#printStackTrace()
provide any additional information here that could help diagnose the issue?
Hi @Joesta is this issue still occurring for you? Were you able to get any additional information from the stack trace?
Hi @Joesta is this issue still occurring for you? Were you able to get any additional information from the stack trace?
Hi @sarahkoop I will try this when I get home and revert. I also may have closed this issue by mistake!
Hey @Joesta thanks for using the Braintree SDK for Android. Does
Error#printStackTrace()
provide any additional information here that could help diagnose the issue?
Hi @sshropshire apologies for this late response. I will check and provide you with the trace logs.
two times clientToken
Can I show localized Drop In UI using Braintree Android SDK.
@sarthi93 Yes Drop-in will be automatically localized to the user's device language. Closing the original issue now due to inactivity.