payu-intrepos / payumoney-new-sample-app

New Sample App For PayUmoney and PnP SKD integration
40 stars 37 forks source link

onActivityResult not called inside of Fragment #55

Open YudizMohitS opened 3 years ago

YudizMohitS commented 3 years ago

Is there any way to get a callback from Fragment?

Rahul-Hooda commented 3 years ago

@YudizMohitS - When calling startPayUMoneyFlow(), don't use activity context and just pass this.

YudizMohitS commented 3 years ago

@Rahul-Hooda Thanks. for your reply but this is not work with Fragment

I am using this lib implementation 'com.payumoney.sdkui:plug-n-play:1.6.1'

Rahul-Hooda commented 3 years ago

@YudizMohitS - You must be calling below integration function from your code -

// Invoke the following function to open the checkout page. PayUmoneyFlowManager.startPayUMoneyFlow( PayUmoneySdkInitializer.PaymentParam paymentParam, Activity context, int style, boolean isOverrideResultScreen)

Now, when calling this from Activity, you can pass this which will pass activity context. In your case, you are calling it from inside a fragment. Please make sure to pass your fragment context and you shouldn't pass getActivity() in this.

YudizMohitS commented 3 years ago

@Rahul-Hooda How can I pass this inside of Fragment because there is an Activity context in startPayUMoneyFlow method. Below is my SS

https://imgur.com/kBlF9dl

Rahul-Hooda commented 3 years ago

@YudizMohitS - Yes. Activity context is consumed by the method. In this case, onActivityResult() of your activity will be called. From there you can consume the result.

YudizMohitS commented 3 years ago

@Rahul-Hooda But my question is there is any way to handle inside of Fragment?

Rahul-Hooda commented 3 years ago

@YudizMohitS - No, You can not handle it inside Fragment. The only way to handle it is through the Activity's onActivityResult()