Integrating the EPAS client library
The steps to integrate the EPAS Client Library are:
- Add the library module to the ECR project.
- Add an instance of the library to the ECR application.
- Implement required methods.
- Implement optional handler methods as required.
1. Add a reference to EpasClientLibrary.dll
The EPAS Client Library is implemented as a .NET Framework 4.7.2 class library.
2. Create an EpasClient instance
The EPAS Client Library is implemented by the EpasClient class in the Westpay.Epas namespace. The client takes a single parameter, which is an instance of a class that implements IClientApp.
using Westpay.Epas;
public class SampleECR : IClientApp
{
/// <summary>
/// Instance of the EPAS client library
/// </summary>
EpasClient mEpas = null;
public SampleECR()
{
// Create the EPAS client library instance
mEpas = new EpasClient(this);
}
.
.
.
}
Note: An
EpasClient
instance is only connected to one terminal at a time. If the ECR needs to interact with several terminals simultaneously, one instance must be created for each terminal.
3. Implement IClientApp
The EpasClient class requires an IClientApp instance. This instance must be provided by the ECR application, which must implement all the required members of the interface.
- Display
- PrintRecipt
- PrintReport
- VerifySignature
- HandleVoiceReferral
- PaymentCodeRequired
- VatAmountRequired
- LoyaltyCardPresented
- CheckDccOnOriginalTransaction
- ParameterDownloadAvailable
- Log
4. Optional methods
The client library offers a range of handler methods that are optional, and the ECR can implement any that will be useful.
Each handler method is implemented as a callback. The ECR simply assigns a method reference to the appropriate library callback handler in EpasClient and the method will be called when appropriate.
About callbacks
When the library calls methods in the ECR, only one method will be called at any time. This is done to ensure that there are no
race conditions, since events can happen quickly and it would be confusing if, for example, the CardAccepted
handler is called
while the CardInserted
handler is still executing.
It is, therefore, recommended that the ECR returns from interface methods and handlers as quickly as possible so that the remainder of the transaction can be processed without delay.
There is one exception to this, which is IClientApp.Log. This has a dedicated thread so that the Log method can be called while another method or handler is executing. Only one call to Log will be made at a time, however – there will be no overlapping calls made.
Using the library
The next step is to start using the library