Migrate to local PG & Update Solana Checkout
This commit is contained in:
@@ -19,18 +19,37 @@ interface CryptoCheckoutProps {
|
||||
}
|
||||
|
||||
export default function CryptoCheckout({ amount, currency, txId, onSuccess }: CryptoCheckoutProps) {
|
||||
const [selectedCoin, setSelectedCoin] = useState('USDT');
|
||||
const [selectedCoin, setSelectedCoin] = useState('SOL');
|
||||
const [depositAddress, setDepositAddress] = useState<string>('');
|
||||
const [isVerifying, setIsVerifying] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [status, setStatus] = useState<'waiting' | 'verifying' | 'success' | 'error'>('waiting');
|
||||
|
||||
// Exchange rate mock: 1 USD = 35 TRY, 1 USDT = 1 USD
|
||||
const cryptoAmount = (currency === 'TL' ? (amount / 35) : amount).toFixed(2);
|
||||
const [cryptoAmount, setCryptoAmount] = useState<string>('Hesaplanıyor...');
|
||||
|
||||
useEffect(() => {
|
||||
// Mock address generation
|
||||
setDepositAddress('0x' + Math.random().toString(16).slice(2, 42));
|
||||
async function fetchExchangeRate() {
|
||||
if (currency === 'TL' || currency === 'TRY') {
|
||||
try {
|
||||
const symbol = selectedCoin === 'SOL' ? 'SOLTRY' : 'USDTTRY';
|
||||
const res = await fetch(`https://api.binance.com/api/v3/ticker/price?symbol=${symbol}`);
|
||||
const data = await res.json();
|
||||
const rate = parseFloat(data.price);
|
||||
setCryptoAmount((amount / rate).toFixed(selectedCoin === 'SOL' ? 4 : 2));
|
||||
} catch (error) {
|
||||
// Fallback rate if API fails
|
||||
setCryptoAmount((amount / 5500).toFixed(selectedCoin === 'SOL' ? 4 : 2));
|
||||
}
|
||||
} else {
|
||||
// If already USD or USDT, 1:1 ratio
|
||||
setCryptoAmount(amount.toFixed(2));
|
||||
}
|
||||
}
|
||||
fetchExchangeRate();
|
||||
}, [amount, currency]);
|
||||
|
||||
useEffect(() => {
|
||||
// Use a real valid Solana test wallet so Phantom doesn't say "Invalid Address"
|
||||
setDepositAddress('5pLH1tqZhx8p8WpZ18yr28N42KXB3FXVPzZ9ceCtpBVe');
|
||||
}, [selectedCoin]);
|
||||
|
||||
const handleCopy = () => {
|
||||
@@ -49,7 +68,7 @@ export default function CryptoCheckout({ amount, currency, txId, onSuccess }: Cr
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
txId: txId,
|
||||
merchantAddress: '0x123...MERCHANT_WALLET'
|
||||
merchantAddress: '5pLH1tqZhx8p8WpZ18yr28N42KXB3FXVPzZ9ceCtpBVe' // A placeholder valid Solana Devnet Wallet
|
||||
})
|
||||
});
|
||||
const data = await response.json();
|
||||
@@ -81,7 +100,7 @@ export default function CryptoCheckout({ amount, currency, txId, onSuccess }: Cr
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="text-2xl font-black text-gray-900">{cryptoAmount} <span className="text-xs text-gray-400">{selectedCoin}</span></p>
|
||||
<p className="text-[10px] text-gray-400 font-bold uppercase">Ağ: Polygon (MATIC)</p>
|
||||
<p className="text-[10px] text-gray-400 font-bold uppercase">Ağ: Solana (Devnet)</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -127,7 +146,7 @@ export default function CryptoCheckout({ amount, currency, txId, onSuccess }: Cr
|
||||
<span className="text-[9px] font-black uppercase tracking-widest">Önemli Uyarı</span>
|
||||
</div>
|
||||
<p className="text-[10px] text-blue-800 leading-relaxed font-medium">
|
||||
Lütfen sadece <b>Polygon (PoS)</b> ağı üzerinden gönderim yapın. Yanlış ağ üzerinden gönderilen varlıklar kurtarılamaz.
|
||||
Lütfen sadece test amaçlı <b>Solana (Devnet)</b> ağı üzerinden test SOL'ü gönderimi yapın. Gerçek ağ veya USDT bu ortamda kabul edilmez.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user