PSP Session Management
The session protocol is designed to allow multiple payment sessions to be started and tracked. A session starts by sending the Start Session command, this starts the terminal scanning for a new card.
When the terminal reads a card it will send a Card Read response to the host machine with some details about the card (by default the masked PAN and if available a hash of the card).
The host machine can now make a choice to either:
Cancel the session using the Cancel Session command, for example if this card is already in use.
Perform an auth for this card using the Auth Session command, this will result in a request to the bank to authorize payment for the amount given in the Start Session command
The terminal will respond with either Session Approved, Session Declined or Session Cancelled.
In the case of Session Approved the response will contain a Session ID, this should be stored by the host machine and can be used to further commands to Commit or Void the session. Committing or Voiding of a session can be done at any time and multiple sessions may be open on the terminal.
The chargers is responsible for storing whether a session is active or not for a certain card. Usually the hash is checked for this. E.g. a map is used for the active sessions where the key is the card hash and the value is the session ID.
