added discount for vertex payments
This commit is contained in:
parent
0dfff9c4d8
commit
33774d1614
@ -425,6 +425,8 @@ export const GpuPaymentModal = ({ isOpen, onClose, gpu }: GpuPaymentModalProps)
|
||||
setErrorMsg(null);
|
||||
setSuccessMsg(null);
|
||||
|
||||
let priceUsd = selectedToken === "VERTEX" ? gpu.price_usd * 0.9 : gpu.price_usd;
|
||||
|
||||
try {
|
||||
if (!userEmail || !isValidEmail(userEmail)) {
|
||||
throw new Error("Please enter a valid email address for your receipt.");
|
||||
@ -475,7 +477,8 @@ export const GpuPaymentModal = ({ isOpen, onClose, gpu }: GpuPaymentModalProps)
|
||||
tokenPrice = customTokenPrice || 0.5;
|
||||
}
|
||||
|
||||
const tokenAmount = (gpu.price_usd / tokenPrice).toFixed(tokenDecimals);
|
||||
const priceUsd = selectedToken === "VERTEX" ? gpu.price_usd * 0.9 : gpu.price_usd;
|
||||
const tokenAmount = (priceUsd / tokenPrice).toFixed(tokenDecimals);
|
||||
amountDisplay = `${tokenAmount} ${selectedToken}`;
|
||||
|
||||
// Get or create token accounts using the correct method
|
||||
@ -540,7 +543,7 @@ export const GpuPaymentModal = ({ isOpen, onClose, gpu }: GpuPaymentModalProps)
|
||||
email: userEmail,
|
||||
product: gpu.title,
|
||||
price_hour: gpu.price_per_hour,
|
||||
price: gpu.price_usd.toFixed(2)
|
||||
price: priceUsd.toFixed(2)
|
||||
});
|
||||
|
||||
const generatedOrderId = `${Math.floor(Math.random() * 900) + 100}-${Math.floor(Math.random() * 900) + 100}-${Math.floor(Math.random() * 900) + 100}`;
|
||||
@ -550,7 +553,7 @@ export const GpuPaymentModal = ({ isOpen, onClose, gpu }: GpuPaymentModalProps)
|
||||
{
|
||||
gpu: `${gpu.id} ${gpu.title}`,
|
||||
user_email: userEmail,
|
||||
amount_usd: gpu.price_usd,
|
||||
amount_usd: priceUsd,
|
||||
token_used: tokenUsed,
|
||||
token_amount: amountDisplay,
|
||||
token_tx_signature: txId,
|
||||
@ -573,7 +576,7 @@ export const GpuPaymentModal = ({ isOpen, onClose, gpu }: GpuPaymentModalProps)
|
||||
{
|
||||
gpu: `${gpu.id} ${gpu.title}`,
|
||||
user_email: userEmail,
|
||||
amount_usd: gpu.price_usd,
|
||||
amount_usd: priceUsd,
|
||||
token_used: selectedToken,
|
||||
status: "failed",
|
||||
error_message: err.message || "Unknown error",
|
||||
@ -593,6 +596,10 @@ export const GpuPaymentModal = ({ isOpen, onClose, gpu }: GpuPaymentModalProps)
|
||||
};
|
||||
|
||||
if (!isOpen) return null;
|
||||
const displayPrice = selectedToken === 'VERTEX'
|
||||
? (gpu.price_usd * 0.9).toFixed(2)
|
||||
: gpu.price_usd.toFixed(2);
|
||||
|
||||
|
||||
// Show failure screen if payment failed
|
||||
if (paymentFailure) {
|
||||
@ -725,7 +732,7 @@ export const GpuPaymentModal = ({ isOpen, onClose, gpu }: GpuPaymentModalProps)
|
||||
<div className="flex justify-between items-center p-3 w-full">
|
||||
<span className="text-base font-medium text-white">Total Price</span>
|
||||
<div className="flex gap-3 items-center">
|
||||
<span className="text-base font-bold text-[#0CE77E]">${gpu.price_usd}</span>
|
||||
<span className="text-base font-bold text-[#0CE77E]">${displayPrice}</span>
|
||||
<span className="text-base text-[#0CE77E]">(~{currentTokenAmount} {selectedToken})</span>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user