React Quick Start
Build your first embedded checkout with FloPay in a React application.
React Quick Start
This guide shows the recommended FloPay integration: render FloPayCheckout, let it create the session inline, and keep the payment form embedded on your page.
Prerequisites
- Packages installed (Installation)
- Environment configured (Configuration)
- A FloPay client ID
- A success URL and cancel URL in your app
1. Configure FloPay
Set your FloPay client ID:
Then configure the SDK once at app startup:
This tells the SDK which billing API to use. See Configuration for the supported setup options.
2. Render the Embedded Checkout
The simplest embedded flow matches the demo's one-shot approach: pass createSession instead of a pre-created sessionId.
That's the embedded integration. No pre-created session ID and no separate session-creation API route.
Embedded checkout should be rendered with account.email already populated. The billing session is created with accountData.email, so do not leave it blank. If you only have a temporary address at first, pass it in account.email and replace it later in onBeforeButtonClick.
FloPayCheckout handles everything:
- Posts the
createSessionpayload to the billing API - Uses the returned session data to detect the payment provider and read
gatewayData.publishableKey/gatewayData.paypalPublishableKey - Initializes the FloPay SDK automatically
- Renders the embedded buttons layout with cards, wallets, and PayPal
- Runs the full payment flow: tokenize → create intent → confirm → process → 3DS retry
- Calls
onCompletewith thePaymentResult
successUrl and cancelUrl are still required for embedded checkout because wallet, PayPal, and authentication flows can redirect away from the page and back again.
3. Collect Data Before Rendering
If the customer picks a product, enters an email, or chooses a plan in the UI first, build the final createSession payload in state and pass it to FloPayCheckout only when they're ready to start checkout.
That is the pattern used by the demo's embedded page: collect the product + account data, then render FloPayCheckout with the finished payload.
Next Steps
- FloPayCheckout Guide — all embedded checkout options
- FloPayCheckout API Reference — all props and customization options
- Node.js Quick Start — add webhook handling for the embedded flow
- Theming — customize the checkout UI