Engine Life Cycle

Use these functions to maintain the life cycle of LS Pay:

  • InitAsync()
  • TerminateAsync()
  • EnteringBackground() - For mobile applications
  • EnteringForeground() - For mobile applications
  • ConnectionStatusChanged - event

For many PSPs LS Pay needs to do some background work to maintain the connection to the PED. In many cases closing the connection and cleaning up is also required. For LS Pay to perform these tasks, LS Pay uses two basic functions that need to be called. They are

  • InitAsync() - should be called when the host client starts up.
  • TerminateAsync() - should be called when the host client shuts down.

Two more mobile specific functions are also provided:

  • EnteringBackgroundAsync()

  • EnteringForgroundAsync().

These should be called whenever the host application enters foreground or background.

The EAManagement interface (IEAManagement) has one event, the ConnectionStatusChanged event.
Note: Subscribe to this event to get notified about when the connection to the PED changes.

The image below shows a typical LS Pay life cycle:

Life cycle of LS Pay

The following code snippets are run, when the program starts up and shuts down.

Initializing:

Copy
private static async Task InitConnection()
{
    // Get the correct External accessory management
    eam = EAManagementModelFinder.EAManagementModel(psp);
    // Get the EFT from the EAM there you can make the transactions
    eft = eam.GetEFT();
    // Init the connection
    await eam.InitAsync();
}

Terminating:

Copy
private static async Task TerminateAsync()
{
    await eam.TerminateAsync();
}