private HkPaymentResponse verifyAndCreateHkResponsePayment(
      Element element, String gatewayOrderId, String transactionType) {
    HkPaymentResponse hkPaymentResponse = null;
    if (element != null) {
      hkPaymentResponse =
          createPayment(
              gatewayOrderId,
              null,
              null,
              null,
              transactionType,
              null,
              null); // EnumPaymentTransactionType.SALE.getName()

      String paymentId =
          element.getAttributeValue(GatewayResponseKeys.EbsConstants.TXN_PAYMENT_ID.getKey());
      String transactionId =
          element.getAttributeValue(GatewayResponseKeys.EbsConstants.TXN_TRANSACTION_ID.getKey());
      String amount = element.getAttributeValue(GatewayResponseKeys.EbsConstants.AMOUNT.getKey());
      String status =
          element.getAttributeValue(GatewayResponseKeys.EbsConstants.TXN_STATUS.getKey());
      String isFlagged =
          element.getAttributeValue(GatewayResponseKeys.EbsConstants.IS_FLAGGED.getKey());
      String errorCode = element.getAttributeValue(EbsPaymentGatewayWrapper.TXN_ERROR_CODE);
      String errorMessage = element.getAttributeValue(EbsPaymentGatewayWrapper.TXN_ERROR_MSG);
      String ebsTransactionType =
          element.getAttributeValue(EbsPaymentGatewayWrapper.TXN_TRANSACTION_TYPE);
      // String gatewayOrderId =
      // element.getAttributeValue(EbsPaymentGatewayWrapper.TXN_REFERENCE_NO);

      if (paymentId != null) {

        hkPaymentResponse.setGatewayReferenceId(paymentId);
        hkPaymentResponse.setRrn(transactionId);
        hkPaymentResponse.setAmount(NumberUtils.toDouble(amount));
        hkPaymentResponse.setResponseMsg(status);
        updateResponseStatus(
            hkPaymentResponse, transactionType, isFlagged, status, ebsTransactionType);

      } else {
        hkPaymentResponse.setHKPaymentStatus(EnumHKPaymentStatus.FAILURE);
        hkPaymentResponse.setErrorLog(errorMessage);
      }
    }

    return hkPaymentResponse;
  }
 private void updateSalePaymentStatus(
     HkPaymentResponse hkPaymentResponse, String isFlagged, String ebsTransactionType) {
   if (GatewayResponseKeys.EbsConstants.Authorized.getKey().equalsIgnoreCase(ebsTransactionType)) {
     if (isFlagged != null
         && isFlagged.equalsIgnoreCase(
             GatewayResponseKeys.EbsConstants.IS_FLAGGED_FALSE.getKey())) {
       hkPaymentResponse.setHKPaymentStatus(EnumHKPaymentStatus.SUCCESS);
     } else if (isFlagged != null
         && isFlagged.equalsIgnoreCase(
             GatewayResponseKeys.EbsConstants.IS_FLAGGED_TRUE.getKey())) {
       hkPaymentResponse.setHKPaymentStatus(EnumHKPaymentStatus.AUTHENTICATION_PENDING);
     } else {
       hkPaymentResponse.setHKPaymentStatus(EnumHKPaymentStatus.FAILURE);
     }
   } else {
     hkPaymentResponse.setHKPaymentStatus(EnumHKPaymentStatus.FAILURE);
     hkPaymentResponse.setResponseMsg(
         GatewayResponseKeys.HKConstants.NO_TRANSACTION_FOUND.getKey());
   }
 }