Class PaymentTerminal

java.lang.Object
com.codename1.payment.terminal.PaymentTerminal
Direct Known Subclasses:
AdyenCloudTerminal, MdbCashlessTerminal, SquareTerminal, StripeReaderTerminal, TapToPay, ZvtTerminal

public abstract class PaymentTerminal extends Object

A card terminal: takes in-person payments and, where the terminal supports it, everything a point of sale does around them -- refunds, reversals, pre-authorizations and their capture, lookups after a lost connection, and the end-of-day reconciliation.

Every operation answers the same way: a resource that completes on the EDT with a TerminalResult once the terminal decided -- approved, declined, canceled or failed. It completes with an error only when the terminal could not be asked at all (no connection, a rejected credential, a malformed answer), so a decline is never an exception. One error is special: a TerminalOutcomeUnknownException means the card may have been charged, and the app must look the payment up before charging again.

Not every terminal can do everything. supports(TerminalOperation) says what this one can; an unsupported operation completes with an UnsupportedOperationException without touching the card.

For every operation, TerminalResult.Status.APPROVED means the operation went through: the sale was charged, the reversal or refund was accepted, the capture took the money. A lookup reports the payment's own status instead.

One operation that drives the terminal itself (a sale, or a refund taken on the card) runs at a time per terminal; starting a second completes it with an IllegalStateException and leaves the first alone. Operations a provider carries out on its servers without the terminal may run alongside one.

The implementations in this tree:

  • com.codename1.payment.terminal.tap.TapToPay -- the phone itself reads the card (Tap to Pay on iPhone and Android, over the Stripe Terminal SDK).
  • com.codename1.payment.terminal.stripe.StripeReaderTerminal -- a Stripe smart reader on the counter, driven over Stripe's API.
  • com.codename1.payment.terminal.adyen.AdyenCloudTerminal and AdyenLocalTerminal -- any Adyen terminal, through Adyen's cloud or directly over the shop's network.
  • com.codename1.payment.terminal.square.SquareTerminal -- a Square Terminal, through Square's API.