Razorpay stuck in release mode

Viewed 97

In Flutter i have used razor pay library while i am running in debug mode all went perfectly but when i create a release of that it showing black screen and i couldn't go back so please help me out of it

proguard-rules.pro

-dontwarn com.razorpay.**
-keep class com.razorpay.** {*;}
-optimizations !method/inlining/
-keepclasseswithmembers class * {
  public void onPayment*(...);
}

build.gradle

        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                    signingConfig signingConfigs.release
        }
    }

pubspec.yaml

razorpay_flutter: ^1.2.9

code

void openCheckout() async {
    showDialog(
        context: context,
        builder: (_) => new Dialog(
              elevation: 0,
              backgroundColor: Colors.transparent,
              child: new Container(
                alignment: FractionalOffset.center,
                height: 150.0,
                child: Lottie.asset('assets/dtp_loader.json'),
              ),
            ));
    AuthRepositories()
        .checkUser(context, _onlineStatus, commonClass,
            mobileNumberController.text, emailController.text)
        .then((value) {
      if (value.status == 200) {
        Navigator.pop(context);

        var options = {
          'key': '${commonClass.get_razor_key}',
          'amount': memberShipAmount,
          'name': '${memberShipName}',
          'description': 'Paying to DTP',
          'retry': {'enabled': true, 'max_count': 1},
          'send_sms_hash': true,
          'prefill': {
            'contact': '${mobileNumberController.text}',
            'email': '${emailController.text}'
          },
          'external': {
            'wallets': ['paytm']
          }
        };

        try {
          _razorpay.open(options);
        } catch (e) {}
      } else {
        Navigator.pop(context);
      }
    });
  }

  void _payWithourPayment( ) {
    showDialog(
        context: context,
        builder: (_) => new Dialog(
              elevation: 0,
              backgroundColor: Colors.transparent,
              child: new Container(
                alignment: FractionalOffset.center,
                height: 150.0,
                child: Lottie.asset('assets/dtp_loader.json'),
              ),
            ));
    AuthRepositories()
        .register(
            context,
            _onlineStatus,
            commonClass,
            fNameController.text,
            lNameController.text,
            emailController.text,
            mobileNumberController.text,
            cityId.toString(),
      "",
       code,
          referById==0?"":referById.toString(),
           "")
        .then((value) {
      setState(() {
        _signUpClicked = false;
        _signInClicked = true;
        fNameController.text = "";
        lNameController.text = "";
        emailController.text = "";
        mobileNumberController.text = "";
        loginMobileNumberController.text = "";        couponCodeController.text = "";

        cityId = 0;
        cityName = "";
        txnID = "";
        referById = 0;
        referByName = "";
        memberShipId = 0;
        memberShipName = "";
        memberShipAmount = "";
        code = "";
      });
      Navigator.pop(context);
    });


  }

  void _handlePaymentSuccess(PaymentSuccessResponse response) {
    showDialog(
        context: context,
        builder: (_) => new Dialog(
              elevation: 0,
              backgroundColor: Colors.transparent,
              child: new Container(
                alignment: FractionalOffset.center,
                height: 150.0,
                child: Lottie.asset('assets/dtp_loader.json'),
              ),
            ));
    AuthRepositories()
        .register(
            context,
            _onlineStatus,
            commonClass,
            fNameController.text,
            lNameController.text,
            emailController.text,
            mobileNumberController.text,
            cityId.toString(),
            memberShipId.toString(),
            "",
        referById==0?"":referById.toString(),
            response.paymentId!)
        .then((value) {
      setState(() {
        _signUpClicked = false;
        _signInClicked = true;
        fNameController.text = "";
        lNameController.text = "";
        emailController.text = "";
        mobileNumberController.text = "";
        loginMobileNumberController.text = "";
        couponCodeController.text = "";
        cityId = 0;
        cityName = "";
        txnID = "";
        referById = 0;
        referByName = "";
        memberShipId = 0;
        memberShipName = "";
        memberShipAmount = "";
        code = "";
      });
      Navigator.pop(context);
    });
 
    // Fluttertoast.showToast(
    //     msg: "SUCCESS: " + response.paymentId!,
    //     toastLength: Toast.LENGTH_SHORT);
  }

  void _handlePaymentError(PaymentFailureResponse response) {
    print("${response.code.toString() + " - " + response.message!}");

    // Fluttertoast.showToast(
    //     msg: "ERROR: " + response.code.toString() + " - " + response.message!,
    //     toastLength: Toast.LENGTH_SHORT);
  }

  void _handleExternalWallet(ExternalWalletResponse response) {
    print("${"EXTERNAL_WALLET: " + response.walletName!}");

    // Fluttertoast.showToast(
    //     msg: "EXTERNAL_WALLET: " + response.walletName!,
    //     toastLength: Toast.LENGTH_SHORT);
  }

So this is my code all went perfect in debug mode but failed in release mode

1 Answers

I got an solution from razorPay team and they said i have miss placed proguard rules file and they said to place on app folder Now my proguard rules file look like this proguard-rules.pro

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

-keepattributes JavascriptInterface
-keepattributes *Annotation*

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

-optimizations !method/inlining/*

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

in app/build.gradle

    buildTypes {
        debug {
            debuggable true
        }
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

Related