# Route payments to multiple payment service providers (/global/en/docs/Terminal/AdvancedIntegrations/Route-payments-to-multiple-payment-service-provider)

## Route payments to multiple payment service providers

In real deployment environments, a payment terminal may provide multiple services of the same type, or multiple payment terminals may be available around an EPOS.

Before initiating a transaction, EPOS may need to select an appropriate service object as the target.

### Service Object Description

A service object represents a specific callable capability provided by a payment terminal, for example:

- Purchase Service: Card payment transactions
- Refund Service: Refund processing
- Printer Service: Receipt printing

A single terminal may expose multiple service objects of the same type. This can happen in the following cases:

1. Multiple payment applications
   The same terminal has multiple payment applications installed that support the same transaction type.
2. Multiple service instances
   A single payment application exposes multiple service instances with different configurations.

Therefore, before initiating a transaction, EPOS may need to:

1. Retrieve the list of available service objects on the target device.
2. Select a service object based on business rules.

### Retrieve Service Objects from a Device

EPOS can retrieve discovered services through the SDK, then filter them by the target terminal and required capability:

```java
RetailerSettingManager.showAllService((List<TerminalServiceInfo> terminalServiceInfos)->{
    for (TerminalServiceInfo terminalServiceInfo : terminalServiceInfos) {
        System.out.println(terminalServiceInfo.getServiceId());
    }
});          
```

Service information includes terminal identity, service type, service ID, names, and application information. Android and Windows use `TerminalServiceInfo`; iOS uses `ServiceInfo`.

| Information  | Purpose                                                                                                               |
| ------------ | --------------------------------------------------------------------------------------------------------------------- |
| Terminal SN  | Identify the terminal hosting the service.                                                                            |
| Service type | Identify the capability; several providers may offer the same type.                                                   |
| Service ID   | Identify a specific service instance; combine it with terminal SN when selecting a provider on a particular terminal. |

Filter by terminal and capability before selecting a provider. Before setting a default or per-request target by SN or service ID, the SDK must have discovered the corresponding terminal or service. Obtain service IDs from discovery results. Service type, service ID, and terminal SN are not interchangeable.

### Target Configuration Scope

| Configuration                         | Effect                                                                                                                      |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| Default target in the setting manager | Supply a reusable target for subsequent requests without an explicit per-request target.                                    |
| Target on an individual request       | Specify the terminal or service for that request, without temporarily changing a shared default to route it.                |
| SDK selection and remember options    | Choose from available services according to the selection policy; the picker may appear when there is no applicable target. |

Communication, saved settings, and terminal switching are covered in the terminal configuration guide. Service routing remains subject to the capabilities actually offered by the selected provider.

### Default Target Configuration

For a terminal's SN, address, and communication configuration, see [Terminal Configuration and Selection](doc-id:358d4159). When that terminal has multiple providers, set the terminal SN and service ID together.

**Set a service provider on the selected terminal for applicable requests:**

```java
// Set the selected terminal and provider as the default target.
RetailerSettingManager.destination(Destinations.serviceDestination("serviceId","SN"));
```

### Recommendations for Multi-Device and Multi-Service Scenarios

In the following scenarios, it is NOT recommended to bind to a fixed service object:

1. Multiple terminals are available around the EPOS
2. Terminals may be replaced or moved dynamically
3. Different transaction types require different devices or services

In such cases, it is recommended to:

1. Use SDK-based device and service discovery
2. Display available devices and services via UI
3. Let the operator select the target service at runtime

### Dynamic Target Selection

A request target applies to the individual operation. Select it from discovery results, and retain the terminal and service identity used by that request for later queries or related operations.

1. Specify Target Device

```java
// Specify the target terminal by SN
RetailerManager.provideFinancialService()
        .newPaymentExchange(paymentParam)
        .destination(Destinations.terminal("NDNL00017998"))
        .startAsyncExchange(callback);

// Specify the local terminal to execute the transaction
RetailerManager.provideFinancialService()
        .newPaymentExchange(paymentParam)
        .destination(Destinations.currentTerminal())
        .startAsyncExchange(callback);
```

2. Specify Both Device and Service

This scenario applies when there are multiple acquirers and multiple devices, but you want a specific transaction to prioritize a specific acquirer service on a specific device.

```java
RetailerManager.provideFinancialService().newPaymentExchange(paymentParam)
       .destination(Destinations.serviceDestination("serviceId", "SN"))
       .startAsyncExchange(callback);
```

### Clear Configuration and Reset Strategy

When terminals or services change, clear the scope affected by the obsolete choice: terminal, service type, service category, or all options. Available overloads and scopes differ by platform. Update the application's saved target as well; see [Terminal Configuration and Selection](doc-id:358d4159) for switching and restoration.

```java
// Clear the preferred device configuration (by SN)
RetailerSettingManager.clearRememberOption("sn");

// Clear the configuration for a specific service
RetailerSettingManager.clearRememberOption(ServiceTypes.CARD_PAYMENT);

// Clear the configuration for a specific service category
RetailerSettingManager.clearRememberOption(ServiceCategory.FINANCIAL);

// Clear all saved configuration
RetailerSettingManager.clearRememberOption(ServiceTypes.ALL);
```