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"));
      }
    }
  }
  private String getDataFromThirdParty(TransactionTransportBean transactionTransport)
      throws Exception {

    String finalInput = null;

    StringBuilder sessionVal = new StringBuilder(transactionTransport.getRetailerId());
    int length = transactionTransport.getRetailerId().length();
    if (length < 10) {
      for (int i = 0; i < 8 - transactionTransport.getRetailerId().length(); i++) {
        sessionVal.append("0");
      }
    }

    String operatorCode = transactionTransport.getOperatorCode();
    String connectURL[] = new String[2];
    if (operatorCode != null) {
      StringTokenizer stringTokenizer = new StringTokenizer(operatorCode, ";");
      int index = 0;
      while (stringTokenizer.hasMoreTokens()) {
        connectURL[index] = stringTokenizer.nextToken();
        index++;
      }
    }
    if (connectURL.length > 1) {
      sessionVal.append(transactionTransport.getTransid().substring(13));
      finalInput = inputMessageCreation(transactionTransport, sessionVal, true);
      String outputMessage = getDataFromURL(connectURL[0], finalInput);
      // System.out.println("outputMessage getDataFromThirdParty "
      // + outputMessage);
      int errorIndex = outputMessage.indexOf("ERROR=");
      int resultIndex = outputMessage.indexOf("RESULT=");
      // System.out.println("resultIndex>" + resultIndex);
      String errorVal = "1";
      String resultVal = "1";
      if (errorIndex != -1 && resultIndex != -1) {
        errorVal = outputMessage.substring(errorIndex + 6, errorIndex + 8);
        resultVal = outputMessage.substring(resultIndex + 7, resultIndex + 9);
        // System.out.println("resulVal:> " + resultVal);
      }

      if ((resultVal != null && "0".equals(resultVal.trim()))
          && (errorVal != null && "0".equals(errorVal.trim()))) {
        transactionTransport.setConnectURL(connectURL[1]);

        finalInput = inputMessageCreation(transactionTransport, sessionVal, false);
        outputMessage = getDataFromURL(transactionTransport.getConnectURL(), finalInput);
        // System.out.println("outputMessage:::" + outputMessage);
        String[] line = outputMessage.split("\n");
        String addInfo = "";
        for (String info : line) {
          if (info.contains("ADDINFO=")) {
            addInfo = info.substring(8);
            break;
          }
        }
        transactionTransport.setMessage(addInfo);

      } else {
        transactionTransport.setErrorCode(2);
        transactionTransport.setErrorcode(errorVal);
        transactionTransport.setMessage("Error " + errorVal);
        transactionTransport.setErrorMessage("Error " + errorVal);
        // System.out.println("errore code"
        // + transactionTransport.getErrorcode() + "message"
        // + transactionTransport.getMessage());
        return "PROBLEM:" + errorVal;
      }
      return outputMessage;
    }
    return "PROBLEM:Operator Setup Error";
  }