full e com code
// --- Updated Payment Submission (with order info + email alert simulation) --- import React, { useState } from 'react'; import axios from 'axios';
function PaymentUPI() { const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [product, setProduct] = useState(''); const [amount, setAmount] = useState(''); const [file, setFile] = useState(null); const [msg, setMsg] = useState('');
const handleSubmit = async (e) => { e.preventDefault(); const formData = new FormData(); formData.append('name', name); formData.append('email', email); formData.append('product', product); formData.append('amount', amount); formData.append('screenshot', file);
try {
await axios.post('http://localhost:5000/api/payments', formData);
setMsg('पेमेंट यशस्वी!');
} catch (err) {
setMsg('त्रुटी आली. कृपया पुन्हा प्रयत्न करा.');
}
};
return (
QR कोड स्कॅन करून पेमेंट करा

{msg}
}export default PaymentUPI;
// --- Updated Backend server/index.js --- const Payment = mongoose.model('Payment', new mongoose.Schema({ name: String, email: String, product: String, amount: Number, screenshot: String, status: { type: String, default: 'Pending' }, createdAt: { type: Date, default: Date.now } }));
app.post('/api/payments', upload.single('screenshot'), async (req, res) => { const { name, email, product, amount } = req.body; const screenshot = req.file?.filename; const payment = await Payment.create({ name, email, product, amount, screenshot });
// (Simulated email alert)
console.log(EMAIL SENT to ${email}: पेमेंट प्राप्त झाला! ₹${amount} - ${product}
);
res.json(payment); });
0 comments :
Please do not enter any spam link in the comment box.