Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeError: Cannot read property 'open' of null] #451

Open
Akulvarshney opened this issue Apr 26, 2023 · 5 comments
Open

[TypeError: Cannot read property 'open' of null] #451

Akulvarshney opened this issue Apr 26, 2023 · 5 comments

Comments

@Akulvarshney
Copy link

I had installed the react-native-razorpay package using

$ npm i react-native-razorpay --save

I have imported the RazorpayCheckout on the top:

import RazorpayCheckout from "react-native-razorpay";

then I have created a function named paymentRazor, which has been called to an onPress functionality of a button.

`
const paymentRazor = () => {

var options = {
  key: "rzp_test_Rh5hj15XBv8XmI",
  currency: "INR",
  amount: "5000",
  order_id: "order_DslnoIgkIDL8Zt",
  name: "Akul varshney",
  description: "Payment for purchase order",
  image: "http://103.107.67.49/static/media/Orane-Consulting-logo.c3a9713e.jpg",
  prefill: {
    email: "[email protected]",
    contact: "8800252885",
    name: "Akul Varshney",
  },
  theme: { color: "#53a20e" },
};

console.log(options);

RazorpayCheckout(options)
  .then((data) => {

    let bodyData = {
      razorpay_payment_id: data.razorpay_payment_id,
      razorpay_order_id: "order_DslnoIgkIDL8Zt",
      razorpay_signature: data.razorpay_signature,
    };
    dispatch(razorPayment(bodyData));
    alert(`Success: ${data.razorpay_payment_id}`);
  })

  .catch((error) => {
    // handle failure
    alert(`Error: ${error.code} | ${error.description}`);
    console.log(error);
  });

};`

Once I click on that button, the following error occurs:

LOG [TypeError: Cannot read property 'open' of null]

@Jojit-Thomas
Copy link

Hey, I encountered the same error. Have you discovered any solutions for it?

@skbhati199
Copy link

I was facing this issue after I have fixed

Follow these step :

yarn add react-native-razorpay
npx expo prebuild
npx expo run:[ios|android] --device <-- mandatory

@pranav750
Copy link

@skbhati199
Ran the command -

npx expo prebuild
npx expo run:android --device

Build is successful but it is throwing this error

CommandError: Couldn't open Android app with activity "com.anonymous.cc_ui_expo://expo-development-client/?url=http%3A%2F%2F192.168.1.3%3A8081" on device "Resizable_Experimental_API_34".
The app might not be installed, try installing it with: npx expo run:android -d Resizable_Experimental_API_34
Activity class {com.anonymous.cc_ui_expo://expo-development-client/?url=http%3A%2F%2F192.168.1.3%3A8081} does not exist.

Tried starting the app again using

npx expo start

The app is opening but it is again throwing the same error.

[TypeError: Cannot read property 'open' of null]

@vivekshindhe
Copy link
Contributor

vivekshindhe commented Dec 18, 2023

@pranav750 The issue is because after running
npx expo run:android --device
command, when the build failed and you ran the metro server it was in Expo Go mode.

Try running the following commands in order

  1. npx expo start
  2. Press s to switch to development build
  3. Press a to run on android.

@sudhakara11
Copy link

Dear All,

Could anyone able to figure out the issue?

Kindly do the needful

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants