diff --git a/src/components/MobileOffsetOrder.tsx b/src/components/MobileOffsetOrder.tsx index 8a84124..22bc21e 100644 --- a/src/components/MobileOffsetOrder.tsx +++ b/src/components/MobileOffsetOrder.tsx @@ -204,7 +204,8 @@ export function MobileOffsetOrder({ tons, monetaryAmount, onBack }: Props) { const renderPortfolioPrice = (portfolio: Portfolio) => { try { - const pricePerTon = portfolio.pricePerTon || 18; + // Get the price per ton from the portfolio and round UP to next whole number + const pricePerTon = Math.ceil(portfolio.pricePerTon || 18); return formatCurrency(pricePerTon, currencies.USD); } catch (err) { console.error('Error formatting portfolio price:', err); @@ -212,7 +213,9 @@ export function MobileOffsetOrder({ tons, monetaryAmount, onBack }: Props) { } }; - const offsetCost = monetaryAmount || (portfolio ? actualOffsetTons * (portfolio.pricePerTon || 18) : 0); + // Calculate offset cost using the portfolio price (rounded UP to match display) + const roundedPricePerTon = portfolio ? Math.ceil(portfolio.pricePerTon || 18) : 18; + const offsetCost = monetaryAmount || (portfolio ? actualOffsetTons * roundedPricePerTon : 0); const handleInputChange = (field: keyof typeof formData, value: string) => { setFormData(prev => ({ ...prev, [field]: value })); diff --git a/src/components/OffsetOrder.tsx b/src/components/OffsetOrder.tsx index becbcee..6368e38 100644 --- a/src/components/OffsetOrder.tsx +++ b/src/components/OffsetOrder.tsx @@ -167,7 +167,7 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr const checkoutSession = await createCheckoutSession({ tons: actualOffsetTons, portfolioId: portfolio.id, - pricePerTon: portfolio.pricePerTon || 18, // Pass the actual price from Wren + pricePerTon: roundedPricePerTon, // Pass the rounded-up price that matches calculator display }); logger.info('[OffsetOrder] Checkout session created:', checkoutSession.sessionId); @@ -188,13 +188,13 @@ export function OffsetOrder({ tons, monetaryAmount, onBack, calculatorType }: Pr return formatCurrency(pricePerTon, currencies.USD); } catch (err) { console.error('Error formatting portfolio price:', err); - return formatCurrency(18, currencies.USD); // Updated fallback + return formatCurrency(18, currencies.USD); } }; - // Calculate offset cost using the portfolio price (rounded UP) + // Calculate offset cost using the portfolio price (rounded UP to match display) const roundedPricePerTon = portfolio ? Math.ceil(portfolio.pricePerTon || 18) : 18; - const offsetCost = monetaryAmount || (portfolio ? Math.ceil(actualOffsetTons * roundedPricePerTon) : 0); + const offsetCost = monetaryAmount || (portfolio ? actualOffsetTons * roundedPricePerTon : 0); return (