Hooks
React hooks for checkout state, field management, and payment submission.
BiasProvider
<BiasProvider>
Context provider that initializes the checkout store and makes all hooks available to child components.
Props
- Name
clientSecret
- Type
- string,
- Name
onComplete
- Type
- () => void,
- Name
apiBaseUrl
- Type
- string,
- Name
children
- Type
- ReactNode,
useField
useField(type, options?)
Manage a single value field. Returns the field state, current value, and setter functions.
Parameters
- Name
type
- Type
- ValueFieldType,
- Name
options
- Type
- object,
- Properties
Returns
An object with:
state—ValueFieldStatus<T>withvalue,valid,error,focusedvalue— the current field valuesetValue(value)— set the field valuevalidate()— trigger validationsetState(partial)— merge partial state
useAttemptPayment
useAttemptPayment()
Returns
A () => void function that validates all fields and submits the payment if the form is valid.
useIsSubmittable
useIsSubmittable()
Returns
boolean — true when all required frame fields have encrypted data and all required value fields are valid.
useSubmitState
useSubmitState()
Returns
{ loading: boolean; success: boolean } — loading is true while the payment request is in flight. success is true after the payment succeeds.
usePaymentError
usePaymentError()
Returns
string | null — the payment error message, or null if there is no error.
useSelectedPaymentMethod
useSelectedPaymentMethod()
Returns
PaymentMethodType — "card" or "us_bank_account".
useSetSelectedPaymentMethod
useSetSelectedPaymentMethod()
Returns
(method: PaymentMethodType) => void — a function to change the selected payment method.
useCheckoutSession
useCheckoutSession()
Returns
CheckoutSession | undefined — the current checkout session object. undefined until the session loads.
useOnComplete
useOnComplete(callback)
Register a completion callback. Alternative to the onComplete prop on BiasProvider. The callback is cleaned up when the component unmounts.
Parameters
- Name
callback
- Type
- () => void,
useClientSecret
useClientSecret()
Returns
string — the client secret passed to BiasProvider.
useFieldState
useFieldState()
Returns
UnifiedFieldState — the current state of every field.
useBiasContext
useBiasContext()
Access the raw Bias context. Intended for advanced use cases. Throws if called outside BiasProvider.
Returns
The internal BiasContextValue object with access to the store, subscriber, and snapshot.
useThemeVariables
useThemeVariables(variables)
Convert a ThemeVariables object into a Record<string, string> of CSS custom properties suitable for a style attribute.
Parameters
- Name
variables
- Type
- ThemeVariables | undefined,
Returns
Record<string, string> — CSS custom properties with --bias- prefix. Null/undefined values are filtered out.