SwpTrmLib is a Net Standard 2.0 nuget package that may be used when integrating Swedbank Pay terminal to a sale system. The package makes it simple and easy to get started. It has high abstraction and even if the actual protocol to the terminal changes this interface can stay the same.
It offers both synchronous and asynchronous methods and for the simplest form of implementation it just takes a few calls to make a transaction.
As of now the terminal is not prepared for a cloud connection, but by using this SDK it is possible to quickly make a small proxy service that makes whichever cloud connection that is desired.
In the future there may be other variants of the interface and usage within the SDK, but this version will stay the same and once an implementation has been made, it should not have to be changed unless new requirements or new functionality is desired.
The aim of the SDK is to minimize the total work effort for both users and Swedbank Pay.
The SwpTrmLib only contains one implementation for using a PAX terminal from Swedbank Pay at the moment, but makes it possible to vary the style of use
by configuration. There are two major styles that is decided by the
SalesCapabilities string sent in a
- Act as both server and client - see code example for default style
- Act as client only - see code example for client only
The intended default style requires the consumer of the SwpTrmLib to act as both a server and a client. The server handles requests from the terminal, such as display information, events, and possible input request from the terminal, such as a request to confirm that a receipt has been signed if needed.
The second style is to act as a client only and then loose information from terminal such as events informing that a card has been inserted or removed or display information helping the operator to see what is going on. Transactions that need signing is not possible but will be in a later terminal version. Such transactions regard cards from outside EU for which PIN may not be required.
Most available methods have an asynchronous and a synchronous version. Note that the synchronous versions internally renders a call to the asynchronous version. All results genereated due to synchronous calls are received in one callback method, SyncRequestResult, which parameter is the same result as described for the asynchronous version.
Warning: Do not wrap the synchronous calls in async await since the methods themselves call async methods.
Making a transaction from scratch only takes a few method calls.
- Create - Creates an instance and returns an interface
- Start - Initializes the instance and starts a listener for terminal if that mode is chosen
- Open/OpenAsync - Starts a Login Session with the terminal. The session is valid until Close or a new Open call
- Payment/PaymentAsync - Starts a payment transaction for supplied amount.
- Refund/RefundAsync - Starts a refund transaction for supplied amount.
- GetLastTranactionResult/GetLastTransactionResultAsync - Requests a copy of the result for the last transaction
- Close/CloseAsync - Finishes the terminal session and allows for terminal maintenance. At least once a day.
To get more than just payments and refunds
- GetPaymentInstrument/GetPaymentInstrumentAsync - Opens card readers to read card before amount is known
- SetPaymentInstrument - Sends a payment instrument (card number) to the terminal. Note! Only non PCI regulated cards.
- RequestToDisplay/RequestToDisplayAsync - Sends a message to be displayed on terminal
- RequestCustomerConfirmation/RequestCustomerConfirmationAsync - Displays a yes/no question on the terminal and receive the result.
- RequestCustomerDigitString/RequestCustomerDigitStringAsync - Displays a message and ask customer to enter a digit string.
- Abort/AbortAsync - Aborts something ongoing
Continue - May be used after
GetPaymentInstrumentto make terminal proceed with PIN dialog before amount is known
- ReverseLast/ReverseLastAsync - Reverses the last transaction if it was approved
- UpdateTerminal/UpdateTerminalAsync - Ask terminal to see if is any parameter update pending
The callbacks needed if running as a server, using the synchronous method calls or using the EventCallback rather than subscribing to the available Events.
- ConfirmationHandler - When the terminal requests a Yes/No from operator (Verify signed receipt)
- EventCallback - replaces subscribing to events.
- EventNotificationHandler - Reception of EventNotification messages from the terminal
- SyncRequestResult - Results from various synchrounous methods
The events are only used if running as a server.