flair-printer
v0.0.12
Published
This plugin allows printing receipts via USB (ESCPOS)
Readme
flair-printer
This plugin allows printing receipts via USB (ESCPOS)
Install
npm install flair-printer
npx cap syncAPI
getPrinters()scanUsbPrinters()setPrinter(...)removePrinter(...)printReceipt(...)warmUp(...)executeTapAndPay(...)provideConnectionToken(...)addListener('connectionTokenNeeded', ...)setServerUrl(...)getServerUrl()clearServerUrl()openEnvPicker()- Interfaces
- Type Aliases
getPrinters()
getPrinters() => Promise<{ printers: Printer[]; }>Returns: Promise<{ printers: Printer[]; }>
scanUsbPrinters()
scanUsbPrinters() => Promise<{ printers: USBPrinter[]; }>Returns: Promise<{ printers: USBPrinter[]; }>
setPrinter(...)
setPrinter({ printer }: { printer: Printer; }) => Promise<PrinterResult>| Param | Type |
| --------- | --------------------------------------------------------- |
| __0 | { printer: Printer; } |
Returns: Promise<PrinterResult>
removePrinter(...)
removePrinter({ printerId }: { printerId: string; }) => Promise<PrinterResult>| Param | Type |
| --------- | ----------------------------------- |
| __0 | { printerId: string; } |
Returns: Promise<PrinterResult>
printReceipt(...)
printReceipt({ printerId, data, }: { printerId: string; data: { raw: number[]; logo?: string; }; }) => Promise<PrinterResult>| Param | Type |
| --------- | ---------------------------------------------------------------------------- |
| __0 | { printerId: string; data: { raw: number[]; logo?: string; }; } |
Returns: Promise<PrinterResult>
warmUp(...)
warmUp(options?: { simulated?: boolean | undefined; } | undefined) => Promise<void>Prime the Stripe Terminal SDK in the background so the first payment is fast. Call this on app/device page load with the connectionTokenNeeded listener already set up. Fire-and-forget — resolves immediately while warmup runs in the background.
| Param | Type |
| ------------- | ------------------------------------- |
| options | { simulated?: boolean; } |
executeTapAndPay(...)
executeTapAndPay(options: TapAndPayOptions) => Promise<TapAndPayResult>| Param | Type |
| ------------- | ------------------------------------------------------------- |
| options | TapAndPayOptions |
Returns: Promise<TapAndPayResult>
provideConnectionToken(...)
provideConnectionToken(options: { token: string; }) => Promise<void>Supply a fresh connection token to the Stripe Terminal SDK.
Call this in response to the fetchConnectionToken event (re-auth / reconnect scenarios).
| Param | Type |
| ------------- | ------------------------------- |
| options | { token: string; } |
addListener('connectionTokenNeeded', ...)
addListener(eventName: 'connectionTokenNeeded', listenerFunc: () => void) => Promise<PluginListenerHandle>Fired by the native plugin every time the Stripe Terminal SDK needs a fresh connection token (on init, discovery, connect, and any SDK reconnect). Fetch a new token from your backend and call provideConnectionToken().
| Param | Type |
| ------------------ | ------------------------------------ |
| eventName | 'connectionTokenNeeded' |
| listenerFunc | () => void |
Returns: Promise<PluginListenerHandle>
setServerUrl(...)
setServerUrl(options: { url: string; }) => Promise<void>Persist a new server URL and immediately navigate the WebView to it.
| Param | Type |
| ------------- | ----------------------------- |
| options | { url: string; } |
getServerUrl()
getServerUrl() => Promise<{ url: string | null; }>Return the currently-saved server URL, or null if none is stored (falls back to build-time default).
Returns: Promise<{ url: string | null; }>
clearServerUrl()
clearServerUrl() => Promise<void>Clear the saved server URL and open the env picker so the user can choose a new one.
openEnvPicker()
openEnvPicker() => Promise<void>Load the environment-switcher page (launcher.html) over the current WebView.
Interfaces
Printer
| Prop | Type |
| -------------------- | --------------------------------------------------- |
| id | string |
| name | string |
| type | PrinterType |
| connectionInfo | string |
| lineWidth | number |
USBPrinter
| Prop | Type |
| --------------- | ------------------- |
| vendorId | string |
| productId | string |
PrinterResult
| Prop | Type |
| ------------- | -------------------- |
| success | boolean |
| message | string |
TapAndPayResult
| Prop | Type | Description |
| --------------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status | 'error' | 'succeeded' | 'requires_capture' | 'canceled' | succeeded — payment done (auto-capture PI) requires_capture — collected, call POST /capture on your backend with paymentIntentId canceled — user pressed Cancel on the overlay error — something failed, check errorMessage |
| paymentIntentId | string | PaymentIntent ID — present for succeeded / requires_capture / canceled |
| errorMessage | string | |
| errorCode | string | |
TapAndPayOptions
| Prop | Type | Description |
| ------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------- |
| paymentIntentClientSecret | string | Client secret of a PaymentIntent created on your backend (payment_method_types: ['card_present']) |
| locationId | string | Stripe Terminal location ID belonging to the connected account |
| merchantDisplayName | string | Business name shown on the native payment overlay |
| simulated | boolean | Use simulated reader — for testing only, no real card needed. Defaults to false. |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
Type Aliases
PrinterType
'USB' | 'HTTP'
