razorpay / razorpay-java

Razorpay Java SDK
https://mvnrepository.com/artifact/com.razorpay/razorpay-java
MIT License
57 stars 64 forks source link

com.razorpay.CheckoutActivity has leaked IntentReceiver #128

Closed samuel-sujith closed 1 year ago

samuel-sujith commented 3 years ago

I am using 'com.razorpay:checkout:1.6.11' in my android dependencies.

While running the payment scenario for my app, I am getting the below error

E/com.razorpay.checkout: Webview JS Error: Uncaught ReferenceError: otpPermissionCallback is not defined I/chromium: [INFO:CONSOLE(1)] "Uncaught ReferenceError: otpPermissionCallback is not defined", source: https://api.razorpay.com/v1/payments/pay_HjyJpCXUmEggBd/callback/08b127d2a0d9ad380b5b13ce290ea6018bdf9085/rzp_test_gYefCg3wjpjcPZ?status=authorized&token_recurring_status=rejected&language_code=en (1) E/ActivityThread: Activity com.razorpay.CheckoutActivity has leaked IntentReceiver com.razorpay.AutoReadOtpHelper@8c37f9c that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Activity com.razorpay.CheckoutActivity has leaked IntentReceiver com.razorpay.AutoReadOtpHelper@8c37f9c that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.(LoadedApk.java:1167) at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:950) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1339) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1319) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1313) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:596) at com.razorpay.CheckoutPresenterImpl.onSubmit(CheckoutPresenterImpl.java:958) at com.razorpay.CheckoutBridge$2.secure(CheckoutBridge.java:158) at com.razorpay.CheckoutPresenterImpl.executeWebViewCallback(CheckoutPresenterImpl.java:1256) at com.razorpay.CheckoutPresenterImpl.access$700(CheckoutPresenterImpl.java:49) at com.razorpay.CheckoutPresenterImpl$9.run(CheckoutPresenterImpl.java:1242) at android.os.Handler.handleCallback(Handler.java:754) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6238) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

As per many issues which i saw already, this was fixed but I keep getting this error anyway.

Can this please be resolved.

Thanks, Sujith.

chiater0311 commented 3 years ago

do you solve this issue? I faced the same issue

tanishq14developer commented 2 years ago

have you solve this issue???Facing same issue

samuel-sujith commented 2 years ago

I added the below in thr proguard rules file and then it was working fine

-keepclassmembers class * { @android.webkit.JavascriptInterface ; }

-keepattributes JavascriptInterface -keepattributes Annotation

-dontwarn com.razorpay. -keep class com.razorpay. {*;}

