full e com code

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 कोड स्कॅन करून पेमेंट करा

UPI QR Code
<input type="text" placeholder="तुमचं नाव" className="border p-2 w-full" value={name} onChange={e => setName(e.target.value)} required /> <input type="email" placeholder="ई-मेल" className="border p-2 w-full" value={email} onChange={e => setEmail(e.target.value)} required /> <input type="text" placeholder="प्रॉडक्ट / ऑर्डर डिटेल्स" className="border p-2 w-full" value={product} onChange={e => setProduct(e.target.value)} required /> <input type="number" placeholder="रक्कम (₹)" className="border p-2 w-full" value={amount} onChange={e => setAmount(e.target.value)} required /> <input type="file" accept="image/*" onChange={e => setFile(e.target.files[0])} className="w-full" required />
{msg &&

{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.

 
Copyright © 2015. SP MART
Blogger Templates