razorpay / react-native-razorpay

React Native wrapper for Razorpay's mobile SDKs
https://www.npmjs.com/package/react-native-razorpay
MIT License
124 stars 107 forks source link

App Crashes on RazorpayCheckout.open API #393

Closed ameenfarook closed 2 years ago

ameenfarook commented 2 years ago

Description

Android app is crashing when i invoke RazorpayCheckout.open API.

Razorpay Package Version :

Razorpay 2.2.8 ("react-native-razorpay": "^2.2.8",)

Java and Gradle Version (android) :

Gradle 6.9 (distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip) Java 15 (java version "15.0.1" 2020-10-20)

What you did:

I was invoking RazorpayCheckout.open API with key, name and order_id and then it crashes.

What happened:

It is only happening to android, in ios it works fine. I cant even catch the error using basic try catch. But i got the stack trace from crashlytics which is attached below .

Screenshot 2022-02-14 231620

Code example, screenshot, or link to a repository:

Please provide a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

vivekshindhe commented 2 years ago

@ameenfarook Hey there. I tried to replicate the issue. Was unsuccessful in doing so. Both in debug and release modes. Could you please give more details? When does this error happen? Can you send us the payload you are sending?

vivekshindhe commented 2 years ago

Okay, I was able to reproduce the issue. It is happening because of the color value that is passed in the options payload. Here is the payload that I was using when I was able to reproduce the issue,

var options = { description: 'Credits towards consultation', image: 'https://i.imgur.com/3g7nmJC.png', currency: 'INR', key: '***********************', // Your api key amount: '5000', name: 'foo', prefill: { email: 'void@razorpay.com', contact: '9191919191', name: 'Razorpay Software', }, theme: {color: '#000'}, };

If you see the color it is considered as the right value, but android doesn't parse it. But will parse something like this

#000000. Please re-check this option and let us know if that resolves the problem for you. Thank you

ameenfarook8 commented 2 years ago

But i thought theme and color is an optional parameter. Are you saying i must provide theme and color?

ameenfarook8 commented 2 years ago

I actually implemented this a month ago, it was working fine till today. All of a sudden this color issue?

vivekshindhe commented 2 years ago

I was trying to reproduce the issue and was able to do it with this one parameter change with almost the exactly same logs. Could you please send us the payload you are sending so that its easy for me to reproduce it? That would be very helpful.

ameenfarook8 commented 2 years ago

I am only passing three parameters

key name order_id

like this

const paymentResponse = await RazorpayCheckout.open({ key: publicKey, name, order_id: orderId, });
vivekshindhe commented 2 years ago

vivek.shindhe@razorpay.com this is my email. Could you please send the key you are trying this with? Even the test key works. I'll try to reproduce it on my end with the key. Also please add an order_id a sample one. This information would be instrumental in reproducing the issue. Also, did this happen on release or debug version? And you couldn't see the logs in android studio? Another thing, did you upgrade the react-native-razorpay version recently?

bijeesraj007 commented 2 years ago

@vivekshindhe - I have shared the requested information via email.

sahukanishka commented 2 years ago

Razorpay sdk crashes when we call RazorpayCheckout.open(options) method and pass the options Sometimes the method works fine and easily opens the razorpay window.

But other times, it does not open and the app immediately crashes. Also, There is no crash logs found in the console.

ameenfarook8 commented 2 years ago

Razorpay sdk crashes when we call RazorpayCheckout.open(options) method and pass the options Sometimes the method works fine and easily opens the razorpay window.

But other times, it does not open and the app immediately crashes. Also, There is no crash logs found in the console.

Make sure to pass theme and color parameter to RazorpayCheckout.open API. This prevents my app to crash.

Below is the payload im using.

RazorpayCheckout.open({
      key: <public-key>,
      name: <name>,
      order_id: <order-id>,
      theme: {
        color: <some-color>,
      }
    });
sahukanishka commented 2 years ago

One more point if your app still crashes. You have to pass both image and theme. RazorpayCheckout.open({ key: <public-key>, name: <name>, order_id: <order-id>, theme: { color: <some-color>, } image: 'https://i.imgur.com/3g7nmJC.png' });

rahulnikam2002 commented 10 months ago

Did anyone found the solution!

vivekshindhe commented 10 months ago

@rahulnikam2002 Can you share any logs related to the crash? Is it happening on android or iOS? It would be helpful for us to try to get to the bottom of the issue. I wasn't able to reproduce this.

rahulnikam2002 commented 10 months ago

@rahulnikam2002 Can you share any logs related to the crash? Is it happening on android or iOS? It would be helpful for us to try to get to the bottom of the issue. I wasn't able to reproduce this.

Heyy!! it worked for me 😁

SiDDhartharG commented 10 months ago

Hi Guys My problem was solved

I was not sending key in payload which solve my problem and my app stopped crashing

RazorpayCheckout.open({ key: <public-key>, name: <name>, order_id: <order-id>, theme: { color: <some-color>, } image: 'https://i.imgur.com/3g7nmJC.png' });