FloPay Class
The main FloPay SDK instance providing element management, payment confirmation, and session retrieval.
FloPay
The main FloPay SDK instance. Created via loadFloPay(publishableKey).
elements
Creates a new FloPayElements group for mounting payment fields. Only one elements group is active at a time -- creating a new one destroys the previous group.
| Parameter | Type | Required | Description |
|---|---|---|---|
options | ElementOptions | No | Configuration for the elements group. |
Returns: FloPayElements
submitElements
Submit elements for validation.
Returns: Promise<{ error?: FloPayError }> -- an object with an optional error if validation fails.
createPaymentMethod
Create a payment method from the current elements (tokenize card fields).
Returns: Promise<CreatePaymentMethodResult> -- contains paymentMethodId on success or error on failure.
confirmCardPayment
Confirm a card payment with a known client secret and payment method ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
params.clientSecret | string | Yes | Client secret of the PaymentIntent. |
params.paymentMethodId | string | Yes | Payment method ID to confirm with. |
Returns: Promise<ConfirmCardPaymentResult>
confirmPayPalPayment
Confirm a PayPal payment: creates a PaymentMethod, creates a PaymentIntent via the billing API, and confirms with redirect if needed.
| Parameter | Type | Required | Description |
|---|---|---|---|
params.billingApiUrl | string | Yes | Billing API base URL. |
params.sessionId | string | Yes | Checkout session ID. |
params.email | string | Yes | User's email. |
params.returnUrl | string | Yes | URL to return to after PayPal redirect. |
Returns: Promise<ConfirmCardPaymentResult>
resumePayPalPayment
Resume a PayPal payment after redirect return. Checks URL parameters for payment_intent and redirect_status.
Returns: Promise<ConfirmCardPaymentResult | null> -- null if no PayPal parameters are found in the URL.
confirmPayment
Confirms a payment using the mounted elements.
| Parameter | Type | Required | Description |
|---|---|---|---|
params.clientSecret | string | Yes | Client secret of the PaymentIntent or SetupIntent. |
params.returnUrl | string | No | Redirect URL after 3-D Secure or wallet authentication. |
Returns: Promise<PaymentResult>
retrieveSession
Retrieves a checkout session by ID via the billing API. Returns the normalized CheckoutSession.
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId | string | Yes | Checkout session UUID. |
billingApiUrl | string | No | Billing API URL. Falls back to the URL set in loadFloPay(). |
Returns: Promise<CheckoutSession>
Throws: FloPayError if sessionId or billingApiUrl is missing, or if the session is not found.
retrieveUnifiedSession
Retrieves and normalizes a checkout session, including provider-specific data (Stripe clientSecret/publishableKey, Chargebee site, etc.).
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId | string | Yes | Checkout session UUID. |
billingApiUrl | string | No | Billing API URL. Falls back to the URL set in loadFloPay(). |
Returns: Promise<NormalizedCheckoutSession>
getRawProvider
Returns the raw underlying provider instance (e.g. the Stripe object). Used internally by components that need direct provider access.
Returns: unknown -- the raw provider instance.
destroy
Tears down the SDK instance, destroys all elements, and releases resources.