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

Razer payment react native---Cannot read property 'open' of undefined #104

Closed 09user closed 6 years ago

09user commented 6 years ago

Hi , Working on razor payment gateway , But getting an error of cannot read property 'OPEN' of undefined, Below is the code used:


<TouchableHighlight onPress={() => {
        var options = {
          description: 'Credits towards consultation',
          image: 'https://i.imgur.com/3g7nmJC.png',
          currency: 'INR',
          key: 'rzp_test_1DP5mmOlF5G5ag',
          amount: '5',
          external: {
            wallets: ['paytm']
          },
          name: 'foo',
          theme: {color: '#F37254'}
        }
        RazorpayCheckout.open(options).then((data) => {
          // handle success
          alert(`Success: ${data.razorpay_payment_id}`);
        }).catch((error) => {
          // handle failure
          console.log("error : "+error)
          alert(`Error: ${error.code} | ${error.description}`);
        });
        RazorpayCheckout.onExternalWalletSelection(data => {
          alert(`External Wallet Selected: ${data.external_wallet} `);
        });
      }}>`
aayush123 commented 6 years ago

Ran into the same issue, realized that I forgot to link the package using react-native link

iThink32 commented 6 years ago

If you face such issue please try the manual linking process specified here ,

https://facebook.github.io/react-native/docs/linking-libraries-ios

or watch our integration videos

https://razorpay.com/docs/ios/integration-videos/

ghost commented 6 years ago

Facing same issue on android as well :(

iThink32 commented 6 years ago

@arjithn please refer the manual linking process for android on react - native docs specified above.

ashwingattani commented 4 years ago

@arjithn / @09user, did you guys find any resolution to this error? My app is working fine on the iOS front but gives undefined error on the Android platform. @iThink32, can you help to provide integration docs for Android as well? Thanks.

Akulvarshney commented 1 year ago

@arjithn / @09user, did you guys find any resolution to this error? My app is working fine on the iOS front but gives undefined error on the Android platform. @iThink32, can you help to provide integration docs for Android as well? Thanks.

same I need help for the same issue. Kindly help me as well. @ashwingattani @iThink32, what is the solution for this.

open is thrown as undefined.

vtech18 commented 10 months ago

Ran into the same issue, realized that I forgot to link the package using react-native link

hiw can we do it in Expo platform

avdhesh75WT commented 7 months ago

You cant do react-native link in expo app

gopikap commented 5 months ago

@Akulvarshney where you able to find a solution? The same happens to me too, saying Error [TypeError: Cannot read property 'open' of null].

Any help would be great.

vivekshindhe commented 5 months ago

The react-native-razorpay package internally uses native libraries for Android and iOS. The error suggests that the native libraries aren't included in the build. During our testing we have been able to resolve this and switching to development build than expo build which allows for the usage of native libraries. Maybe this will help resolve the issue for you folks.

gopikap commented 5 months ago

"react-native-razorpay": "^2.3.0" //Razorpay version I am using "react-native": "0.68.2", //is the react native version i am using We are not using expo. React cli is what we use.

vivekshindhe commented 5 months ago

If it is react cli that means the package wasn't correctly installed. Can you try reinstalling the package? @gopikap

gopikap commented 5 months ago

@vivekshindhe Thank you so much, after re-installation I got the page.