Class 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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancels a sale still waiting for a card or an approval.collect(TerminalPaymentRequest request) Takes a payment: a sale, or a pre-authorization when the request says so.completeVend(boolean dispensed) Tells the reader whether the approved product was dispensed.protected voidHands a result to the app on the EDT; tests override it.protected voidpause(int millis) Waits between polls; tests override it.voidsetAutoComplete(boolean autoComplete) Reports every approved vend as dispensed at once.voidsetItemNumber(int itemNumber) The item number reported with each vend; 0xFFFF (the default) means unspecified.voidsetSessionTimeout(int sessionTimeout) How long a sale waits for a card and for the reader's answer.protected voidRunstaskon a thread of its own; tests override it.booleansupports(TerminalOperation operation) Whether this terminal can performoperation.Methods inherited from class PaymentTerminal
capture, failed, lookup, missingCapability, reconcile, refund, reverse, unsupported
-
Constructor Details
-
MdbCashlessTerminal
Parameters
bus: the adapter to the MDB bus
-
-
Method Details
-
setItemNumber
public void setItemNumber(int itemNumber) The item number reported with each vend; 0xFFFF (the default) means unspecified.
Parameters
itemNumber: the product's number
-
setAutoComplete
public void setAutoComplete(boolean autoComplete) Reports every approved vend as dispensed at once.
Parameters
autoComplete: true to skipcompleteVend(boolean)
-
setSessionTimeout
public void setSessionTimeout(int sessionTimeout) How long a sale waits for a card and for the reader's answer. Defaults to a minute.
Parameters
sessionTimeout: the limit in milliseconds
-
supports
Description copied from class:PaymentTerminalWhether this terminal can perform
operation.Parameters
operation: the operation to ask about
Returns
true when
PaymentTerminal.collect(TerminalPaymentRequest)or the matching method can carry it out- Specified by:
supportsin classPaymentTerminal
-
collect
Description copied from class:PaymentTerminalTakes a payment: a sale, or a pre-authorization when the request says so.
Parameters
request: what to charge
Returns
the outcome, delivered on the EDT
- Specified by:
collectin classPaymentTerminal
-
completeVend
Tells the reader whether the approved product was dispensed. A failed vend is refunded by the reader.
Parameters
dispensed: true when the customer got the product
Returns
true once the reader has kept the payment, false when it refunded it or the vend could not be reported to it (check the reader's journal)
-
cancel
public void cancel()Cancels a sale still waiting for a card or an approval.- Specified by:
cancelin classPaymentTerminal
-
start
Runs
taskon a thread of its own; tests override it.Parameters
task: the blocking work
-
deliver
Hands a result to the app on the EDT; tests override it.
Parameters
task: the delivery
-
pause
protected void pause(int millis) Waits between polls; tests override it.
Parameters
millis: how long
-