FloPay
API Reference@flopay/js

PaymentAPI

Client-side payment API service for interacting with the billing API endpoints.

PaymentAPI

Client-side payment API service. All methods call the billing API endpoints that the checkout backend exposes.

class PaymentAPI {
  constructor(billingApiUrl: string)
}
ParameterTypeRequiredDescription
billingApiUrlstringYesBase URL of the billing API. Trailing slashes are stripped.

getCheckoutSession

Fetch a raw checkout session by ID.

async getCheckoutSession(
  checkoutSessionId: string
): Promise<BillingResponse<RawCheckoutSession>>
ParameterTypeRequiredDescription
checkoutSessionIdstringYesThe checkout session UUID.

Returns: Promise<BillingResponse<RawCheckoutSession>> -- the raw billing API response.

Throws: FloPayError with type 'api_error' if the request fails.

Endpoint: GET /v1/checkouts/sessions/{checkoutSessionId}


getUnifiedCheckoutSession

Fetch and normalize a checkout session. Reads the backend's gateway field to determine the provider, then wraps the session in a NormalizedCheckoutSession.

async getUnifiedCheckoutSession(
  checkoutSessionId: string
): Promise<NormalizedCheckoutSession>
ParameterTypeRequiredDescription
checkoutSessionIdstringYesThe checkout session UUID.

Returns: Promise<NormalizedCheckoutSession>


processPayment

Submit a tokenized payment to the billing backend. The backend will either succeed, return type: '3ds_required', or return type: 'paypal_redirect_required'.

async processPayment(
  userId: string,
  data: ProcessPaymentParams
): Promise<Response>
ParameterTypeRequiredDescription
userIdstringYesUser ID, sent as x-user-id header.
dataProcessPaymentParamsYesPayment data including sessionId, tokenizedData, accountData, and optional chv.

Returns: Promise<Response> -- the raw fetch response.

Endpoint: POST /v1/checkouts/sessions/process


createPaymentIntent

Create a PaymentIntent on the backend with the client's payment method attached.

async createPaymentIntent(
  sessionId: string,
  email: string,
  paymentMethodType: string,
  options?: { signal?: AbortSignal; isPaypal?: string }
): Promise<Response>
ParameterTypeRequiredDescription
sessionIdstringYesCheckout session ID.
emailstringYesUser's email.
paymentMethodTypestringYesPayment method ID or type string.
options.signalAbortSignalNoAbort signal for cancellation.
options.isPaypalstringNoSet to 'true' for PayPal payments.

Returns: Promise<Response>

Endpoint: POST /v1/checkouts/payments/intents


createSetupIntent

Create a SetupIntent for saving payment methods without an immediate charge.

async createSetupIntent(
  sessionId: string,
  email: string,
  paymentMethodType: 'card' | 'google_pay' | 'apple_pay' | 'paypal_express_checkout',
  options?: { signal?: AbortSignal }
): Promise<Response>
ParameterTypeRequiredDescription
sessionIdstringYesCheckout session ID.
emailstringYesUser's email.
paymentMethodType'card' | 'google_pay' | 'apple_pay' | 'paypal_express_checkout'YesType of payment method to set up.
options.signalAbortSignalNoAbort signal for cancellation.

Returns: Promise<Response>

Endpoint: POST /v1/checkouts/payments/setup-intents


getPaymentsByEmail

Fetch a user's prior payments by email. Used to determine if saved card UX should be shown.

async getPaymentsByEmail(
  email: string,
  options?: { signal?: AbortSignal; page?: number; limit?: number }
): Promise<{ data: Array<{ id: string }>; total: number; page: number; limit: number }>
ParameterTypeRequiredDescription
emailstringYesUser's email.
options.signalAbortSignalNoAbort signal for cancellation.
options.pagenumberNoPage number. Defaults to 1.
options.limitnumberNoResults per page. Defaults to 1.

Returns: Paginated list of payment records.

Throws: FloPayError with type 'api_error' if the request fails.

Endpoint: GET /v1/payments?email=...&page=...&limit=...&sortField=occurredAt&sortDirection=DESC

On this page