Comments (11)
- Does your fragment setup
Braintree
? - Are you adding your
Fragment
as a listener? - Are you receiving the call to
Activity#onActivityResult
in yourActivity
orFragment
? - If you're expecting
Fragment#onActivityResult
to be called, are you callingsuper#onActivityResult
in yourActivity
if you are overriding the method? - Is the result successful in
onActivityResult
? - Are you registering any error listeners with
Braintree
? If so are you receiving errors?
from braintree_android.
receiving the call to onActivityResult in Fragment?
from braintree_android.
Yes, it is possible to receive [onActivityResult
in a Fragment](http://developer.android.com/reference/android/app/Fragment.html#onActivityResult%28int, int, android.content.Intent%29).
In order to figure out the issue you are having, we'll need more information such as the questions I asked above, or if you can reproduce it in a simple case and share it, we're happy to take a look. Is this happening for credit cards or other payment methods? You may also want to make sure you're handling the result in onActivityResult
, if you are not, you will not receive callbacks for Venmo or PayPal.
You can also contact [email protected].
from braintree_android.
but onPaymentMethodNonce method not getting called in fragment ,in activity is still working but not in fragment
from braintree_android.
Is this for credit card tokenization or other payment methods?
from braintree_android.
credit card tokenization its working fine on fragment its only problem in Paypal payment method
from braintree_android.
Are you calling Braintree#finishPayWithPayPal
in Activity#onActivityResult
?
Do you have an example of your Activity
and Fragment
that you can share? It's unclear how your code is setup and in order to debug further I'll need more information. You can also step through it with a debugger to see what is happening.
from braintree_android.
public class Frag_Paypal extends Fragment implements PaymentMethodNonceListener {
View view;
private Braintree mBraintree;
private Button mPaymentButton;
String client_token ;
private static int PayPal_Request_Code = 11876;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(
R.layout.fragment_paypal, container, false);
mPaymentButton = (Button) view.findViewById(R.id.btn_donate);
setData();
mPaymentButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
callPayPal();
}
});
return view;
}
public void callPayPal(){
mBraintree.startPayWithPayPal(getActivity(), PayPal_Request_Code);
}
public void setData(){
Bundle b = getArguments();
HashMap<String,String> obj;
if (!b.getSerializable(AppConstant.DONATE_DETAIL).equals(null)) {
obj = (HashMap<String, String>) b
.getSerializable(AppConstant.DONATE_DETAIL);
client_token = obj.get(BraintreePaymentActivity.EXTRA_CLIENT_TOKEN);
mBraintree = Braintree.getInstance(getActivity(), client_token);
mBraintree.addListener(this);
}
}
@Override
public void onPaymentMethodNonce(String paymentMethodNonce) {
Log.i("paymentListner--------", paymentMethodNonce);
Toast.makeText(getActivity(),"paymentMethodNonce"+paymentMethodNonce,Toast.LENGTH_LONG).show();
/* getActivity().setResult(getActivity().RESULT_OK, new Intent()
.putExtra(BraintreePaymentActivity.EXTRA_PAYMENT_METHOD_NONCE, paymentMethodNonce));*/
paymentAlert(paymentMethodNonce);
//finish();
}
@Override
public void onActivityResult(int requestCode, int responseCode, Intent data) {
Log.i("inonactivity","asfsdfdf");
/*if (requestCode == PaymentButton.REQUEST_CODE) {
mPaymentButton.onActivityResult(requestCode, responseCode, data);
}*/
if (requestCode == PayPal_Request_Code && responseCode == Activity.RESULT_OK) {
if(PayPalHelper.isPayPalIntent(data)) {
mBraintree.finishPayWithPayPal(getActivity(), responseCode, data);
} else {
mBraintree.finishPayWithVenmo(responseCode, data);
}
}
}
public void paymentAlert(String str_msg){
AlertDialog.Builder _builder = new AlertDialog.Builder(getActivity(),R.style.MyAlertDialogStyle);
_builder.setTitle("Donation")
.setMessage(str_msg)
.setNegativeButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
final AlertDialog dialog = _builder.create();
dialog.show();
}
}
// this is my fragment onPaymentMethodNonce method not getting called
from braintree_android.
The issue with this is mBraintree.startPayWithPayPal(getActivity(), PayPal_Request_Code);
is calling Activity#startActivityForResult
and not Fragment#startActivityForResult
. Your Fragment
will never receive a call to Fragment#onActivityResult
, you will need to override Activity#onActivityResult
and either call Braintree#finishPayWithPayPal
or call a method in your Fragment
with the parameters.
from braintree_android.
Hi @lkorth
I have implemented braintree sdk (Express Checkout) in my app.
OnPaymentMethodNonce callback method not getting called in fragment
I have added my paypal Activity and fragment codes below, Kindly check and do the needful.
Thanks...
public class PaymentActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_out);
Init();
}
private void Init() {
FrameLayout frameLayout = findViewById(R.id.frame);
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
PaymentFragment checkoutLoginFragment = new PaymentFragment();
fragmentTransaction.replace(R.id.frame, checkoutLoginFragment);
fragmentTransaction.commit();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
for (Fragment fragment : getSupportFragmentManager().getFragments()) {
fragment.onActivityResult(requestCode, resultCode, data);
}
}
}
----------------------------------------------------------------------------------------------------------------
public class PaymentFragment extends Fragment implements PaymentMethodNonceListener {
private Braintree mBraintree;
private Button mPaymentButton;
String mClientToken ;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_paypal, container, false);
mPaymentButton = (Button) view.findViewById(R.id.btn_donate);
try {
if(getActivity()!=null){
mBraintreeFragment = BraintreeFragment.newInstance(getActivity(),mClientToken);
}
} catch (InvalidArgumentException e) {
e.printStackTrace();
}
mPaymentButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PayPalExpressCheckout();
}
});
return view;
}
public void PayPalExpressCheckout(){
PostalAddress address=new PostalAddress()
.streetAddress(“13th street”)
.locality(“SanMarkam”)
.region(“kelongudi”)
.recipientName(“John Mark”)
.countryCodeAlpha2(Arabia);
PayPalRequest request = new PayPalRequest("1")
.currencyCode("USD")
.shippingAddressRequired(true)
.shippingAddressOverride(address)
.intent(PayPalRequest.INTENT_AUTHORIZE);
PayPal.requestOneTimePayment(mBraintreeFragment, request);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
String nonce = paymentMethodNonce.getNonce();
if (paymentMethodNonce instanceof PayPalAccountNonce) {
PayPalAccountNonce payPalAccountNonce = (PayPalAccountNonce)paymentMethodNonce;
// Access additional information
String email = payPalAccountNonce.getEmail();
String firstName = payPalAccountNonce.getFirstName();
String lastName = payPalAccountNonce.getLastName();
String phone = payPalAccountNonce.getPhone();
// See PostalAddress.java for details
PostalAddress billingAddress = payPalAccountNonce.getBillingAddress();
PostalAddress shippingAddress = payPalAccountNonce.getShippingAddress();
}
}
}
from braintree_android.
I am having a similar problem with @dineshlt
I have a MainActivity in my app and then a PaymentFragment.
Inside the PaymentFragment, I have
mBraintreeFragment = BraintreeFragment.newInstance(getActivity(), clientToken);
and the Fragment's PaymentMethodNonceListener is not called since the braintree fragment is attached to the activity instead and there is no way for me to create a BraintreeFragment from within my PaymentFragment.
from braintree_android.
Related Issues (20)
- Unable to obtain Postal Code from Google Pay HOT 3
- Fatal Exception: android.content.ActivityNotFoundException No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://www.paypal.com/... } HOT 14
- Calling onFailure Results Exception Stating Paypal is Not Enabled HOT 10
- - HOT 3
- Crash NPE on onVenmoFailure listener is null HOT 3
- Paypal native checkout can't work HOT 2
- Native check out call back not triggering after logged in. HOT 3
- ThreeDSecure Challenge UI is distorted in portrait mode HOT 3
- Duplicate class lib.android.paypal.com.magnessdk.Environment found in modules HOT 4
- com.braintreepayments.api.ThreeDSecureActivity instance is Leaking HOT 1
- com.paypal.android.sdk:data-collector not compliant with Play store policy HOT 9
- Absurd Migration Requirements HOT 1
- com.paypal.android.sdk:data-collector not compliant with Play store policy due to device location collection HOT 65
- Braintree - Paypal not working anymore if AppId contains Capital Letters HOT 5
- Allow processing browser switch redirect without requiring an Activity instance HOT 5
- URGENT!!: OnPayPalSuccess is never Called on Pixel Android Devices HOT 2
- Store in Vault - behaviour changes HOT 2
- Does checking if Google Pay is ready to pay require activity instead of plain context? HOT 2
- Users getting UserCanceledException on PayPal CustomTabs tokenization after minimizing the CustomTabs HOT 2
- SDK migration error "This transaction has been declined In order to comply with international regulations" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from braintree_android.