private String getHash(PayUDetails details) { StringBuilder hashString = new StringBuilder(); hashString.append(details.getMerchant().length()); hashString.append(details.getMerchant()); hashString.append(details.getReference().length()); hashString.append(details.getReference()); hashString.append(details.getAmount().length()); hashString.append(details.getAmount()); hashString.append(details.getCurrency().length()); hashString.append(details.getCurrency()); hashString.append(details.getDate().length()); hashString.append(details.getDate()); return hmacMD5(hashString.toString(), secretKey); }
private List<Pair<String, String>> getParameters(PayUDetails details) { List<Pair<String, String>> parameters = new ArrayList<Pair<String, String>>(); parameters.add(new Pair<String, String>("MERCHANT", details.getMerchant())); parameters.add(new Pair<String, String>("ORDER_REF", details.getReference())); parameters.add(new Pair<String, String>("ORDER_AMOUNT", details.getAmount())); parameters.add(new Pair<String, String>("ORDER_CURRENCY", details.getCurrency())); parameters.add(new Pair<String, String>("IRN_DATE", details.getDate())); parameters.add(new Pair<String, String>("ORDER_HASH", getHash(details))); parameters.add(new Pair<String, String>("REF_URL", details.getReferenceUrl())); return parameters; }