11import { Box , Heading } from '@biom3/react' ;
22import { useCallback , useContext , useEffect } from 'react' ;
33import { useTranslation } from 'react-i18next' ;
4+ import { parseUnits } from 'ethers' ;
45import { fetchRiskAssessmentV2 , isSingleAddressSanctioned , SalePaymentTypes } from '@imtbl/checkout-sdk' ;
56
67import {
@@ -34,6 +35,7 @@ import { ViewContext, ViewActions, SharedViews } from '../../../context/view-con
3435import { useHandover } from '../../../lib/hooks/useHandover' ;
3536import { errorToString , getRemoteRive } from '../../../lib/utils' ;
3637import { ConnectLoaderContext } from '../../../context/connect-loader-context/ConnectLoaderContext' ;
38+ import { getPricingBySymbol } from '../utils/pricing' ;
3739
3840type OrderSummaryProps = {
3941 subView : OrderSummarySubViews ;
@@ -52,6 +54,8 @@ export function OrderSummary({ subView }: OrderSummaryProps) {
5254 setPaymentMethod,
5355 environment,
5456 paymentMethod,
57+ orderQuote,
58+ items,
5559 } = useSaleContext ( ) ;
5660
5761 const { connectLoaderState } = useContext ( ConnectLoaderContext ) ;
@@ -100,6 +104,18 @@ export function OrderSummary({ subView }: OrderSummaryProps) {
100104
101105 const { type, fundingItem } = fundingBalance ;
102106
107+ // Calculate total amount from all order items for risk assessment
108+ // Based on how item prices are calculated in OrderItems.tsx
109+ const totalAmount = items . reduce ( ( total , item ) => {
110+ const pricing = getPricingBySymbol (
111+ fundingItem . token . symbol ,
112+ orderQuote ?. products [ item . productId ] ?. pricing ,
113+ cryptoFiatState . conversions ,
114+ ) ;
115+ const itemAmount = pricing ?. amount || 0 ;
116+ return total + itemAmount ;
117+ } , 0 ) ;
118+
103119 // Perform sanctions check once we have valid asset and amount data
104120 const address = await ( await provider ?. getSigner ( ) ) ?. getAddress ( ) ;
105121
@@ -114,7 +130,7 @@ export function OrderSummary({ subView }: OrderSummaryProps) {
114130 const riskAssessmentData = [ {
115131 address,
116132 tokenAddr : fundingItem . token . address ,
117- amount : fundingItem . fundsRequired . amount ,
133+ amount : parseUnits ( totalAmount . toString ( ) , fundingItem . token . decimals ) ,
118134 } ] ;
119135
120136 const riskAssessment = await fetchRiskAssessmentV2 ( riskAssessmentData , checkout . config ) ;
0 commit comments