Smart Router Functionality

Practical demonstration of smart router functionality.

In this example, we will create a Smart Router instance that utilizes the Transaction Size Strategy. The following steps will demonstrate how to configure the Smart Router and define the criteria for selected MIDs, specifically MPGS and Knet MIDs.

Step 1: Create a Smart Router Instance

Navigate to the PGSR (Smart Router section) in the Administration Panel and click on the Add Smart Router button. Fill in the required details as shown in the figure below:

Smart Router Configuration:

  • Name: Smart Router Example

  • Is Active: Yes

  • Code Identifier: smart_router_example

  • Strategies: Transaction Size Strategy

Step 2: Define Criteria for Selected MIDs

Since we are using the Transaction Size Strategy, the criteria for this strategy must be defined for each selected MID. The figure below shows the criteria defined for MPGS and Knet MIDs:

Knet MID Criteria:

  • Minimum Amount: 1

  • Maximum Amount: 50

MPGS MID Criteria:

  • Minimum Amount: 51

  • Maximum Amount: 100

Using the Checkout API, we will create a checkout link. Below is the payload request for creating the checkout link:

{
    "type": "payment_request",
    "pg_codes": ["smart-router-example"],
    "amount": "55",
    "currency_code": "KWD"
}

The generated checkout link will redirect to the Checkout Page where the customer will click on the Pay button.

Step 4: Payment Processing with Smart Router

Once the pay button is clicked, the Smart Router starts functioning to choose the best path between the two chosen MIDs (MPGS and Knet). The path selection is based on the defined criteria.

As shown in the figure below, the chosen MID is MPGS since the transaction amount is 55, which falls within the range of the defined MPGS criteria.

If we change the amount in the request payload to be 50.

{
    "type": "payment_request",
    "pg_codes": ["smart-router-example"],
    "amount": "50",
    "currency_code": "KWD"
}

The Smart Router will choose Knet since the defined range covers the amount, as shown in the figure below:

Conclusion

By following these steps, we demonstrated how to create a Smart Router instance using the Transaction Size Strategy and defined criteria for MPGS and Knet MIDs. This example illustrates how the Smart Router dynamically selects the most appropriate payment gateway based on the transaction amount, optimizing the payment processing workflow and enhancing overall efficiency.

Last updated