Examples
Delegated Mode (Custom Backend)
Use onTokenizedBody to handle payment processing on your own backend with full control over 3DS retry.
By default, CheckoutForm and SplitCardForm handle the entire payment flow internally -- tokenize, create intent, confirm, and call processPayment on the billing API. In delegated mode, you provide onTokenizedBody to intercept after tokenization and handle backend submission yourself.
This is useful when you need custom backend logic, additional validation, or want to call your own payment processing endpoint.
How It Works
- The user fills in card details and clicks submit
CheckoutFormvalidates the fields, tokenizes the card, and confirms the PaymentIntent- Instead of calling
processPaymentinternally, it calls youronTokenizedBodycallback with theTokenizedBody - You send the data to your own backend
- If your backend returns
3ds_required, callformRef.current.handleNextAction(clientSecret)to show the 3DS challenge - After 3DS completes, retry your backend call
Key Props for Delegated Mode
| Prop | Description |
|---|---|
onTokenizedBody | Callback receiving the tokenized payment data. Enables delegated mode. |
isProcessing | Controls the form's loading state externally (disables submit button). |
error | Displays an error message in the form from your external logic. |
ref | Exposes handleNextAction(clientSecret) for triggering 3DS challenges. |
The same pattern works with SplitCardForm -- it accepts the same onTokenizedBody, isProcessing, error, and ref props.