piyushgarg-dev/react-razorpay ? reverse-engineered prompt

Reverse engineered prompt

Build me a small React TypeScript library that makes it easy to add Razorpay payments to a React app.

I want a simple hook that loads the Razorpay script for me and gives me the loading state, any loading error, and the Razorpay constructor so I can open the payment popup from a button click. It should also include a typed options object for payment details like key, amount, currency, name, description, order id, callback handler, customer info, and theme colors.

Please make the example usage really straightforward, like a payment page with a Pay Now button, a loading message while the script is being fetched, and an error message if it fails. Keep the API clean and easy to understand, and make sure everything is typed properly for React and TypeScript. If you need to check the latest Razorpay docs online while wiring it up, go ahead.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab