@RequestMapping(value = "/rechargedetail", method = RequestMethod.POST) public String rechargeDetail( @ModelAttribute("telecomrecharge") TransactionTransportBean transactionTransport, /* @RequestParam Long uuid, */ ModelMap model, HttpServletRequest req) { HttpSession session = req.getSession(); String pathToFollow = null; Long suuid = (Long) session.getAttribute("suuid"); if (suuid != null) { session.setAttribute("suuid", null); session.setAttribute("rechargeType", transactionTransport.getRechargeType()); session.setAttribute("circle", transactionTransport.getCircleName()); session.setAttribute("mobileNo", transactionTransport.getMobileNo()); session.setAttribute( "amount", CyberTelUtil.removeDecimalFromNumber(transactionTransport.getAmount())); session.setAttribute("operator", transactionTransport.getOperator()); transactionTransport.setRetailerId((String) req.getSession().getAttribute("userid")); transactionTransport.setTransactionName("MOBILE_RECHARGE"); transactionTransport.setFranchiseeMobileNum((String) session.getAttribute("userName")); try { rechargeTransactionService.doRechargeService(transactionTransport); } catch (Exception e) { e.printStackTrace(); transactionTransport.setMessage("System Error"); // transactionTransport.setErrorCode(3); } if (transactionTransport.getErrorCode() > 0 || transactionTransport.getThirdpartytransid() == null) { String errorMsg = "Error in Transaction</br>"; if (transactionTransport.getMessage() != null) { errorMsg += transactionTransport.getMessage(); } model.addAttribute("Error", errorMsg); model.addAttribute("telecomrecharge", transactionTransport); pathToFollow = "telecomRechargeFran"; } else { session.setAttribute("transId", transactionTransport.getTransid()); // SimpleDateFormat sdf = new // SimpleDateFormat("dd-MM-yyyy hh:mm:ss"); session.setAttribute("datetime", transactionTransport.getThirdPartyTransDateTime()); // model.addAttribute("datetime", // sdf.format(transactionTransport.getCreatedAt())); String userId = (String) session.getAttribute("userid"); FranchiseeInfo franchiseeInfo = franchiseeInfoService.getFranchiseeInfo(userId); session.setAttribute("franchiseeInfo", franchiseeInfo); pathToFollow = "redirect:rechargedetailfran"; } } else { } return pathToFollow; }
public void doTransaction(TransactionTransportBean transportBean) throws MalformedURLException { initializeCyberplateETransaction(transportBean); String finalData = null; try { finalData = getDataFromThirdParty(transportBean); // System.out.println("final data of getdata from thirdparty" // + finalData); } catch (ThirdPartyRechargeCallException e) { e.printStackTrace(); transportBean.setMessage( "Transaction pending from thirdparty: ThirdPartyRechargeCallException"); return; } catch (Exception e) { e.printStackTrace(); if (e instanceof MalformedURLException) throw (MalformedURLException) e; transportBean.setMessage("Transaction pending from thirdparty"); return; } if (finalData != null && !finalData.startsWith("PROBLEM")) { Map<String, String> dataMap = parseResponse(finalData); // System.out.println("parsed data" + dataMap.size() + dataMap); String errorValue = dataMap.get("ERROR"); String resultVal = dataMap.get("RESULT"); if (!"0".equals(errorValue) || !"0".equals(resultVal)) { try { transportBean.setErrorCode(2); } catch (Exception e) { e.printStackTrace(); transportBean.setErrorCode(2); } transportBean.setErrorcode(errorValue); transportBean.setMessage("Error " + errorValue); transportBean.setErrorMessage("Error " + errorValue); } else if ("0".equals(errorValue) && "0".equals(resultVal)) { transportBean.setThirdpartytransid(dataMap.get("TRANSID")); StringBuffer values = new StringBuffer(); values.append(dataMap.get("SESSION")); if (dataMap.get("AUTHCODE") != null) { values.append(":").append(dataMap.get("AUTHCODE")); } transportBean.setResponsecode(values.toString()); if (!transportBean.getMessage().contains("Your card has been credited by")) { transportBean.setMessage("Transaction Successful"); } transportBean.setThirdPartyTransDateTime(dataMap.get("DATE")); } } }