-optimizations !method/inlining/*

-keepclasseswithmembers class { public void onPayment(...); }

tanishq14developer commented 2 years ago

please give me correct proguard rules some thing you have messed up i think line number 2 showing error in my ide

samuel-sujith commented 2 years ago

https://razorpay.com/docs/payment-gateway/android-integration/standard/

Gives the correct proguard rules.

tanishq14developer commented 2 years ago

Thankyou!!

ManishPingale13 commented 2 years ago

I have added those rules to my proguard file but it still doesn't work, can anybody please help me

ankit1057 commented 2 years ago

Facing The same issue in v- 1.6.12 E/ActivityThread: Activity com.razorpay.CheckoutActivity has leaked IntentReceiver com.razorpay.AutoReadOtpHelper@3308a9a that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Activity com.razorpay.CheckoutActivity has leaked IntentReceiver com.razorpay.AutoReadOtpHelper@3308a9a that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.(LoadedApk.java:1598) at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1374) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1525) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1498) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1486) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:637) at com.razorpay.CheckoutPresenterImpl.onSubmit(CheckoutPresenterImpl.java:959) at com.razorpay.J$0.secure(CheckoutBridge.java:158) at com.razorpay.CheckoutPresenterImpl.executeWebViewCallback(CheckoutPresenterImpl.java:1257) at com.razorpay.CheckoutPresenterImpl.access$700(CheckoutPresenterImpl.java:49) at com.razorpay.z$_w$.run(CheckoutPresenterImpl.java:1243) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7590) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

tanishq14developer commented 2 years ago

just ignored it!!

tanishq14developer commented 2 years ago

In production its working fine and also set pro guard rules @ankit1057

MayurDokras commented 2 years ago

Future openCheckout(OrderProvider orderProvider) async { User? user = FirebaseAuth.instance.currentUser;

var options = {
  'key': 'rzp_test_2Nsm4ZGj6heV50',
  'amount': '${orderProvider.amount}00',
  'name': orderProvider.shopName,
  'description': 'Fruits Purchase',
  'retry': {'enabled': true, 'max_count': 1},
  'send_sms_hash': true,
  'prefill': {'contact': user!.phoneNumber, 'email': orderProvider.email},
  'external': {
    'wallets': ['paytm']
  }
};

try {
  _razorpay.open(options);
} catch (e) {
  debugPrint('Error: e');
  print(e.toString());
}

}

void _handlePaymentSuccess(PaymentSuccessResponse response) { OrderProvider orderProvider = OrderProvider();

if(response.paymentId!= null){
  setState(() {
    orderProvider.success = true;
  });

  Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context)=>Main_Screen()), (route) => false);
}
Fluttertoast.showToast(
    msg: "SUCCESS: " + response.paymentId!,
    toastLength: Toast.LENGTH_SHORT);

}

//when payment not done

void _handlePaymentError(PaymentFailureResponse response) { OrderProvider orderProvider = OrderProvider();

setState(() {
  orderProvider.success = false;
});
Fluttertoast.showToast(
    msg: "ERROR: " + response.code.toString() + " - " + response.message!,
    toastLength: Toast.LENGTH_SHORT);

}

void _handleExternalWallet(ExternalWalletResponse response) { Fluttertoast.showToast( msg: "EXTERNAL_WALLET: " + response.walletName!, toastLength: Toast.LENGTH_SHORT); }

Im using this kind of code I have passed the onpressed : () { openCheckout(orderProvider); }

All is working fine, but after I'm getting the payment id it is validating.

this is my OrderProvider

import 'package:flutter/material.dart';

class OrderProvider with ChangeNotifier{

String? status; String? amount; bool success = false; String shopName = 'Heaven\'s Fruits'; String? email;

filterOrder(status){ this.status = status; notifyListeners(); }

totalAmount(amount, String shopName, email){ this.shopName = shopName; this.amount = amount.toStringAsFixed(0); this.email = email; notifyListeners(); }

paymentStatus(success){ this.success = success; notifyListeners(); }

}

if (_cartProvider.cod == false) { //Pay online orderProvider.totalAmount(_payable, shopName, userDetails.snapshot!['email']); Navigator.pushNamed(context, Payment_Home.id).whenComplete(() { // if (orderProvider.success == true) {

                            if (orderProvider.success == true && orderProvider.success == false ) {

                                _saveOrders(_cartProvider, _payable,
                                    _coupon, orderProvider);
                            }
                          });
                        }

I/chromium( 7587): [INFO:CONSOLE(1)] "Uncaught TypeError: window.getDeviceDetails is not a function", source: https://api.razorpay.com/v1/payments/pay_J91TMMJ4kcCsO2/redirect_callback?key_id=rzp_test_2Nsm4ZGj6heV50 (1)

E/com.razorpay.checkout( 7587): Webview JS Error: Uncaught SyntaxError: Invalid or unexpected token I/chromium( 7587): [INFO:CONSOLE(1)] "Uncaught SyntaxError: Invalid or unexpected token", source: https://api.razorpay.com/v1/payments/pay_J91TMMJ4kcCsO2/redirect_callback?key_id=rzp_test_2Nsm4ZGj6heV50 (1)

I/chromium( 7587): [INFO:CONSOLE(1)] "Uncaught SyntaxError: Invalid or unexpected token", source: https://api.razorpay.com/v1/payments/create/checkout# (1) E/com.razorpay.checkout( 7587): Webview JS Error: Uncaught TypeError: window.getDeviceDetails is not a function I/chromium( 7587): [INFO:CONSOLE(1)] "Uncaught TypeError: window.getDeviceDetails is not a function", source: https://api.razorpay.com/v1/payments/create/checkout# (1)

Getting these Errors repeatedly, Someone please tell me what is going on in this package. I have a deadline and when I started this it is working fine till getting to the page but after payment, it does not show the callBack to the successful payment.

Feel free to discuss with me, mayurdokras2404@gmail.com

faisalmushtaq007 commented 2 years ago

@MayurDokras hi brother! i am getting the same issue. First payment works fine and after that the event listeners dont work

MayurDokras commented 2 years ago

Hi, Actually, it is package issue bro. Cause if I'm not getting the flag that the payment is not done. Still the package is sending Payment Successful status to the App. So, I'm thinking to go with another option and if u get the solution for this issue. Please let me know.

From, Mayur Dokras.

On Thu, 21 Apr, 2022, 4:59 pm Faisal Mushtaq, @.***> wrote:

@MayurDokras https://github.com/MayurDokras hi brother! i am getting the same issue. First payment works fine and after that the event listeners dont work

— Reply to this email directly, view it on GitHub https://github.com/razorpay/razorpay-java/issues/128#issuecomment-1105087958, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKRV2TKHTN3JTFBLJI74GPTVGE32PANCNFSM5B7DP2ZA . You are receiving this because you were mentioned.Message ID: @.***>

Tejaswini0215 commented 2 years ago

E/com.razorpay.checkout: Webview JS Error: Uncaught SyntaxError: Invalid or unexpected token I/chromium: [INFO:CONSOLE(1)] "Uncaught SyntaxError: Invalid or unexpected token", source: https://api.razorpay.com/v1/checkout/public?version=1.6.19&library=checkoutjs&platform=android (1)

ankitdas13 commented 1 year ago

@samuel-sujith It has already been fixed #134 . Please update to the most recent version to resolve this issue also the issue is not related to this repo . If the issue still persists after upgrading could you please create a new issue in this repo

dhavalpatel666 commented 1 year ago

I am using 'com.razorpay:checkout:1.6.26' in my android dependencies.

While running the payment scenario for my app, I am getting the below error go to razorpay page

java.lang.NoSuchFieldError: No static field NO_OPTIONS of type Lcom/google/android/gms/common/api/Api$ApiOptions$NoOptions; in class Lcom/google/android/gms/common/api/Api$ApiOptions; or its superclasses (declaration of 'com.google.android.gms.common.api.Api$ApiOptions' appears in /data/app/com.smaple-suaPyGsU26tVlh7gKARYpQ==/base.apk!classes2.dex) at com.google.android.gms.auth.api.phone.SmsRetrieverClient.(com.google.android.gms:play-services-auth-api-phone@@17.5.1:1) at com.google.android.gms.internal.auth-api-phone.zzab.(com.google.android.gms:play-services-auth-api-phone@@17.5.1:1) at com.google.android.gms.auth.api.phone.SmsRetriever.getClient(com.google.android.gms:play-services-auth-api-phone@@17.5.1:1) at com.razorpay.CheckoutPresenterImpl.onLoad(CheckoutPresenterImpl.java:874) at com.razorpay.J$0.secure(CheckoutBridge.java:27) at com.razorpay.CheckoutPresenterImpl.executeWebViewCallback(CheckoutPresenterImpl.java:1370) at com.razorpay.CheckoutPresenterImpl.access$700(CheckoutPresenterImpl.java:55) at com.razorpay.b$f.run(CheckoutPresenterImpl.java:1355) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6810) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

DipeshChaudhari87 commented 1 year ago

I am using 'com.razorpay:checkout:1.6.26' in my android dependencies.

While running the payment scenario for my app, I am getting the below error go to razorpay page

java.lang.NoSuchFieldError: No static field NO_OPTIONS of type Lcom/google/android/gms/common/api/Api$ApiOptions$NoOptions; in class Lcom/google/android/gms/common/api/Api$ApiOptions; or its superclasses (declaration of 'com.google.android.gms.common.api.Api$ApiOptions' appears in /data/app/com.smaple-suaPyGsU26tVlh7gKARYpQ==/base.apk!classes2.dex) at com.google.android.gms.auth.api.phone.SmsRetrieverClient.(com.google.android.gms:play-services-auth-api-phone@@17.5.1:1) at com.google.android.gms.internal.auth-api-phone.zzab.(com.google.android.gms:play-services-auth-api-phone@@17.5.1:1) at com.google.android.gms.auth.api.phone.SmsRetriever.getClient(com.google.android.gms:play-services-auth-api-phone@@17.5.1:1) at com.razorpay.CheckoutPresenterImpl.onLoad(CheckoutPresenterImpl.java:874) at com.razorpay.J$0.secure(CheckoutBridge.java:27) at com.razorpay.CheckoutPresenterImpl.executeWebViewCallback(CheckoutPresenterImpl.java:1370) at com.razorpay.CheckoutPresenterImpl.access$700(CheckoutPresenterImpl.java:55) at com.razorpay.b$f.run(CheckoutPresenterImpl.java:1355) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6810) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

Hi @dhavalpatel666 I am also facing the same issue but I am facing this issue on @eabdullazyanov/react-native-sms-user-consent plugin. Have you got any solution for this issue?