FloPay
API Reference@flopay/shared

Types

All TypeScript interfaces and type aliases exported by @flopay/shared.

Appearance

FloPayThemeVariables

Theme variables that map to CSS custom properties on FloPay elements.

NameTypeRequiredDescription
colorPrimarystringNoPrimary brand color.
colorBackgroundstringNoBackground color for elements.
colorTextstringNoText color.
colorDangerstringNoColor for error states.
borderRadiusstringNoBorder radius (e.g. "8px").
fontFamilystringNoFont family stack.
fontSizeBasestringNoBase font size (e.g. "16px").
spacingUnitstringNoBase spacing unit (e.g. "4px").

FloPayAppearance

Controls the visual appearance of all FloPay elements.

NameTypeRequiredDescription
theme'default' | 'flat' | 'night' | 'none'NoPredefined theme to apply.
variablesFloPayThemeVariablesNoCustom theme variable overrides.
rulesRecord<string, Record<string, string>>NoCSS-like rules keyed by selector (e.g. ".Input", ".Label").

Checkout Session

Customer

A customer attached to a checkout session.

NameTypeRequiredDescription
idstringYesCustomer ID.
emailstringYesCustomer email.
firstNamestringNoFirst name.
lastNamestringNoLast name.
genderstringNoGender.
citystringNoCity.
statestringNoState or province.
countrystringNoCountry code.
zipstringNoPostal / ZIP code.

RecurringInterval

Recurring interval configuration for subscription line items.

NameTypeRequiredDescription
interval'month' | 'year'YesBilling interval.
intervalCountnumberNoNumber of intervals between billings.

PriceData

Inline product data when no pre-created price is referenced.

NameTypeRequiredDescription
currencystringYesISO 4217 currency code.
unitAmountnumberYesPrice per unit in smallest currency unit.
productData{ name: string; description?: string }YesProduct name and optional description.
recurringRecurringIntervalNoRecurring billing configuration.

LineItem

A single line item within a checkout session.

NameTypeRequiredDescription
pricestringNoReference to a pre-created price object on the provider.
priceDataPriceDataNoInline price data (used when no price reference exists).
quantitynumberYesQuantity of this line item.

CheckoutSession

Represents a FloPay checkout session.

NameTypeRequiredDescription
idstringYesSession ID.
clientSecretstringYesClient secret for client-side confirmation.
mode'payment' | 'subscription' | 'setup'YesSession mode.
status'open' | 'complete' | 'expired'YesCurrent session status.
amountnumberYesTotal amount in smallest currency unit.
currencystringYesISO 4217 currency code.
lineItemsLineItem[]NoLine items in the session.
customerCustomerNoCustomer attached to the session.
metadataRecord<string, string>NoArbitrary key-value metadata.

Payment Results

PaymentResult

The result of a payment confirmation attempt.

NameTypeRequiredDescription
status'succeeded' | 'processing' | 'requires_action' | 'failed'YesPayment status.
paymentIntentIdstringNoID of the PaymentIntent.
errorFloPayErrorNoError if payment failed.

ConfirmPaymentParams

Parameters for confirming a payment.

NameTypeRequiredDescription
clientSecretstringYesClient secret of the PaymentIntent or SetupIntent.
returnUrlstringNoRedirect URL after 3-D Secure or wallet authentication.

CreatePaymentMethodResult

Result from creating a payment method (tokenizing card fields).

NameTypeRequiredDescription
paymentMethodIdstring | nullYesThe created payment method ID, or null on failure.
errorFloPayErrorNoError if tokenization failed.

ConfirmCardPaymentParams

Parameters for confirming a card payment with a known client secret.

NameTypeRequiredDescription
clientSecretstringYesClient secret of the PaymentIntent.
paymentMethodIdstringYesID of the payment method to confirm with.

ConfirmCardPaymentResult

Result from confirming a card payment.

NameTypeRequiredDescription
status'succeeded' | 'processing' | 'requires_action' | 'requires_capture' | 'failed'YesConfirmation status.
paymentIntentIdstringNoID of the PaymentIntent.
paymentMethodIdstringNoID of the payment method used.
errorFloPayErrorNoError if confirmation failed.

Elements

ElementType

type ElementType =
  | 'payment'
  | 'card'
  | 'cardNumber'
  | 'cardExpiry'
  | 'cardCvc'
  | 'address';

The type of payment element to render.

ElementChangeEvent

Emitted when an element's internal state changes.

NameTypeRequiredDescription
elementTypeElementTypeYesWhich element emitted the event.
completebooleanYesWhether the element is complete and valid.
emptybooleanYesWhether the element is empty.
error{ message: string; type: string }NoValidation error details.
valueRecord<string, unknown>NoNon-sensitive field values (e.g. address).

