Payment Flow
Overview
The createPaymentFlow() method provides a complete, orchestrated payment experience. It handles navigation between all screens automatically, making it the easiest way to integrate payments.
Flow Screens
The payment flow progresses through these screens:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Invoice Detail │ ──▶ │ Payment Method │ ──▶ │ Confirmation │
│ │ │ Selection │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
┌───────▼─────────┐
│ Payment Result │
│ │
└─────────────────┘Invoice Detail - Displays invoice information and line items
Payment Method Selection - Choose existing or add new payment method
Add Payment Method - Card or bank account form (if adding new)
Confirmation - Review payment details before submitting
Result - Success or error screen
Basic Usage
Configuration
PaymentFlowConfig
containerId
string
Yes
ID of the container element
invoiceId
string
Yes
Invoice ID to pay
theme
ThemeConfig
No
Custom theme configuration
onPaymentSuccess
(payment: Payment) => void
No
Called when payment succeeds
onPaymentError
(error: Error) => void
No
Called when payment fails
onClose
() => void
No
Called when flow is closed
onGoBack
() => void
No
Called when user clicks "Go back" on success screen
Common Use Cases
Basic Payment Flow
Handle Payment Results
Component Instance Methods
The flow returns a ComponentInstance with these methods:
mount()
Mounts the component to the DOM. Called automatically on creation.
unmount()
Removes the component from the DOM. Call this when navigating away or cleaning up.
refresh()
Refreshes the component data. Useful after external changes.
Cleanup
Always unmount the flow when the user navigates away to prevent memory leaks:
Already Paid Invoices
If an invoice is already paid (status: RECEIVED), the flow will skip directly to the success screen, showing the payment details without requiring any user action.
Related
ComponentsThemingLast updated
Was this helpful?
