@Override
  public List<HkPaymentResponse> seekPaymentFromGateway(Payment basePayment)
      throws HealthkartPaymentGatewayException {
    String gatewayOrderId = basePayment.getGatewayOrderId();
    List<HkPaymentResponse> gatewayPaymentList = new ArrayList<HkPaymentResponse>();

    try {

      // call payment gateway and get the base payment object
      Element element =
          callPaymentGateway(
              gatewayOrderId, null, null, null, EbsPaymentGatewayWrapper.TXN_ACTION_STATUS);
      HkPaymentResponse baseGatewayPayment =
          verifyAndCreateHkResponsePayment(
              element, gatewayOrderId, EnumPaymentTransactionType.SALE.getName());
      List<Payment> paymentList =
          paymentDao.searchPayments(null, null, null, null, null, null, null, basePayment, null);

      gatewayPaymentList.add(baseGatewayPayment);

      // again call gateway and update all child payment list
      if (paymentList != null) {
        for (Payment payment : paymentList) {
          String gatewayReferenceId = payment.getGatewayReferenceId();
          String rrn = payment.getRrn();
          if (gatewayReferenceId != null && rrn != null) {
            Element ele =
                callPaymentGateway(
                    gatewayOrderId,
                    payment.getGatewayReferenceId(),
                    payment.getRrn(),
                    null,
                    EbsPaymentGatewayWrapper.TXN_ACTION_STATUS_PAYMENT_ID);
            HkPaymentResponse childPayment =
                verifyAndCreateHkResponsePayment(
                    ele, payment.getGatewayOrderId(), EnumPaymentTransactionType.REFUND.getName());
            gatewayPaymentList.add(childPayment);
          } else {
            HkPaymentResponse hkPaymentResponse =
                createPayment(
                    payment.getGatewayOrderId(),
                    null,
                    null,
                    payment.getErrorLog(),
                    EnumPaymentTransactionType.REFUND.getName(),
                    payment.getAmount().toString(),
                    null);
            hkPaymentResponse.setHKPaymentStatus(EnumHKPaymentStatus.FAILURE);
            gatewayPaymentList.add(hkPaymentResponse);
          }
        }
      }

    } catch (Exception e) {
      logger.debug("Ebs Payment gateway exception :", e);
      // throw new
      // HealthkartPaymentGatewayException(HealthkartPaymentGatewayException.Error.UNKNOWN);
    }

    return gatewayPaymentList;
  }
  @SuppressWarnings("unchecked")
  private Element callPaymentGateway(
      String gatewayOrderId, String gatewayReferenceId, String rrn, String amount, String action)
      throws Exception {

    Element ele = null;
    String propertyLocatorFileLocation =
        AppConstants.getAppClasspathRootPath() + EBS_LIVE_PROPERTIES;
    Properties properties = BaseUtils.getPropertyFile(propertyLocatorFileLocation);
    // String action = EbsPaymentGatewayWrapper.TXN_ACTION_STATUS;
    // Instantiate an HttpClient
    HttpClient client = new HttpClient();
    String url = EbsPaymentGatewayWrapper.EBS_TXN_URL;

    // Instantiate a GET HTTP method
    PostMethod method = new PostMethod(url);
    method.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");

    // Define name-value pairs to set into the QueryString
    NameValuePair nvp1 =
        new NameValuePair(
            EbsPaymentGatewayWrapper.TXN_SECRET_KEY,
            (String) properties.get(GatewayResponseKeys.EbsConstants.GATEWAY_SECRET_KEY.getKey()));
    NameValuePair nvp2 = new NameValuePair(EbsPaymentGatewayWrapper.TXN_ACTION, action);
    NameValuePair nvp3 = new NameValuePair(EbsPaymentGatewayWrapper.Amount, amount); // txnAmount
    NameValuePair nvp4 =
        new NameValuePair(EbsPaymentGatewayWrapper.TXN_REF_NO, gatewayOrderId); // AccountID
    NameValuePair nvp5 =
        new NameValuePair(EbsPaymentGatewayWrapper.PaymentID, gatewayReferenceId); // txnPaymentId
    NameValuePair nvp6 =
        new NameValuePair(EbsPaymentGatewayWrapper.TransactionID, rrn); // TODO: change here too
    //   Account id should be the last parameter
    NameValuePair nvp7 =
        new NameValuePair(
            EbsPaymentGatewayWrapper.TXN_ACCOUNT_ID,
            (String) properties.get(GatewayResponseKeys.EbsConstants.ACCOUNT_ID.getKey()));

    String res = null;
    if (action.equals(EbsPaymentGatewayWrapper.TXN_ACTION_STATUS)) {
      method.setQueryString(new NameValuePair[] {nvp1, nvp2, nvp4, nvp7});
    } else if (action.equals(EbsPaymentGatewayWrapper.TXN_ACTION_REFUND)
        || action.equals(EbsPaymentGatewayWrapper.TXN_ACTION_CAPTURE)
        || action.equals(EbsPaymentGatewayWrapper.TXN_ACTION_CANCEL)) {
      method.setQueryString(new NameValuePair[] {nvp1, nvp2, nvp3, nvp5, nvp7});
    } else if (action.equalsIgnoreCase(EbsPaymentGatewayWrapper.TXN_ACTION_STATUS_PAYMENT_ID)) {
      method.setQueryString(new NameValuePair[] {nvp1, nvp2, nvp5, nvp6, nvp7}); // TODO: npv4->npv2
    }

    client.executeMethod(method);
    res = method.getResponseBodyAsString();
    Document doc = new SAXBuilder().build(new StringReader(res));

    XPath xPath = XPath.newInstance("/output");
    List<Element> xmlElementList = xPath.selectNodes(doc);

    if (xmlElementList != null && !xmlElementList.isEmpty()) ele = xmlElementList.get(0);

    method.releaseConnection();

    return ele;
  }