Tally UI

TerminalLegView

TerminalLegView shows a card-terminal payment in progress, with its status, reader, steps and the way out.

Import

import { TerminalLegView } from '@tallyui/components';

Usage

<TerminalLegView
  amountMinor={leg.amountMinor}
  currency={order.currency}
  phase={phase}
  outcome={result?.outcome}
  failureReason={result?.failureReason}
  method={method}
  driver={driver}
  onCancel={() => driver.cancel?.()}
  onRetry={retry}
  onChooseAnother={dismiss}
/>

It is presentational: the host runs the leg (for example with collectTerminalLeg from @tallyui/pos) and passes its phase. Top to bottom it shows "ON THE TERMINAL" over the amount, one status line, the method and reader name with a Connected badge (and the battery when the driver reports one), and the steps Sent, On terminal, Approved and Captured. While the leg cancels or ends, the last step reached stays marked.

While the terminal starts or waits for a card, a driver that can cancel from the till (capabilities.cancel is 'app') gets a "Cancel on terminal" button; a driver that only cancels on the reader gets the hint "Cancel on the reader". A failed leg reads "Payment failed: {reason}" with a red mark; a cancelled or timed-out leg reads "Payment cancelled" or "Timed out — payment cancelled" with a grey one. Both offer "Try again" and "Choose another way". A captured or authorized leg renders nothing: the host opens the receipt, or the ledger shows the authorized leg.

It follows WCPOS v2's terminal-leg-view.tsx. v2's Details log, the order number and plan heading, the veto, release and capture-retry states, and the captured-but-unfinished notice are later work.

Props

PropTypeDefaultDescription
amountMinornumberrequiredThe leg's amount in minor units
currencystringrequiredISO 4217 code of the amount
phaseTerminalLegPhaserequired'starting', 'collecting', 'confirming', 'cancelling' or 'final'
outcome'captured' | 'authorized' | 'failed' | 'voided' | null—Read when phase is 'final'. With phase 'final' and no outcome, the leg reads as cancelled (grey, Try again).
failureReasonstring | null—The driver's reason, e.g. 'card_declined' or 'timed_out'; an unknown reason shows as itself
methodPaymentMethodDescriptorrequiredThe leg's payment method; its title names the reader row
driverPaymentDriverrequiredThe method's driver; its status and capabilities.cancel are read
onCancel() => void—Called by "Cancel on terminal"
onRetry() => void—Called by "Try again"
onChooseAnother() => void—Called by "Choose another way"
testIDstring'terminal-leg'Test identifier

On this page