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.
| Parameter | Type | Required | Description |
|---|---|---|---|
billingApiUrl | string | Yes | Base URL of the billing API. Trailing slashes are stripped. |
getCheckoutSession
Fetch a raw checkout session by ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
checkoutSessionId | string | Yes | The 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
checkoutSessionId | string | Yes | The 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'.
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | User ID, sent as x-user-id header. |
data | ProcessPaymentParams | Yes | Payment 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId | string | Yes | Checkout session ID. |
email | string | Yes | User's email. |
paymentMethodType | string | Yes | Payment method ID or type string. |
options.signal | AbortSignal | No | Abort signal for cancellation. |
options.isPaypal | string | No | Set 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId | string | Yes | Checkout session ID. |
email | string | Yes | User's email. |
paymentMethodType | 'card' | 'google_pay' | 'apple_pay' | 'paypal_express_checkout' | Yes | Type of payment method to set up. |
options.signal | AbortSignal | No | Abort 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
email | string | Yes | User's email. |
options.signal | AbortSignal | No | Abort signal for cancellation. |
options.page | number | No | Page number. Defaults to 1. |
options.limit | number | No | Results 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