Hey! These docs are for version 3.2, which is no longer officially supported. Click here for the latest version, 1.0!

Annexure 2: Sample Routing logics

Refer Documentation on Routing logic:

Samples

Example 1: Routing based on Channel

If you wish to route the transaction 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 myGateways = ['HDFC','ICICI']
  // Goal: 50% approx split between two gateways

  if(currentTimeMillis % 10 < 5) {
    setGatewayPriority(['HDFC', 'ICICI'])
  }
  else {
    setGatewayPriority(['ICICI', 'HDFC'])  
  }

  // def myGateways = ["HDFC","ICICI", "AXIS"]
  // Goal: 1/2 split between two gateways and use third as backup
  if(currentTimeMillis % 10 < 5) {
    setGatewayPriority(['HDFC', 'ICICI', 'AXIS'])
  }
  else {
    setGatewayPriority(['ICICI', 'HDFC', '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' ]
  }
  else { // for everything else use HDFC as primary
    priorities = [ 'HDFC', 'ICICI' ]
  }
  setGatewayPriority(priorities)

Did this page help you?