Compare commits
No commits in common. "c2cc4202a7fec4b38cf95b112b011dfd22392aa6" and "b01e5bbdf949a05807ae28f7dcffa6fd35c72419" have entirely different histories.
c2cc4202a7
...
b01e5bbdf9
22
src/App.tsx
22
src/App.tsx
|
|
@ -638,9 +638,6 @@ export default function App() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let isPaymentCancelled = false;
|
|
||||||
let isPaymentCompleted = false;
|
|
||||||
|
|
||||||
const rzpOptions = {
|
const rzpOptions = {
|
||||||
key: razorpayKeyId,
|
key: razorpayKeyId,
|
||||||
amount: Math.round(grand_total * 100),
|
amount: Math.round(grand_total * 100),
|
||||||
|
|
@ -654,25 +651,7 @@ export default function App() {
|
||||||
email: loggedInUser?.email || '',
|
email: loggedInUser?.email || '',
|
||||||
contact: loggedInUser?.phone_number || loggedInUser?.phone || ''
|
contact: loggedInUser?.phone_number || loggedInUser?.phone || ''
|
||||||
},
|
},
|
||||||
modal: {
|
|
||||||
confirm_close: true,
|
|
||||||
escape: true,
|
|
||||||
backdropclose: false,
|
|
||||||
ondismiss: function () {
|
|
||||||
if (!isPaymentCompleted) {
|
|
||||||
isPaymentCancelled = true;
|
|
||||||
setCheckoutLoading(false);
|
|
||||||
console.log('Razorpay payment modal dismissed / cancelled by user.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handler: async function (response: any) {
|
handler: async function (response: any) {
|
||||||
if (isPaymentCancelled) {
|
|
||||||
console.warn('Payment was cancelled by the user. Verification ignored.');
|
|
||||||
setCheckoutLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
isPaymentCompleted = true;
|
|
||||||
setCheckoutLoading(true);
|
setCheckoutLoading(true);
|
||||||
try {
|
try {
|
||||||
const verifyRes = await axios.post(`${API_BASE}/api/checkout/verify`, {
|
const verifyRes = await axios.post(`${API_BASE}/api/checkout/verify`, {
|
||||||
|
|
@ -730,7 +709,6 @@ export default function App() {
|
||||||
|
|
||||||
const razorpayInstance = new (window as any).Razorpay(rzpOptions);
|
const razorpayInstance = new (window as any).Razorpay(rzpOptions);
|
||||||
razorpayInstance.on('payment.failed', function (resp: any) {
|
razorpayInstance.on('payment.failed', function (resp: any) {
|
||||||
setCheckoutLoading(false);
|
|
||||||
alert(`Payment failed! Reason: ${resp.error.description}`);
|
alert(`Payment failed! Reason: ${resp.error.description}`);
|
||||||
});
|
});
|
||||||
razorpayInstance.open();
|
razorpayInstance.open();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue