Below script can be used to get the credit card type and set it in ticket properties.
Add the below lines in the resource, Script.AddProprties:
for (int i = 0 ; i < ticket.getPayments().size() ; i++) { if(ticket.getPayments().get(i).getName().equals("magcard")) { if(ticket.getPayments().get(i).getCardNumber().substring(0,1).equals("3")) { if(ticket.getPayments().get(i).getCardNumber().substring(0,2).equals("34")) { ticket.setProperty("CardType","AMERICAN EXPRESS"); } else if(ticket.getPayments().get(i).getCardNumber().substring(0,2).equals("37")) { ticket.setProperty("CardType","AMERICAN EXPRESS"); } if(ticket.getPayments().get(i).getCardNumber().substring(0,4).equals("3528")) { ticket.setProperty("CardType","JCB"); } else { ticket.setProperty("CardType","DINERS CLUB"); } } else if(ticket.getPayments().get(i).getCardNumber().substring(0,1).equals("4")) { ticket.setProperty("CardType","VISA"); } else if(ticket.getPayments().get(i).getCardNumber().substring(0,1).equals("5")) { ticket.setProperty("CardType","MASTER CARD"); } else if(ticket.getPayments().get(i).getCardNumber().substring(0,1).equals("6")) { ticket.setProperty("CardType","DISCOVER"); } } } Save & restart
Leave a Reply