ElementOptions

Configuration options when creating an element.

NameTypeRequiredDescription
appearanceFloPayAppearanceNoAppearance overrides.
clientSecretstringNoClient secret for the PaymentIntent or SetupIntent.
amountnumberNoTotal amount in smallest currency unit (cents). Used when no clientSecret.
currencystringNoISO 4217 currency code (lowercase). Used with amount.
paymentMethodCreation'manual' | 'auto'NoHow payment methods are created. 'manual' = tokenize only, 'auto' = provider handles it.
layout'tabs' | 'accordion' | 'auto'NoLayout style for the payment element.
defaultValuesRecord<string, unknown>NoPre-filled default values.
readOnlybooleanNoWhether the element is read-only.
mode'billing' | 'shipping'NoAddress element mode.

MountedElement

A payment element that has been created and can be mounted into the DOM.

MethodSignatureDescription
mount(container: HTMLElement) => voidMount the element into a DOM container.
unmount() => voidUnmount the element from the DOM.
update(options: Partial<ElementOptions>) => voidUpdate element options.
on(event: string, handler: (...args: unknown[]) => void) => voidSubscribe to an event.
off(event: string, handler: (...args: unknown[]) => void) => voidUnsubscribe from an event.
destroy() => voidDestroy the element and release resources.

Provider Config

FloPayConfig

Top-level configuration for initializing FloPay.

