How to setup Dynamic Routing?

Our approach

It is important to understand JusPay's implementation of dynamic routing to be able to configure gateway priorities correctly for your Merchant Account. Our approach has been to ensure maximum conversion rate and the implementation reflects this. The dynamic routing algorithm uses a non-deterministic mathematical model to rank all applicable gateways for the given transaction, using a lot of information, such as, gateway health, gateway performance for a similar transaction recently, historical performance, etc.. Along with this, we take into account the priorities configured by you and arrive at the final gateway, such that the success probability is the highest.

So, please do not be surprised if a different gateway is chosen for a particular transaction which doesn't really align with your configuration. Getting you the maximum success rate is more important to us.

If a particular gateway is not applicable for a transaction, say payment mode is SBI NetBanking and gateway is HDFC PG, then that gateway will be automatically dropped by us. So, you don't have to take care of that in the priority logic.

Simple routing

Most typical routing logic would be to set up one gateway as primary and another gateway as secondary. Secondary gateway is usually used as a backup in case of primary gateway going down. However, there could be cases where a specific card BIN performs really well with the given PG and we might end up chosing the secondary gateway in such a case.

You can configure the priorities of gateways using a comma separated string representation. For instance, say you have two gateways namely HDFC and ICICI. Now, if you need to setup HDFC as primary and ICICI as secondary, then you should configure the priorities as given below:

HDFC,ICICI

DSL

We understand that one size doesn't fit all. So, we have come up with another flexible option where you have the complete capability to dynamically set the priority.

You can describe the priority logic in Groovy code and set the priority dynamically for any given transaction. The gateways should be identified using the unique names (enumerations given below) and you are expected to setup the priority in the form of a string List. First gateway in the list has the highest priority and so will be preferred over others.

Note: Good code writing skills are necessary here. If you dont know what this is or is doubtful, please get in touch with us along with your requirement and we will help set this up for you.

Context

Transaction details are given as input to the DSL. Please see below for all the input variables that will be available to you in the DSL.


def order = [orderId: "orderId", amount: 1000.00, udf1:"web", udf2: "desktop"]
def txn = [txnId: "txnId", isEmi: false, emiBank: "HDFC", emiTenue: "6" ]
def payment = [cardBin: "524368", cardIssuer: "HDFC Bank", cardType: "CREDIT", cardBrand: "MASTERCARD"]
def setGatewayPriority = { gateways -> 
 println "priority: " + gateways;
}

// the above is available to the DSL as context variables

Example 1. Routing based on Channel

If you wish to route the transactions based on channel say web or mobile.

def priorities = ["HDFC", "ICICI", "PAYU"] 
 // above is the default priority

 if (order.udf1 == "web") {
 priorities = ["HDFC","PAYU","ICICI"]
 }
 else if (order.udf1 == "mobile" && order.udf2 == "android")
 priorities = ["ICICI","HDFC","PAYU"]
 }
 setGatewayPriority(priorities)

Example 2. Volume based routing

def priorities = []
 // def myGateways = ["HDFC","ICICI"]
 // 50% approx split between two gateways
 setGatewayPriority(shuffle(['HDFC', 'ICICI']))

 // def myGateways = ["HDFC","ICICI", "AXIS"]
 // 1/3 split between three gateways
 setGatewayPriority(shuffle(['HDFC', 'ICICI', "AXIS"]))

 // def myGateways = ["HDFC","ICICI", "AXIS"]
 // 1/2 split between two gateways and use third as backup
 setGatewayPriority(shuffle(['HDFC', 'ICICI']), "AXIS"])

Example 3. Issuer based routing

def priorities = ["HDFC", "ICICI"] 
 // default priorities
 if (payment.cardIssuer == "ICICI Bank") { 
 // if ICICI Bank card, use ICICI
 priorities = ["ICICI", "HDFC"]
 }
 else if (order.udf1 == "mobile" && order.udf2 == "android")
 // for android transactions, use ICICI
 priorities = ["ICICI","HDFC"]
 }
 setGatewayPriority(priorities)

Example 4. Card Brand based routing

def priorities = ["HDFC", "ICICI", "PAYU"] 
 // default priorities
 if (payment.cardBrand == "MAESTRO") { 
 // if Maestro card, use ICICI as primary
 priorities = ["ICICI", "PAYU", "HDFC"]
 }
 else if (payment.cardBrand == "AMEX")
 priorities = ["PAYU", "ICICI", "HDFC"]
 }
 setGatewayPriority(priorities)

Example 5. Card type based routing

def priorities = ["HDFC", "ICICI"] 
 // default priorities
 if (payment.cardType == "CREDIT") { 
 // if Credit card, use ICICI
 priorities = ["ICICI", "HDFC"]
 }
 else if (payment.cardType == "DEBIT")
 // for Debit Card transactions, use HDFC
 priorities = ["HDFC","ICICI"]
 }
 setGatewayPriority(priorities)


Enumerations

List of gateways:

  • HDFC
  • ICICI
  • AXIS
  • CITI
  • AMEX
  • PAYU
  • CITRUS
  • TPSL
  • PAYTM
  • CCAVENUE
  • CCAVENUE_V2
  • EBS
  • RAZORPAY
  • ATOM

List of card brands:

  • VISA
  • MASTERCARD
  • MAESTRO
  • RUPAY
  • AMEX
  • DINERS
  • DISCOVER

List of card types:

  • CREDIT
  • DEBIT


Configure priority

To set this up, please proceed to Merchant Settings and enable the checkbox that says: I'd rather write code to define the priority. In the given text area, enter your DSL logic and then click on Update Gateway details.

Special rules

In addition to the routing logic explained above, we have also provided you with the ability to define specific rules to assign different gateway priorities for a given card BIN / card issuer bank / Card Brand. For instance, if you have negotiated special rates for HDFC cards on HDFC PG, then you can configure this on the dashboard.

Refer Gateway Route Scores for configuring this.

ISIN Routing

Setup your scoring for ISIN (card BIN) and Issuer route for different gateways here. Using this, you can setup a rule stating that for a particular credit card BIN range say 524368 (HDFC issued credit cards), we should give higher priority to HDFC gateway

Issuer Routing

Issuer typically refers to the bank which has issued the credit or debit card. In some countries even credit unions or prepaid card providers can also issue cards. You can setup rules to specify dynamic scoring for a particular issuer and a gateway

Card Brand Routing

Card Brands include VISA, MASTERCARD, MAESTRO, AMEX, RUPAY, DISCOVER, DINERS, JCB. Setup your scoring to route based on a card brand and a gateway

Score

The score is expected to be in the range of 0.0 - 2.0 (decimals are allowed). Giving a value of 2.0 will increase the priority of the gateway by 2x. A value of 0.5 will reduce the priority score by 50%. A score of 1.0 will make the rule neutral.

Was this article helpful?