FloPay
API Reference@flopay/react

FloPayProvider

React context provider that supplies the FloPay SDK and Elements instances to the component tree.

FloPayProvider

Provides FloPay SDK context to the component tree. Wrap your checkout page (or entire app) with this provider.

function FloPayProvider(props: FloPayProviderProps): React.ReactElement

Props

NameTypeRequiredDescription
flopayPromise<FloPay> | FloPayYesA FloPay instance or a promise that resolves to one (from loadFloPay()).
optionsobjectNoConfiguration applied when creating the elements group. See below.
childrenReact.ReactNodeYesChild components that will have access to FloPay context.

options

NameTypeDescription
localestringLocale code (e.g. "en").
appearanceFloPayAppearanceAppearance overrides for elements.
clientSecretstringClient secret for the PaymentIntent or SetupIntent.
amountnumberTotal amount in smallest currency unit (cents). Used when no clientSecret.
currencystringISO 4217 currency code (lowercase). Used when no clientSecret.
paymentMethodCreation'manual' | 'auto'How payment methods are created. 'manual' (default for cards) or 'auto' (needed for PayPal).

Behavior

  1. Resolves the flopay promise if one is passed.
  2. Creates a FloPayElements group once the FloPay instance is ready.
  3. Recreates elements when appearance, clientSecret, amount, or currency changes.
  4. Cleans up elements on unmount.

Example

import { FloPayProvider } from '@flopay/react';
import { loadFloPay } from '@flopay/js';
 
const flopayPromise = loadFloPay('pk_test_...');
 
function App() {
  return (
    <FloPayProvider
      flopay={flopayPromise}
      options={{
        amount: 4999,
        currency: 'usd',
        appearance: { theme: 'default' },
      }}
    >
      <CheckoutForm sessionId="uuid" billingApiUrl="https://api.example.com" />
    </FloPayProvider>
  );
}

On this page