Functions
Reference of every function and type of the SDK.
Every function is on the LemonwayTerminal object:
import { LemonwayTerminal, LemonwayTerminalRoot, LemonwayTerminalError } from '@lemonway/terminal';All functions throw a LemonwayTerminalError.
Setup
| Function | Returns | Description |
|---|---|---|
init(config) | void | Initializes the SDK. Call it before mounting <LemonwayTerminalRoot>. See Init and connect. |
isReady() | boolean | true once the terminal is initialized. |
setLocationId(locationId) | void | Sets the location when tokenProvider does not return it. |
getLocationId() | string | undefined | The location set in init() or setLocationId(). |
Reader
| Function | Returns | Description |
|---|---|---|
connectTapToPay() | Promise<Reader> | Discovers and connects the phone. |
disconnectReader() | Promise<void> | Disconnects the phone. |
status() | Promise<{ connectionStatus, connectedReader }> | Current connection status and reader. |
discoverReaders() | Promise<void> | Advanced: discovers the phone. |
getDiscoveredReaders() | Reader[] | Advanced: readers found by discoverReaders(). |
connectReader(reader) | Promise<Reader> | Advanced: connects a discovered reader. |
Payment
| Function | Returns | Description |
|---|---|---|
authorizePaymentOrder({ id, objectSecret }) | Promise<AuthorizedPayment> | Authorizes a Payment Order created by your backend. |
collectPayment(authorized) | Promise<PaymentResult> | Asks the customer to tap and confirms the payment. |
cancelCollectPayment() | Promise<void> | Cancels the running payment until the card is read. |
Events
| Function | Returns | Description |
|---|---|---|
on(event, callback) | () => void | Subscribes. Call the returned function to unsubscribe. |
once(event, callback) | () => void | Subscribes for the next event only. |
off(event, callback) | void | Unsubscribes a callback passed to on(). |
See Events for the event list.
Types
type LemonwayTerminalConfig = {
env: 'sandbox' | 'production';
publicKey: string; // pk_…
tokenProvider: () => Promise<string | ConnectionTokenSession>;
shopId?: string; // sh_…
locationId?: string; // tml_…
onBehalfOf?: string; // acct_…, iPhone only
logLevel?: 'none' | 'verbose';
};
type ConnectionTokenSession = {
secret: string;
locationId?: string;
onBehalfOf?: string;
};
type AuthorizedPayment = {
paymentOrderId: string;
paymentIntentId?: string;
clientSecret: string;
};
type PaymentResult = {
paymentOrderId?: string;
paymentIntentId: string;
status?: string; // 'succeeded'
amount: number; // in cents
currency: string; // 'eur'
};
class LemonwayTerminalError extends Error {
code: LemonwayTerminalErrorCode;
status?: number; // HTTP status from the PayGreen API
cause?: unknown;
}Reader describes the connected phone (id, serial number, device type).
Updated 11 days ago
Did this page help you?