FloPayCheckout
The recommended way to add payments — a single component that handles everything.
FloPayCheckout Guide
FloPayCheckout is the fastest way to integrate FloPay. One component handles session fetching, Stripe initialization, card fields, wallets, PayPal, 3DS, and checkout modes — no manual wiring needed.
Quick Start
That's it. The component automatically:
- Fetches the checkout session from the billing API
- Reads the Stripe publishable key from
gatewayData.publishableKey(card, Apple Pay, Google Pay) - Reads the dedicated PayPal publishable key from
gatewayData.paypalPublishableKey(PayPal). When this field isnullor missing, the PayPal button is hidden — there is no fallback to the primary key. - Initializes one Stripe instance per key (two when the keys differ)
- Renders card fields, Apple Pay, Google Pay, and PayPal
- Handles 3DS authentication
- Calls
onCompletewhen payment succeeds
Environment Setup
FloPayCheckout needs to know which billing API to call. Choose one:
Option A: configureFlopay() (recommended)
Call this once at app startup, for example in app/layout.tsx or _app.tsx.
Option B: Explicit prop
Checkout Modes
Full Mode (default)
Shows the complete payment form — card fields, wallets, PayPal.
Confirm Mode
Uses a saved payment method. Shows a single "Confirm Purchase" button. Falls back to full mode if payment fails.
Customize the confirm button:
Auto Mode
Automatically submits with a saved payment method — no user interaction. Falls back to full mode if it fails.
Layout Modes
Default Layout
All payment methods visible together: wallets on top, divider, then card fields below.
Buttons Layout
Payment methods shown as stacked buttons. Clicking "Credit / Debit Card" expands into the card form with a back button and title.
Theme Presets
Four built-in themes for the buttons layout:
Custom Styles
Override individual elements with buttonsStyles:
Custom Card Button Content
Use cardButtonContent to replace the default card button body with your own React content:
Use cardButtonContent for the inner content and buttonsStyles.cardButton for the outer button container styles.
Buttons Layout Header Slots
Use cardBackButtonContent and cardTitleContent to replace the default "Go back" and "Secure card checkout" text in the expanded card form header. Pass '' when you want to remove the text completely.
cardTitleContent also replaces the standalone title in the default card form layout.
For dark backgrounds, use cardInputColor, cardInputPlaceholderColor, and cardInputBackground to style the Stripe Element text inside the iframe:
See the full ButtonsLayoutStyles reference for all available properties.
Inline Session Creation (One-Shot)
Skip the backend API route entirely — create the session and render the checkout in one component:
No sessionId needed — the component creates the session, initializes the payment provider, and renders the form automatically.
For embedded checkout, include createSession.account.email in the initial payload. If you only have a temporary value such as test@email.com, pass it first and then replace it in onBeforeButtonClick before the card flow continues.
Tracking Button Clicks
Fire GTM events when users interact with payment buttons:
method values: 'card', 'paypal', 'apple_pay', 'google_pay'.
Before Card Button Click
Use onBeforeButtonClick when you need to do async work before the credit card button continues, such as confirming checkout details or replacing a temporary email address:
onBeforeButtonClick is credit card only. It runs only for the "Credit / Debit Card" button in layout="buttons". It does not run for PayPal, Apple Pay, or Google Pay. If you need required data before every payment method, collect it before rendering FloPayCheckout.
Returning false cancels the card click. Throwing routes the error through onError. When createSession is used, the returned patch refreshes the card flow with the merged session draft. createSession.account.email should already be present when the embedded checkout renders; use this hook to update it, not to skip it.
Decline Events
Use onDecline when you want GTM or analytics events for declined payments, failed 3DS, PayPal cancellation, or wallet dismissal:
Payment Methods
Apple Pay & Google Pay
Enabled by default. Only renders on supported devices/browsers.
Wallet buttons depend on Stripe domain registration. Apple Pay also needs the Apple association file. See the Apple Pay Setup and Google Pay Setup guides.
PayPal
Enabled by default. Requires PayPal to be enabled on the Stripe account. Handles redirects automatically.
AVS (Address Verification)
Enable AVS to collect the user's country and postal/ZIP code. When enabled, billing_details are passed to Stripe's createPaymentMethod() so Stripe can run postal code and address verification checks automatically.
Basic Setup
The country dropdown defaults to the session's customer.country value (typically resolved from the user's IP by your backend). If no country is provided, it defaults to US.
Country from GEO/IP Lookup
Pass the user's country in the session creation params. The SDK pre-fills the dropdown:
The dropdown shows "United Kingdom" and the postal code label says "Postcode" instead of "ZIP Code".
Dynamic Labels
The postal code field label adapts to the selected country:
| Country | Label |
|---|---|
| US | ZIP Code |
| GB, AU, NZ | Postcode |
| CA | Postal Code |
| IE | Eircode |
| All others | Postal Code |
AVS Field Layout
By default, country and postal code sit side-by-side in a row. Switch to stacked:
Theming AVS Fields
AVS fields inherit from the card input styles. Override individually with countrySelect and zipInput in buttonsStyles:
How It Works
- User selects country and enters postal code in the form
- On submit,
billing_details(name + address with country and postal_code) are passed to Stripe'screatePaymentMethod() - Stripe runs AVS checks automatically when billing details are present
- The
accountData.zipandaccountData.countryare also sent to your backend in the process request - Configure Stripe Dashboard → Radar → Rules to block or allow based on AVS results (e.g., "Block if postal code check fails")
AVS is performed by Stripe at payment confirmation time. The SDK sends the billing details — your Stripe Radar rules determine whether to block, allow, or flag based on the verification result. No backend code changes are needed for basic AVS.
Error Handling
Suppress the built-in error UI and handle it yourself:
Custom Loading State
Full Example
See the FloPayCheckout Example for a complete checkout page with order summary, discount timer, and all props configured.
Next Steps
- API Reference — full props table
- Theming — customize card field appearance
- Apple Pay Setup — domain verification
- Google Pay Setup — Stripe payment method domains
- AVS (Address Verification) — postal code verification setup
- 3D Secure — how 3DS authentication works