FloPayFloPay
API Reference@flopay/react

FloPayProvider

React context provider that supplies FloPay SDK instances and billing configuration 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()).
paypalFlopayPromise<FloPay> | FloPay | nullNoOptional Stripe FloPay instance used by the Stripe-rendered PayPal fallback. Direct PayPal does not use this prop.
optionsobjectNoProvider configuration. See below.
onInstrument(event: FloInstrumentEvent) => voidNoReceives the versioned, privacy-safe checkout funnel and failure feed for forwarding to your own analytics. Use this when you compose the payment surfaces yourself; FloPayCheckout exposes the same prop and already forwards the instruments raised by the provider it owns. Requires SDK 1.7.0 or later. See Checkout analytics.
childrenReact.ReactNodeYesChild components that will have access to FloPay context.

options

NameTypeDescription
billingApiUrlstringBilling API base URL. Set it here so child components do not need to repeat it.

Behavior

  1. Resolves the flopay promise if one is passed.
  2. Resolves and exposes the optional paypalFlopay instance for the Stripe-rendered PayPal fallback.
  3. Resolves options.billingApiUrl and exposes it to child checkout components.
  4. Forwards provider telemetry into the onInstrument merchant feed.

Example

import { FloPayProvider } from '@flopay/react';
import { loadFloPay } from '@flopay/js';

const flopayPromise = loadFloPay('pk_test_...');

function App() {
  return (
    <FloPayProvider
      flopay={flopayPromise}
      options={{
        billingApiUrl: 'https://api.example.com',
      }}
    >
      <YourCheckout />
    </FloPayProvider>
  );
}

On this page