Vending Events
Vending events are a crucial aspect of the Marshall SDK, enabling your application to handle various stages of the vending process.
- For Java and the C# SDKs the
vend_callbacks_t
interface defines the set of callback methods that your application must implement to respond to these events. - In the C SDK the
vmc_vend_event_e
enumeration performs the same.
The sections below provide an overview of these events and their respective callback methods.
Vending Callbacks Interface
Java and C# only
The interface described on this section are relevant for the Java and C# SDKs only.
The vend_callbacks_t
interface is designed to handle events related to vending operations.
public abstract static interface vend_callbacks_t
Implementing this interface allows your application to manage the lifecycle of a vending session, from initiation to settlement, and handle various statuses and commands received from Nayax's devices. Below is a list of methods available when using the vend_callbacks_t
interface:
-
public abstract void onReady(vmc_link.vpos_config_t config)
: Called when the peripheral framework is ready to start a session, typically after a link has been established or a previous session has ended. It provides the configuration details of the VPOS. -
public abstract void onSessionBegin(int funds_avail)
: Triggered when a client presents a credit card, indicating that a new session has begun and funds are available for the transaction. -
public abstract void onTransactionInfo(vend_session_data_t data)
: Called on receipt of transaction data, providing detailed information about the current transaction. -
public abstract boolean onVendApproved(vend_session_t session)
: Invoked when a vending request is approved. This method should returntrue
if the vend process was successful, indicating that the client’s credit card will be charged, orfalse
if the vend process failed. -
public abstract void onVendDenied(vend_session_t session)
: Called when a vending request is denied, allowing the application to handle the denial accordingly. -
public abstract void onSettlement(boolean success)
: Triggered when a transaction settlement occurs, indicating whether the settlement was successful. -
public abstract void onStatus(int status);
: Called when the peripheral receives a "Status" command from Nayax's device, providing the current status of the session as defined in the Marshall Protocol section 8.11. -
public abstract void onOpenedSessions(ushort[] sessions)
: This is invoked when the peripheral receives a "Get Session Status" command from Nayax's device. It is useful for identifying which sessions are open, especially in multi-session mode, as defined in Marshall Protocol section 8.27.5. -
public abstract void onReaderState(boolean enabled)
: Provides the status of the reader, indicating whether it is enabled or disabled, as defined in Marshall Protocol section 8.27.9. -
public abstract void onRemoteVend(int avail_funds, int product_code, int options)
: Triggered when the device receives a remote vend command, providing the available funds, product code, and options for dispensing the product. -
public abstract void onReceipt(int ereceipt_type, String data)
: Called when a QR code receipt is generated, passing the QR code data to the peripheral to display for the consumer, as defined in Marshall Protocol section 8.12.
Vending Events Enumeration (C SDK)
The vmc_vend_event_e
enumeration is designed to handle events related to vending operations in the C SDK.
Enum vmc_vend_event_e
Below is a list of methods available when using the vend_callbacks_t
interface:
public abstract void onReady(vend_session_t session):
Called when the peripheral framework is ready to start a session. This occurs after a link has been established or a previous session has ended.public abstract void onSessionBegin(int fundsAvail)
: Called when a client presents a credit card, providing the available funds for the transaction.public abstract void onTransactionInfo(vend_session_data_t data)
: Triggered when transaction data is received, passing detailed information about the current session.public abstract void onVendApproved(vend_session_t session)
: Called when a vending request is approved, providing session details for further processing.public abstract void onVendDenied(vend_session_t session)
: Called when a vending request is denied, passing relevant session details.public abstract void onSessionCanceled(vend_session_t session)
: Triggered when a transaction is canceled, providing information about the canceled session.public abstract void onSettlement(uint32_t success)
: Indicates the settlement status of a transaction. The success parameter signifies whether the settlement succeeded (non-zero for success).public abstract void onStatus(uint32_t status)
: Called when the peripheral receives a "Status" command from Nayax's device, as defined in Marshall Protocol section 8.11.public abstract void onSessionsResponse(mdb_msg_sessions_status_t sessions)
: Triggered when the "Get Session Status" command is received from Nayax's device. Provides details about open sessions, useful in multi-session mode or after a software restart.public abstract void onReaderStateResponse(mdb_msg_reader_status_t state)
: Responds to the "Get Reader Status" command, indicating whether the card reader is enabled or disabled (Marshall Protocol section 8.27.9).public abstract void onReceipt(int ereceiptType, String data)
: Called when a QR code receipt is generated. Passes the QR code data to the peripheral to display for the consumer, as defined in Marshall Protocol section 8.12.public abstract void onSessionTimeout(uint32_t sessionId)
: Triggered when a transaction times out, providing the sessionId of the timed-out session.
Updated 3 months ago