ashwamegh / razorpay-react-demo

Razorpay React.js bindings
https://ashwamegh.github.io/razorpay-react-demo/
MIT License
18 stars 8 forks source link

'Razorpay' is not defined #2

Closed aliasgar-choolawala closed 6 years ago

aliasgar-choolawala commented 6 years ago

Hi, I have defined the checkout.js script in index.html in public folder. The components are in the src folder, and index.js is also in the src folder.

Got the error 'Razorpay' is not defined when trying to run the project.

Any idea about this?

daudtacto commented 6 years ago

@aliasgar-choolawala, I am also facing this issue. I have used redux for my project with structured folder. Not able to access new razorpay() class although i have included CDN in public/index.html.

@shashank7200 it will be much appreciated if you help me out.

Daudsayyed commented 6 years ago

@aliasgar-choolawala @daudtacto i got similar issue and i made it by working as const rzp1 = new window.Razorpay(options); //instead of new Razorpay(options) rzp1.open();

ashwamegh commented 6 years ago

const rzp1 = new window.Razorpay(options); //instead of new Razorpay(options) this seems to be a possible solution for this. I will just rewrite the logic.

ashwamegh commented 6 years ago

@aliasgar-choolawala @daudtacto @Daudsayyed I am just closing this issue, If you face any problem, just create a new issue. :+1:

muftisamiullah commented 3 years ago

any other way of doing the same without using window

saalim-bhatkar commented 1 year ago

window

Thanks a lots

Chelsea67jain commented 1 year ago

I am getting an error window.Razorpay is not defined in the code below, and I have written this code inside useEffect const script = document.createElement('script') script.src = "https://checkout.razorpay.com/v1/checkout.js" script.async = true document.body.appendChild(script) const rzp1 = new window.Razorpay(options); rzp1.open(); setLoading(!loading);

ashwamegh commented 1 year ago

@Chelsea67jain You are adding your declaration of the script to be run Asynchronously, In that case, the Razorpay object will not be immediately available to the window. You'll have to wait for the script to be loaded before you execute the Razorpay logic.