FloPay
API Reference@flopay/js

loadFloPay

The primary entry point for initializing the FloPay client-side SDK.

loadFloPay

Loads and initializes the FloPay SDK. This is the primary entry point for consumer applications. It initializes the underlying payment provider (currently Stripe) and returns a ready-to-use FloPay instance.

function loadFloPay(
  publishableKey: string,
  options?: Omit<FloPayConfig, 'publishableKey'>
): Promise<FloPay>

Parameters

ParameterTypeRequiredDescription
publishableKeystringYesYour FloPay/Stripe publishable key (e.g. pk_test_...).
optionsOmit<FloPayConfig, 'publishableKey'>NoAdditional configuration options.

Options:

NameTypeDescription
billingApiUrlstringBilling API base URL (e.g. https://api.stage.flopay.com). Required for retrieveSession.
localestringLocale code (e.g. "en").
appearanceFloPayAppearanceDefault appearance for all elements.
apiVersionstringAPI version header value.

Returns

Promise<FloPay> -- a fully initialized FloPay instance.

Caching

loadFloPay caches the instance by publishable key. Calling it again with the same key returns the cached instance. Calling with a different key destroys the previous instance and creates a new one.

Errors

Throws FloPayError with type 'validation_error' if publishableKey is empty.

Example

import { loadFloPay } from '@flopay/js';
 
const flopay = await loadFloPay('pk_test_...', {
  billingApiUrl: 'https://api.stage.flopay.com',
  appearance: {
    theme: 'night',
  },
});
 
const elements = flopay.elements();
const cardElement = await elements.create('card');
cardElement.mount('#card-container');

On this page