1. Documentation
  2. AppFlow
  3. POS Applications
  4. Guides

Guides


Technical

Querying examples

All the operations documented here assumes that you already have access to the PaymentSettings, which can be retrieved as per below

paymentClient.getPaymentSettings()
  .subscribe(paymentSettings -> {
         // Use for the operations on this page
   });

Flow configuration operations

This lists some useful operations. For a full list of API methods, please see the FlowConfiguration javadocs.

Get a list of all flow configurations

Returns a list of all the current flow configurations.

List<FlowConfig> flowConfigurations = paymentSettings.getFlowConfigurations().getAll();

Check if a flow type is supported

paymentSettings.getFlowConfigurations().isFlowTypeSupported("sale");

Get all flow types

You can either query for all flow types (pass in null) or specifically for payment flows or generic flows.

paymentSettings.getFlowConfigurations().getFlowTypes(null);
paymentSettings.getFlowConfigurations().getFlowTypes(FlowConfig.REQUEST_CLASS_PAYMENT);
paymentSettings.getFlowConfigurations().getFlowTypes(FlowConfig.REQUEST_CLASS_GENERIC);

Get flow details from type

There can be more than one flow per type, differentiated by the flow name. For instance, there may be a flow named basicSale that has no loyalty apps, whereas loyaltySale does. They are both of type sale.

paymentSettings.getFlowConfigurations().getFlowNamesForType("sale");

The name can then be used to set in the request to initiate a flow, or to query for flow details

paymentSettings.getFlowConfigurations().getFlowConfiguration("loyaltySale");

Filter flow configurations

If you want to filter flow configurations by some criteria, you can use stream(). The below filters based on whether the flow contains the TRANSACTION_PROCESSING stage or not.

paymentSettings.getFlowConfigurations().stream()
                .filter(flowConfig -> flowConfig.hasStage(FlowStages.TRANSACTION_PROCESSING))
                .subscribe(flowConfig -> {
                    // Do something
                });

Flow service operations

This lists some useful operations. For a full list of API methods, please see the PaymentFlowServices javadocs and PaymentFlowServiceInfo javadocs.

Get a list of all flow services

Returns a list of all installed flow services on the device.

List<PaymentFlowServiceInfo> flowServices = paymentSettings.getPaymentFlowServices().getAll();

Filter flow services

Flow services can be filtered by any of the data that is exposed by them, such as currency or payment methods. In the example, we below, we use stream() which we then apply a filter to.

paymentSettings.getPaymentFlowServices().stream()
                .filter(paymentFlowServiceInfo -> paymentFlowServiceInfo.supportsCurrency("EUR"))
                .toList()
                .subscribe(paymentFlowServiceInfos -> {
                    // List of flow services that supports "EUR"
                });

Retrieve collated information

The PaymentFlowServices model collates information about all the flow services into collections.

Set<String> allSupportedCurrencies = paymentSettings.getPaymentFlowServices().getAllSupportedCurrencies();

Example below provides a set of all the supported currencies.

Check for support

The PaymentFlowServices model contains some useful "is" methods, like isCurrencySupported(), which will check across all the flow services.

paymentSettings.getPaymentFlowServices().isCurrencySupported("EUR");

Flow response listeners

Client (POS) applications must define a response entry point that is called when the final flow responses are available.

This can be done by extending and implementing one of the response listener services. Currently two base listener services are defined:

  • BaseResponseListenerService - to listen for Response objects resulting from a initial Request
  • BasePaymentResponseListenerService - to listen for PaymentResponse objects resulting from a Payment request

Response service

Response services have two callback methods for responses - one for generic responses, such as for any of the defined flow types or custom request types, and one for responses from a status update flow. These are delivered separately as many clients may not be interested in responses from status updates.

There is also a callback method for errors that may have occurred during a flow.

public class ResponseListenerService extends BaseResponseListenerService {

  @Override
  protected void notifyGenericResponse(Response response) {
     // Handle generic response
  }

  @Override
  protected void notifyStatusUpdateResponse(Response response) {
     // Handle (if required) status update response
  }

  @Override
  protected void notifyError(String errorCode, String errorMessage) {
      // Map error code against one of `ErrorConstants`
  }
}

The service should be registered in your manifest as normal and should include the correct intent filter as shown below.

<service
  android:name=".ResponseListenerService"
  android:exported="true">
  <intent-filter>
      <action android:name="com.aevi.sdk.flow.action.PROCESS_RESPONSE"/>
  </intent-filter>
</service>

Payment response listener

In order to receive payment flow outcomes, your application should implement the notifyResponse and notifyError methods as shown in the example for payment responses below.

public class PaymentResponseListenerService extends BasePaymentResponseListenerService {

  @Override
  protected void notifyResponse(PaymentResponse paymentResponse) {
     // Handle response
  }

  @Override
  protected void notifyError(String errorCode, String errorMessage) {
     // Map error code against one of `ErrorConstants`
  }
}

The service should be registered in your manifest as normal and should include the correct intent filter as shown below.

<service
  android:name=".PaymentResponseListenerService"
  android:exported="true">
  <intent-filter>
      <action android:name="com.aevi.sdk.flow.action.PROCESS_PAYMENT_RESPONSE"/>
  </intent-filter>
</service>