@@ -31,6 +31,7 @@ import {
3131} from "../../../constants/rozoConfig" ;
3232import { useRozoPay } from "../../../hooks/useDaimoPay" ;
3333import { usePayoutPolling } from "../../../hooks/usePayoutPolling" ;
34+ import { usePusherPayout } from "../../../hooks/usePusherPayout" ;
3435import { useSupportedChains } from "../../../hooks/useSupportedChains" ;
3536import styled from "../../../styles/styled" ;
3637import Button from "../../Common/Button" ;
@@ -58,6 +59,14 @@ const Confirmation: React.FC = () => {
5859 const paymentCompletedSent = React . useRef < string | null > ( null ) ;
5960 const payoutCompletedSent = React . useRef < string | null > ( null ) ;
6061
62+ // Local state for Pusher payout transaction hash
63+ const [ pusherPayoutTxHash , setPusherPayoutTxHash ] = useState <
64+ string | undefined
65+ > ( undefined ) ;
66+ const [ pusherPayoutTxHashUrl , setPusherPayoutTxHashUrl ] = useState <
67+ string | undefined
68+ > ( undefined ) ;
69+
6170 const showProcessingPayout = useMemo ( ( ) => {
6271 const { payParams, tokenMode } = paymentStateContext ;
6372
@@ -165,7 +174,7 @@ const Confirmation: React.FC = () => {
165174
166175 // Use payout polling hook
167176 const { payoutLoading, payoutTxHash, payoutTxHashUrl } = usePayoutPolling ( {
168- enabled : showProcessingPayout ,
177+ enabled : false ,
169178 rozoPaymentId,
170179 order,
171180 done,
@@ -174,6 +183,42 @@ const Confirmation: React.FC = () => {
174183 triggerResize,
175184 } ) ;
176185
186+ // Use Pusher hook for real-time status updates
187+ const enablePusher = context . options ?. enablePusher ?? false ;
188+ usePusherPayout ( {
189+ enabled : enablePusher ,
190+ rozoPaymentId,
191+ onPayoutCompleted : ( payload ) => {
192+ context . log ( "[CONFIRMATION] Pusher payout completed:" , payload ) ;
193+ // If we receive payout completed from Pusher and have the destination txhash,
194+ // we can use it to update the payout state
195+ if ( payload . destination_txhash && rozoPaymentId ) {
196+ const payoutKey = `${ payload . destination_txhash } -${ rozoPaymentId } ` ;
197+ if ( payoutCompletedSent . current !== payoutKey ) {
198+ payoutCompletedSent . current = payoutKey ;
199+
200+ // Update local state for UI display
201+ setPusherPayoutTxHash ( payload . destination_txhash ) ;
202+
203+ // Generate transaction URL if we have the order
204+ if ( order ) {
205+ const destChainId = getOrderDestChainId ( order ) ;
206+ const txUrl = getChainExplorerTxUrl (
207+ destChainId ,
208+ payload . destination_txhash
209+ ) ;
210+ setPusherPayoutTxHashUrl ( txUrl ) ;
211+ }
212+
213+ // Update payment state
214+ setPaymentPayoutCompleted ( payload . destination_txhash , rozoPaymentId ) ;
215+ triggerResize ( ) ;
216+ }
217+ }
218+ } ,
219+ log : context . log ,
220+ } ) ;
221+
177222 /**
178223 * Sets the payment completed state.
179224 * This is called when the payment is confirmed and the transaction hash is available.
@@ -297,14 +342,17 @@ const Confirmation: React.FC = () => {
297342 < ModalBody >
298343 { payoutLoading ? (
299344 < LoadingText > Processing payout...</ LoadingText >
300- ) : payoutTxHashUrl && payoutTxHash ? (
345+ ) : ( pusherPayoutTxHashUrl && pusherPayoutTxHash ) ||
346+ ( payoutTxHashUrl && payoutTxHash ) ? (
301347 < Link
302- href = { payoutTxHashUrl }
348+ href = { pusherPayoutTxHashUrl || payoutTxHashUrl || "#" }
303349 target = "_blank"
304350 rel = "noopener noreferrer"
305351 style = { { fontSize : 14 , fontWeight : 400 } }
306352 >
307- { getAddressContraction ( payoutTxHash ) }
353+ { getAddressContraction (
354+ pusherPayoutTxHash || payoutTxHash || ""
355+ ) }
308356 < ExternalIcon />
309357 </ Link >
310358 ) : (
0 commit comments