NameTypeRequiredDescription
publishableKeystringYesYour FloPay publishable key (e.g. pk_test_...).
billingApiUrlstringNoBilling API base URL (e.g. https://api.stage.flopay.com).
localestringNoLocale code (e.g. "en").
appearanceFloPayAppearanceNoDefault appearance for all elements.
apiVersionstringNoAPI version header value.

Adapter

PaymentProviderAdapter

Abstraction layer for payment providers. Currently only Stripe is implemented (StripeAdapter).

MemberSignatureDescription
namereadonly stringProvider name.
initialize(config: FloPayConfig) => Promise<void>Initialize the provider.
createElement(type: ElementType, options: ElementOptions) => Promise<MountedElement>Create a mountable element.
getElement(type: ElementType) => MountedElement | nullGet existing element by type.
submitElements() => Promise<{ error?: FloPayError }>Submit elements for validation.
createPaymentMethod() => Promise<CreatePaymentMethodResult>Tokenize card fields into a payment method.
confirmCardPayment(params: ConfirmCardPaymentParams) => Promise<ConfirmCardPaymentResult>Confirm a card payment.
confirmPayment(params: ConfirmPaymentParams) => Promise<PaymentResult>Confirm a payment using mounted elements.
confirmPayPalPayment(params: { billingApiUrl: string; sessionId: string; email: string; returnUrl: string }) => Promise<ConfirmCardPaymentResult>Create and confirm a PayPal payment.
resumePayPalPayment() => Promise<ConfirmCardPaymentResult | null>Resume a PayPal payment after redirect.
getRawProvider() => unknownGet the raw underlying provider instance (e.g. Stripe object).
createPayPalElements(options: ElementOptions) => unknownCreate a secondary Elements group for PayPal.
destroy() => voidTear down the provider and release resources.

Billing Types

BillingProvider

type BillingProvider = 'recurly' | 'chargebee' | 'stripe';

Supported upstream billing providers.

TokenizedBody

Token payload produced by client-side tokenization.

NameTypeRequiredDescription
idstringNoToken or payment method ID.
typestringNoToken type (e.g. "card").
threeDSecureActionResultTokenIdstringNo3DS action result token.
isPaypalbooleanNoWhether this is a PayPal payment.

CheckoutModeKind

type CheckoutModeKind = 'tokenize' | 'redirect';

Checkout mode: tokenize client-side or redirect to a hosted page.

NormalizedCheckoutSession

Provider-agnostic normalized checkout session.

NameTypeRequiredDescription
providerBillingProviderYesThe billing provider.
modeCheckoutModeKindYesCheckout mode.
dataobjectYesProvider-specific data (see below).
rawunknownNoRaw API response.

data properties:

NameTypeDescription
hostedUrlstringURL for hosted checkout (redirect mode).
clientTokenstringClient token for tokenization.
sessionCheckoutSessionNormalized session object.
chargebee{ site?: string; publishableKey?: string; dropInToken?: string; sessionId?: string }Chargebee-specific data.
stripe{ clientSecret?: string; publishableKey?: string }Stripe-specific data.

Server-side

CheckoutItem

A one-time purchase item for checkout session creation.

NameTypeRequiredDescription
providerItemIdstringYesThe provider's item/product ID (e.g. Stripe price ID).
providerItemNamestring | nullNoDisplay name for the item.
quantitynumberNoQuantity. Defaults to 1.
totalAmountnumberYesThe regular (full) price in the given currency.
overrideAmountnumber | nullNoA discounted price to charge instead of totalAmount.
currencystringNoISO 4217 currency code. Defaults to 'USD'.

CheckoutSubscription

A recurring subscription plan for checkout session creation.

NameTypeRequiredDescription
providerPlanIdstringYesThe provider's plan ID.
providerPlanNamestring | nullNoDisplay name for the plan.
quantitynumberNoQuantity. Defaults to 1.
totalAmountnumberYesThe regular (full) price in the given currency.
overrideAmountnumber | nullNoA discounted price to charge instead of totalAmount.
currencystringNoISO 4217 currency code. Defaults to 'USD'.

CheckoutAccount

Buyer's account information for session creation.

NameTypeRequiredDescription
userIdstringYesUser ID.
firstNamestringNoFirst name.
lastNamestringNoLast name.
emailstringYesEmail address.
countrystring | nullNoCountry code.
genderstring | nullNoGender.
citystring | nullNoCity.
statestring | nullNoState or province.
zipstring | nullNoPostal / ZIP code.

TagsData

Analytics / pixel tags forwarded to the checkout page.

NameTypeRequiredDescription
googleContainerIdstring | nullNoGoogle Tag Manager container ID.
sessionIdstring | nullNoAnalytics session ID.
testEventCodestring | nullNoTest event code for pixel testing.

CreateSessionParams

Parameters for creating a checkout session via the billing API.

NameTypeRequiredDescription
billingApiUrlstringYesBase URL of the billing API.
checkoutBaseUrlstringYesBase URL of the checkout frontend.
clientIdstringYesClient ID for the checkout session.
itemsCheckoutItem[]NoOne-time purchase items.
subscriptionsCheckoutSubscription[]NoRecurring subscription plans.
accountCheckoutAccountYesBuyer's account information.
successUrlstringYesURL to redirect to after successful payment.
cancelUrlstringYesURL to redirect to if the user cancels.
checkoutMode'confirm' | 'auto' | 'full'NoCheckout mode. Defaults to 'confirm'.
couponCodesstring[]NoCoupon codes to apply.
tagsDataTagsDataNoPixel / analytics tags.
redirectParamsRecord<string, string>NoExtra query params appended to the checkout redirect URL.
setCookiebooleanNoWhether to set the checkout_data cookie. Defaults to true.
timeoutMsnumberNoRequest timeout in milliseconds. Defaults to 12000.
utmMetadataRecord<string, string | null | undefined>[]NoUTM and funnel tracking metadata.

CheckoutSessionResult

type CheckoutSessionResult =
  | { status: 201; redirectUrl: string }
  | { status: 204 }
  | { status: number };

Result from creating a checkout session. 201 includes a redirect URL, 204 means payment method already on file.

ProcessPaymentParams

Data submitted when processing a payment (tokenized card/wallet data).

NameTypeRequiredDescription
sessionIdstringYesCheckout session ID.
tokenizedDataTokenizedBodyNoTokenized card/wallet data.
accountData{ userId: string; email: string; firstName: string; lastName: string; zip?: string; country?: string }YesAccount data for the payment.
chvstringNoCheckout version for A/B tracking.

CreateCustomerParams

Parameters for creating a customer.

NameTypeRequiredDescription
emailstringYesCustomer email.
namestringNoCustomer full name.
metadataRecord<string, string>NoArbitrary metadata.

UpdateCustomerParams

Parameters for updating a customer.

NameTypeRequiredDescription
emailstringNoUpdated email.
namestringNoUpdated name.
metadataRecord<string, string>NoUpdated metadata.

WebhookEvent

A webhook event from FloPay.

NameTypeRequiredDescription
idstringYesEvent ID.
typestringYesEvent type (e.g. "payment_intent.succeeded").
dataRecord<string, unknown>YesEvent data payload.
creatednumberYesUnix timestamp of event creation.

Currency

CurrencyInfo

Currency information mapped to a country.

NameTypeRequiredDescription
currencystringYesISO 4217 currency code (e.g. "EUR").
symbolstringYesCurrency symbol (e.g. "$").
countrystringYesCountry name.
countryCodestringYesISO 3166-1 alpha-2 country code.
taxnumberYes0 = no tax, 1 = tax (VAT) applies.

CountryOption

A country option for UI select elements.

NameTypeRequiredDescription
codestringYesISO 3166-1 alpha-2 country code.
namestringYesCountry display name.
flagstringYesFlag emoji.