Routing Logic for choosing the best gateway to handle your transaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WARNING: This code is a sample to test your logic of gateway priority. This is NOT to be used as such. | |
def order = [order_id: "ord_id", amount: 1000.00, udf1:"web", udf2: "desktop", gateway_id: 2] | |
def txn = [txn_id: "txn_id", express_checkout: true, add_to_locker: false ] | |
def payment = [card_isin: "524368", card_issuer: "HDFC Bank", card_type: "CREDIT"] | |
def setGatewayPriority = { gateways -> | |
println "priority: " + gateways; | |
} | |
def channelRouter = { order, txn, payment -> | |
def priorities = ["HDFC", "ICICI", "PAYU"] // if udf1 is not set | |
if (order.udf1 == "web") { | |
priorities = ["HDFC","PAYU","ICICI"] | |
} | |
else if (order.udf1 == "mobile" && order.udf2 == "android") | |
priorities = ["ICICI","HDFC","PAYU"] | |
} | |
setGatewayPriority(priorities) | |
} | |
def volumeRouter = { order, txn, payment-> | |
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"]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment