@@ -65,11 +65,6 @@ export function useCancelPayment() {
6565}
6666
6767interface UsePaymentStatusOptions {
68- /**
69- * Polling interval in milliseconds
70- * @default 2000 (2 seconds)
71- */
72- pollingInterval ?: number ;
7368 /**
7469 * Whether to enable the query
7570 * @default true
@@ -87,19 +82,14 @@ interface UsePaymentStatusOptions {
8782 * Polls until payment reaches a final state (isFinal === true).
8883 * Unknown statuses from the API are normalized to "failed".
8984 * @param paymentId - The payment ID to check status for
90- * @param options - Query options including polling interval
85+ * @param options - Query options
9186 * @returns Query result with payment status data
9287 */
9388export function usePaymentStatus (
9489 paymentId : string | null | undefined ,
9590 options : UsePaymentStatusOptions = { } ,
9691) {
97- const {
98- pollingInterval = 2000 ,
99- enabled = true ,
100- onTerminalState,
101- ...queryOptions
102- } = options ;
92+ const { enabled = true , onTerminalState } = options ;
10393
10494 const hasCalledCallback = useRef ( false ) ;
10595 const callbackRef = useRef ( onTerminalState ) ;
@@ -134,12 +124,15 @@ export function usePaymentStatus(
134124 if ( data ?. isFinal ) {
135125 return false ;
136126 }
137- return pollingInterval ;
127+ const pollInMs = data ?. pollInMs ;
128+ if ( typeof pollInMs !== "number" || ! Number . isFinite ( pollInMs ) || pollInMs <= 0 ) {
129+ return 2000 ;
130+ }
131+ return pollInMs ;
138132 } ,
139133
140134 // Let failed requests retry naturally
141135 retry : 3 ,
142- ...queryOptions ,
143136 } ) ;
144137
145138 // Handle terminal state callback
0 commit comments