I have below code
import React, { useEffect } from 'react';
const PayByRazorPay = () => {
const options = {
key: 'YOUR_KEY',
amount: '100', // = INR 1
name: 'Acme shop',
description: 'some description',
image: 'https://cdn.razorpay.com/logos/7K3b6d18wHwKzL_medium.png',
handler: function(response) {
alert(response.razorpay_payment_id);
},
prefill: {
name: 'Gaurav',
contact: '9999999999',
email: 'demo@demo.com'
},
notes: {
address: 'some address'
},
theme: {
color: 'blue',
hide_topbar: false
}
};
const openPayModal = () => {
var rzp1 = new window.Razorpay(options);
rzp1.open();
};
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://checkout.razorpay.com/v1/checkout.js';
script.async = true;
document.body.appendChild(script);
}, []);
return (
<>
<button onClick={openPayModal}>Pay with Razorpay</button>
</>
);
};
export default PayByRazorPay;
The above code is working fine... But I am not able to figure out how to handle failed response as well as when user simply click the razorpay popup...
Please advise..
Thanks