Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ This guide will walk you through how to build a custom user interface for a chec
// Confirm checkout with payment method
await confirm({ paymentSourceId })
// Complete checkout and redirect
finalize({ redirectUrl: '/dashboard' })
await finalize({
navigate: () => navigate('/dashboard'),
})
} catch (error) {
console.error('Payment failed:', error)
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ For the custom flow that allows users to add a new payment method to their accou
// Confirm checkout with payment method
await confirm(data)
// Complete checkout and redirect
finalize({ redirectUrl: '/dashboard' })
await finalize({
navigate: () => navigate('/dashboard'),
})
} catch (error) {
console.error('Payment failed:', error)
} finally {
Expand Down
8 changes: 5 additions & 3 deletions docs/reference/hooks/use-checkout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ There are two ways to use `useCheckout()`:
---

- `finalize()`
- `(params?: { redirectUrl: string }) => void`
- `(params?: { navigate?: SetActiveNavigate }) => void`

A function that finalizes the checkout process. Can optionally accept a `redirectUrl` to navigate the user to upon completion.
A function that finalizes the checkout process. Can optionally accept a `navigate` function to redirect the user after completion.

---

Expand Down Expand Up @@ -273,7 +273,9 @@ The `useCheckout()` hook can be used with a context provider for managing state
})
// Calling `.finalize` enables you to sync the client-side state with the server-side state of your users.
// It revalidates all authorization checks computed within server components.
finalize({ redirectUrl: '/dashboard' })
await finalize({
navigate: () => navigate('/dashboard'),
})
} catch (error) {
console.error('Payment failed:', error)
} finally {
Expand Down
4 changes: 3 additions & 1 deletion docs/reference/hooks/use-payment-methods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ function CheckoutPaymentSelection() {
// Confirm checkout with selected payment method
await confirm({ paymentSourceId: paymentMethodId })
// Complete checkout and redirect
finalize({ redirectUrl: '/dashboard' })
await finalize({
navigate: () => navigate('/dashboard'),
})
} catch (error) {
console.error('Payment failed:', error)
}
Expand Down