SwedbankPay.Pax.Sdk
1.3.26259
dotnet add package SwedbankPay.Pax.Sdk --version 1.3.26259
NuGet\Install-Package SwedbankPay.Pax.Sdk -Version 1.3.26259
<PackageReference Include="SwedbankPay.Pax.Sdk" Version="1.3.26259" />
<PackageVersion Include="SwedbankPay.Pax.Sdk" Version="1.3.26259" />
<PackageReference Include="SwedbankPay.Pax.Sdk" />
paket add SwedbankPay.Pax.Sdk --version 1.3.26259
#r "nuget: SwedbankPay.Pax.Sdk, 1.3.26259"
#:package SwedbankPay.Pax.Sdk@1.3.26259
#addin nuget:?package=SwedbankPay.Pax.Sdk&version=1.3.26259
#tool nuget:?package=SwedbankPay.Pax.Sdk&version=1.3.26259
SwpTrmLib
SDK for using Swedbank Pay terminals. Implements the Nexo Retailer v3.1 as used by Swedbank Pay. For complete documentation please visit developer.Swedbankpay.com/pax-terminals/NET/.
Create an instance
Contains at the moment only one implementation through class PAXTrmImp_1. Its static create method returns an instance of interface ISwpTrmIf_1. Provided that the current object implements the ISwpTrmCallbackInterface, the following creates an instance to an object with ISwpTrmIf_1 interface.
ISwpTrmIf_1 Pax = PAXTrmImp_1.Create(new SwpIfConfig(), this);
The ISwpTrmCallbackInterface
As of now it both exposes events and requires an interface to callbacks, ISwpTrmCallbackInterface. If the events are not subscribed for they all appear in the callback EventCallback. This is useful if using more than one terminal which requires one instance per terminal.
public interface ISwpTrmCallbackInterface
{
void ConfirmationHandler(string text, IConfirmationResult callback);
void EventNotificationHandler(EventToNotifyEnumeration type, string text);
void SyncRequestResult(object result);
void EventCallback(EventCallbackObject eventObject);
}
ConfirmationHandler
This callback occurs when the terminal wants a confirmation from the POS operator. Typically an approval of a customer signature on a signature receipt.
EventNotificationHandler
Occurs when an event notification message is received from the terminal. Typically CardInserted, CardRemoved, MaintenanceRequired etc.
SyncRequestResult
Occurs when a synchronous method call has ended up with a result/response. A call to the method Payment will eventually give a Payment result with receipt information.
Example of how to use the SycnRequestResult Callback
public void SyncRequestResult(object result)
{
switch (Enum.Parse(typeof(RequestResultTypes), result.GetType().Name)) {
case RequestResultTypes.OpenResult:
...
break;
case RequestResultTypes.PaymentRequestResult:
...
break;
...
EventCallback
Occurs when an ISwpTrmIf_1 event has not been subscribed for. Typically a display message from the terminal that may be displayed on the POS to inform the operator what is going on on the terminal.
Example of how to use the EventCallback method
public void EventCallback(EventCallbackObject eventObject)
{
switch (eventObject.type)
{
case EventCallbackTypes.TerminalAddressObtainedEventCallback:
...
break;
case EventCallbackTypes.NewStatusEventCallback:
...
break;
case EventCallbackTypes.DisplayEventCallback:
...
break;
case EventCallbackTypes.PrintRequestEventCallback:
...
break;
...
Asynchronous or Synchronous methods
The ISwpTrmIf_1 has implementation for both asynchronous and synchronous methods. Note, that the synchronous methods ends up in the asynchronous methods and the SyncRequestResult callback will give the same result object as the awaitable method.
Get going to actually make a payment
Once an instance is created call the Start method with a SaleApplInfo object. The SaleApplInfo holds essential information. POIID among others.
POIID
POIID is an identification of the Point of Interaction and decides what parameters to fetch from the TMS. The POIID must be registered in the TMS and may be decided by the customer/partner or Swedbank Pay. It could be any kind of unique identification within an organisation.
SaleCapabilities
SaleCapabilities is used in the LoginRequest message to the terminal and decides whether the terminal should send requests towards the Sale System or not, i.e. if the sale system needs to have a listener or not. Default is that a listener is used, but if string SaleCapabilities only contains PrinterReceipt, a listener will not be started. In that case it is not possible to do transactions approved with signature. The SwpIfConfig in call to .Create sets which port to listen on. Default is port 11000.
Set Terminal address and port
Before communicating with the terminal the created instance needs the address and port for the terminal. Set the property TerminalAddress using the following format <ip-address>:<port>.
Note, that if a listener has been started the terminal address and port may be initialized from the terminal's admin menu by entering ECR IP and ECR Port. A configuration message is then sent from the terminal. This enables a terminal to be installed without having to login to the sale system. When the configuration message is received the OnTerminalAddressObtained will occur or the EventCallback is called.
Steps to make a transaction
- Call
Open/OpenAsyncto send a LoginRequest to the terminal and wait for answer. On success it is possible to start using the terminal. The Login session, as it is called, last untilClosemethod is called or another call toOpen/OpenAsyncis made. - Call
Payment/PaymentAsyncorRefund/RefundAsyncto start a transaction and wait for response. - Call
GetPaymentInstrumetAsyncto start a transaction when a card needs to be read before the amount is known. Follow up with call to either Payment/PaymentAsynch or Refund/RefundAsynch when a card has been read.
Call Close to send logout. Do this at least once a day to let the terminal update its parameters.
Payment results
All results that contain receipt data are formatted automatically by ReceiptFormatter before giving the result to the caller (consumer of the instance).
Brief method description in relevant order.
Start
Call Start to initialize the instance with a SaleApplInfo object. First call to be made after creation.
Open/OpenAsync
First method to call that actually sends a message to the terminal and makes it ready to be used.
GetPaymentInstrument/GetPaymentInstrumentAsync
This method will start a transaction for wich a card needs to be read before the amount is known. The result after a card read will hold information about the card, but not a full card number. It will always give a CNA - Card Number Alias - that may be used to identify the card in a loyalty system.
Continue/ContinueAsync
Only relevant if a chip card has been read and PIN entry should be possible before amount is known.
Payment/PaymentAsync
Call this method when amount is known and a payment shall be made. This will open the terminal's card readers unless GetPaymentInstrument/GetPaymentInstrumentAsync was used prior to this call.
Refund/RefundAsync
Call this method when amount is known and a refund shall be made. This will open the terminal's card readers unless GetPaymentInstrument/GetPaymentInstrumentAsync was used prior to this call.
Abort/AbortAsync
Aborts any ongoing request, GetPaymentInstrument, Payment, Refund. The actual request that is aborted will render a result.
ReversLast/ReversLastAsync
Reverses the last transaction if it was successful.
GetLastTransactionResult/GetLastTransactionResultAsync
Gets the last transaction result including receipt data. This is useful if the sale system for some reason is unable to pick up the original result.
RequestCustomerConfirmation/RequestCustomerConfirmationAsync
Possibility to ask the customer a Yes/No question to be answered on the terminal. The response will contain a boolean, true/false. This method is valid before call to any of Payment or Refund or after the result of those methods.
RequestCustomerDigitString/RequestCustomerDigitStringAsync
Possibility to ask the customer for a digit string. Eg. Cell phone number. This method is valid before call to any of Payment or Refund or after the result of those methods.
RequestToDisplay/RequestToDisplayAsync
Possibility to display a message on the terminal. The message will stay visible until next request is made. This method is valid before call to any of Payment or Refund or after the result of those methods.
Close
Ends the login session by sending a LogoutRequest to the terminal. By default MaintenanceAllowed flag in LogoutRequest will be set to true, making it possible for the terminal to update its parameters. It is however possible to pass the parameter as false in the call to inhibit updates.
Stop
Stops the listener if started.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Identity.Client (>= 4.72.1)
- Newtonsoft.Json (>= 13.0.3)
- NLog (>= 6.1.1)
- System.Configuration.ConfigurationManager (>= 10.0.0)
- System.Security.Cryptography.ProtectedData (>= 10.0.0)
- System.Text.Json (>= 9.0.6)
-
net10.0
- Microsoft.Identity.Client (>= 4.72.1)
- Newtonsoft.Json (>= 13.0.3)
- NLog (>= 6.1.1)
- System.Configuration.ConfigurationManager (>= 10.0.0)
- System.Security.Cryptography.ProtectedData (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
SwpTrmLib Release Notes
1.3.26259:
- Restored Netstandard 2.0 support alongside .NET 10 (multi-targeting)
- Added CloudConfigFolder to SaleApplInfo, allowing the cloud configuration file location to be customized
- GetLastTransactionResult now targets message category "Payment" instead of "All"
- Added ReverseByTransactionId and ReverseByTransactionIdAsync to support manual reversal by POI transaction ID and timestamp
- SwpIfConfig.EventFallbackDelayMs enables events to be delivered on a thread-pool thread when the
captured SynchronizationContext has not delivered them. -1 (default) disables the fallback, so events
are delivered only on the captured context. This only affects applications where a SynchronizationContext exists.
- IConfirmationResult.Confirmation(bool) remains the supported method. Confirmed(bool) is kept as an
[Obsolete] alias and will be removed in a future release.
- The ServiceID is now echoed back from the request alongside DeviceID, per the Nexo requirement that a
response always carries the same ServiceID as its request.
1.3.26201
- Fixed silent callback drop when SynchronizationContext is stale (FireEvent now guarantees exactly-once delivery)
- Added configurable FallbackDelayMs to FireEvent for async UI consumers
- Fixed PaymentType, Reference and Amount not being populated when terminal suppresses CustomerReceiptData
- Migrated to .NET 10
1.3.26056
- Updated B2C config URL
- Added fix to potential deadlock in doOpen()
- Tests added for cloud mode
1.3.25338
- Added support for Loyalty before Auth
1.3.25328
- Added support for cloud
- changed order of Payment Arguments
1.3.25253
- This release updates the library’s logging dependencies from NLog v4 to NLog v6.
Applications that directly use NLog alongside this library must also update to NLog v6 for compatibility.
If your application does not use NLog directly, no changes are required on your side.
1.3.25252
- Added custom version handling
- Added support for tips
- Added Loyalty flag to SaleAppInfo
- Added Card Acqusition data
- Various bugfixes and Improvements
1.3.25212
- Added ApplicationLabel to PaymentRequestResult.
1.3.25120
- Added a flag in SaleApplInfo to support Forced Card Acquisition. Making Payment instrument required.
1.3.24326
- Now allows UnitPrice and itemAmount to be 0.
1.3.24170
- Add specific data from fuel app to the receiptBlob
1.3.24163
- If installed POS language is not supported by terminal as operator language, use english.
- Only send continue_processing if Continue is called. Don't send continue_processing automatically on Payment.
1.3.24129
- PaymentRequetsResult now with new properties, MerchantReceiptBlob, MerchantReceiptBlobNoHeader and SignatureBlock.
1.3.24075
- Fixed bug for fuel that caused SaleItems to be missed when starting with GetPaymentInstrument.
1.3.24066
- New package ID. SwedbankPay.Pax.Sdk. Still same namespaces and dll name.
- Fix for display messages from fuel app that lacks text id.
- Added support for AdminRequest with service identification OM02, OM03 and OM04, regarding the Store-And-Forward
- Fixed bug for PrintRequest with DocumentQualifier other other than CashierReceipt or CustomerReceipt.
- Possibility for Net Framework 4.0. Now supports Netstandard2.0, net framework 4.5 and 4.0.
1.3.24047
- PaymentRequestResult now populates ProductName and PAN even if PaymentInstrumentData is missing.
- Possibility to use OpenEx or OpenExAsync to set OperatorID and ShiftNumber that will be forwarded and seen in reports.
- Possibility to attach purchase order Id by setting in in TransactionSetup when starting a payment.
- Setting up the logfile will only be made once even if new instances is created. Filter is removed when calling Stop.
- Calling Stop will stop and remove the listener
- SplitPayment may be indicated in TranactionSetup and is sent to terminal to be forwarded to host.
- Property type of TransactionSetup is always overridden and set to Refund if Refund or RefundAsync is called.
- Default currency fixed when using TransactionSetup
1.3.24025
- ReverseLast corrected and now with auto retry on Busy response from the terminal.
- OnTerminalAddressObtainedEventCallback now public to make sense.
- Corrected result from RequestToDisplay and UpdateTerminal
1.3.24016
- PaymentRequestResult now with properties for PaymentType, CNA, PAN, ReceiptNumber and Reference.
- PaymentRequestResult extended with new properties
- CardAcquisitionReference TimeStamp now a copy och POITransactionID TimeStamp. Earlier it was converted to local time.