Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class MdbCashlessTerminal
- Object
- PaymentTerminal
- MdbCashlessTerminal
A cashless reader on an MDB bus, driven by the app as the vending machine controller (VMC), following MDB/ICP level 1 cashless device commands.
MdbBus myAdapter = (block, timeout) -> new byte[0]; // your adapter board
MdbCashlessTerminal reader = new MdbCashlessTerminal(myAdapter);
reader.setItemNumber(12);
reader.collect(new TerminalPaymentRequest(250, "EUR")).ready(result -> {
if (result.isApproved()) {
boolean ok = true; // whether the machine dispensed item 12
reader.completeVend(ok);
}
});A sale enables the reader and waits for the customer to present a card,
then asks to vend the price. An approval is delivered before anything is
dispensed; call completeVend(boolean) once the product is out, or not,
so the reader settles or refunds. With setAutoComplete(boolean) the
vend is reported successful at once, for a machine that cannot fail.
The approval is an authorization: a vend never completed within five
session timeouts is reported failed, and the reader refunds it. The
resource completeVend(boolean) returns says whether the money was kept.
Amounts convert through the reader’s scale factor and decimal places from its setup answer.
Constructors
public MdbCashlessTerminal(MdbBus bus) |
Methods
Inherited methods
Constructor details
MdbCashlessTerminal
public MdbCashlessTerminal(MdbBus bus)Parameters
busMdbBus- the adapter to the MDB bus
Method details
setItemNumber
public void setItemNumber(int itemNumber)Parameters
itemNumberint- the product’s number
setAutoComplete
public void setAutoComplete(boolean autoComplete)Parameters
autoCompleteboolean- true to skip
completeVend(boolean)
setSessionTimeout
public void setSessionTimeout(int sessionTimeout)Parameters
sessionTimeoutint- the limit in milliseconds
supports
public boolean supports(TerminalOperation operation)operation.Parameters
operationTerminalOperation- the operation to ask about
Returns
collect(TerminalPaymentRequest) or the matching method
can carry it outcollect
public AsyncResource<TerminalResult> collect(TerminalPaymentRequest request)Parameters
requestTerminalPaymentRequest- what to charge
Returns
completeVend
public AsyncResource<Boolean> completeVend(boolean dispensed)Parameters
dispensedboolean- true when the customer got the product
Returns
cancel
public void cancel()start
protected void start(Runnable task)task on a thread of its own; tests override it.Parameters
taskRunnable- the blocking work
deliver
protected void deliver(Runnable task)Parameters
taskRunnable- the delivery
pause
protected void pause(int millis)Parameters
millisint- how long