import React, { useState } from "react"; const MIN_AMOUNT = 1.0; // Minimum allowed amount const GooglePayUPIButton = ({ upiId = "paytmqr6q5qpv@ptys", name = "Pozomind Technologies Private Limited", note = "Test Payment", merchantCode = "7372", merchandId = "BCR2DN7T5GJJ7JSR" }) => { const [amount, setAmount] = useState(""); const [error, setError] = useState(""); const handlePayment = () => { const amt = parseFloat(amount); // ✅ Validate amount if (isNaN(amt) || amt < MIN_AMOUNT) { setError(`Please enter a valid amount (minimum ₹${MIN_AMOUNT})`); return; } setError(""); // ✅ Generate a unique transaction reference const transactionRef = `TXN${Date.now()}`; // ✅ Universal UPI scheme const upiLink = `upi://pay?pa=${encodeURIComponent( upiId )}&pn=${encodeURIComponent(name)}&mid=${encodeURIComponent( "AzqifC58839792984360" )}&tn=${encodeURIComponent(note)}&am=${encodeURIComponent( amt.toFixed(2) )}&cu=INR`; console.log("Generated UPI Link:", upiLink); // ✅ Open directly in any UPI app window.location.href = upiLink; }; return (
Enter the amount:
setAmount(e.target.value)} placeholder={`₹${MIN_AMOUNT} or more`} style={styles.input} /> {error &&{error}
}Works with Google Pay, PhonePe, Paytm, and other UPI apps.