Package SampleCAT

Class CAT

All Implemented Interfaces:
CATInterface, JposBaseInterface

public class CAT extends CATProperties
Sample device specific accessor class. The device uses the following commands:
  • p%d\3 Set print line width. Parameters: Line width (must be ≥ 28).
  • l%d\3 Lock or unlock terminal. Parameters: 0: unlock, 1: lock
  • b\3 Begin transaction. s, v or r must follow.
  • s%f\3 Set sale amount. Parameters: Amount.
  • c%d\2%d\3 Commit operation. Parameters: No. of transaction to be committed, result (0: Verification error, 1: Signature verified). Mandatory after sign-based sale operations.
  • r%f\3 Set return amount. Parameters: Amount.
  • v%d\3 Void transaction. Parameters: No. of transaction to be voided.
  • a\3 Abort operation.
In addition, the device sends the following responses:
  • L%d\3 Lock terminal. Parameters: Result code (0: OK, 4: just locked).
  • U%d\3 Unlock terminal. Parameters: Result code (0: OK, 4: just unlocked).
  • B%d\3 Begin transaction. Parameters: Result code (0: OK, 4: just locked, 6: waiting for commit, 7: authorization active).
  • E%d\3 End. Parameters: Result code (0: OK, 3: Abort, 4: locked, 5: no transaction, 6: wait for commit, 7: other operation active, 8: invalid transaction).
  • E%d\2%s\2%s\2%s\2%s\2%s\2%s\2%s\2%s\2%s\3 End processing. Parameters: Result code (0: OK, 1: wait for commit, 2: Error), Result code (0: no error), approval result (0: OK, 1111: check, else error), balance, tip (included in balance), card issuer (abbreviation, see IssuerList), card no (last 4 digits), expiration date, transaction number, transaction time (format YYYYmmddTHHMMSS).
The device sends the following status messages:
  • D%d\2%s\3 Display line. Parameters: line no (0-3), contents (UTF-8).
  • P%d\2%s\3 Print ticket. Parameters: count (1-2), ticket data (UTF-8), may contain line feeds.
The device will be connected via TCP.
  • Constructor Details

    • CAT

      public CAT(Device dev)
      Constructor. Gets instance of Device to be used as communication object. Device index for sample is always 0.
      Parameters:
      dev - Instance of Device that controls the communication with the terminal.
  • Method Details

    • claim

      public void claim(int timeout) throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of setting claim. Can be overwritten within derived classes. This method will be called only if the following plausibility checks lead to a positive result:
      • Device has not been closed,
      • The device is not claimed,
      • ExclusiveUse dos not equal ExclusiveNo,
      • timeout is negative not equal to FOREVER.
      Specified by:
      claim in interface JposBaseInterface
      Overrides:
      claim in class JposCommonProperties
      Parameters:
      timeout - see UPOS specification, method Claim
      Throws:
      jpos.JposException - If an error occurs while claiming the device
    • release

      public void release() throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of release method. Can be overwritten in derived class, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is claimed,
      • ExclusiveUse equals ExclusiveYes: Device is not enabled.
      Specified by:
      release in interface JposBaseInterface
      Overrides:
      release in class JposCommonProperties
      Throws:
      jpos.JposException - See UPOS specification, method Release
    • checkHealth

      public void checkHealth(int level) throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of CheckHealth method. Can be overwritten in derived class, if necessary. Keep in mind that dvice class specific checks (e.g. check of Claimed or DeviceEnabled) must be done within derived classes. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is neither enabled nor claimed.
      Specified by:
      checkHealth in interface JposBaseInterface
      Overrides:
      checkHealth in class JposCommonProperties
      Parameters:
      level - See UPOS specification, method CheckHealth
      Throws:
      jpos.JposException - See UPOS specification, method CheckHealth
    • deviceEnabled

      public void deviceEnabled(boolean enable) throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of setting DeviceEnabled. Can be overwritten within derived classes. Performs initOnEnable method of corresponding property set in addition to setting DeviceEnabled. This method will be called only if the following plausibility checks lead to a positive result:
      • Device has not been closed,
      • ExclusiveUse equals ExclusiveYes: Device is claimed,
      • DeviceEnabled != enabled.
      Specified by:
      deviceEnabled in interface JposBaseInterface
      Overrides:
      deviceEnabled in class JposCommonProperties
      Parameters:
      enable - True to enable, false to disable
      Throws:
      jpos.JposException - If an error occurs during enable or disable
    • handlePowerStateOnEnable

      public void handlePowerStateOnEnable() throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Will be called whenever DeviceEnabled will be set to true if power notification is enabled (PowerNotify = PN_ENABLED). Should update the PowerState property. Further processing like firing a StatusUpdateEvent is not necessary, this will be made by the framework automatically.
      Specified by:
      handlePowerStateOnEnable in interface JposBaseInterface
      Overrides:
      handlePowerStateOnEnable in class JposCommonProperties
      Throws:
      jpos.JposException - If an error occurs.
    • authorizeSales

      public void authorizeSales(AuthorizeSales request) throws jpos.JposException
      Description copied from interface: CATInterface
      Final part of AuthorizeSales method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a AuthorizeSales object. This method will be called when the corresponding operation shall be performed, either synchronously or asynchronously. All plausibility checks have been made before, only runtime errors can occur.
      Specified by:
      authorizeSales in interface CATInterface
      Overrides:
      authorizeSales in class CATProperties
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by AuthorizeSales.
      Throws:
      jpos.JposException - If an error occurs.
    • authorizeVoid

      public AuthorizeVoid authorizeVoid(int sequenceNumber, long amount, long taxOthers, int timeout) throws jpos.JposException
      Description copied from interface: CATInterface
      Validation part of AuthorizeVoid method. Can be overwritten within derived classes, if necessary. This method shall only perform additional validation. It will be called before the service buffers the method call for synchronous or asynchronous execution. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • Device is not busy,
      • CapAuthorizeVoid is true,
      • amount > 0, taxOthers $ge; 0,
      • timeout is JPOS_FOREVER or ≥ 0.
      Specified by:
      authorizeVoid in interface CATInterface
      Overrides:
      authorizeVoid in class CATProperties
      Parameters:
      sequenceNumber - Sequence number, any value.
      amount - Purchase amount for approval.
      taxOthers - Tax and other amounts for approval.
      timeout - operation timeout.
      Returns:
      AuthorizeVoid object for use in final part.
      Throws:
      jpos.JposException - If an error occurs.
    • authorizeVoid

      public void authorizeVoid(AuthorizeVoid request) throws jpos.JposException
      Description copied from interface: CATInterface
      Final part of AuthorizeVoid method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a AuthorizeVoid object. This method will be called when the corresponding operation shall be performed, either synchronously or asynchronously. All plausibility checks have been made before, only runtime errors can occur.
      Specified by:
      authorizeVoid in interface CATInterface
      Overrides:
      authorizeVoid in class CATProperties
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by AuthorizeVoid.
      Throws:
      jpos.JposException - If an error occurs.
    • authorizeRefund

      public void authorizeRefund(AuthorizeRefund request) throws jpos.JposException
      Description copied from interface: CATInterface
      Final part of AuthorizeRefund method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a AuthorizeRefund object. This method will be called when the corresponding operation shall be performed, either synchronously or asynchronously. All plausibility checks have been made before, only runtime errors can occur.
      Specified by:
      authorizeRefund in interface CATInterface
      Overrides:
      authorizeRefund in class CATProperties
      Parameters:
      request - Output request object returned by validation method that contains all parameters to be used by AuthorizeRefund.
      Throws:
      jpos.JposException - If an error occurs.
    • clearOutput

      public void clearOutput() throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Clear output processing. Removes all OutputCompleteEvents and ErrorEvents from event queue and sets State to S_IDLE. Clears all outstanding commands of the given property set as well. This method will be called only if the following plausibility checks lead to a positive result:
      • Device has not been closed,
      • ExclusiveUse equals ExclusiveYes: Device is claimed.
      Specified by:
      clearOutput in interface JposBaseInterface
      Overrides:
      clearOutput in class JposCommonProperties
      Throws:
      jpos.JposException - See UPOS specification, method ClearOutput