gt: 	  	   String currentDate = inputformat.format(new Date());
context: /**
   * 
   */
  package com.abm.mainet.common.integration.payment.core;
  
  import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  import java.util.Arrays;
  import java.util.Date;
  import java.util.List;
  import java.util.Map;
  import java.util.UUID;
  
  import org.apache.log4j.Logger;
  
  import com.abm.mainet.common.integration.payment.constants.PaymentConstant;
  import com.abm.mainet.common.integration.payment.dto.PaymentRequestDTO;
  import com.abm.mainet.common.integration.payment.exeception.PaymentException;
  import com.tp.pg.util.TransactionRequestBean;
  import com.tp.pg.util.TransactionResponseBean;
  
  
  /**
   * @author umashanker.kanaujiya
   *
   */
  public class HDFCPayment implements PaymentStrategy {
  
  	
  	   protected Logger LOG  = Logger.getLogger(HDFCPayment.class);	
  	   
  		@Override
  		public PaymentRequestDTO generatePaymentRequest(PaymentRequestDTO paymentRequestVO) throws PaymentException {
  			
  			LOG.info("Start the genreatePaymentRequest() in HDFCPayment calss ");
  			try
  			{
  			  			
  		   if(paymentRequestVO.getMerchantId() != null && paymentRequestVO.getKey() != null  &&  paymentRequestVO.getSalt() != null  && paymentRequestVO.getSchemeCode() != null && paymentRequestVO.getPgUrl() != null)
  			   {
  				   UUID customerId = UUID.randomUUID();		    	
  			       String ShoppingCartDetails = null;
  				   TransactionRequestBean transactionRequestBean = new TransactionRequestBean();
  				   transactionRequestBean.setStrRequestType(paymentRequestVO.getRequestType());
  				   transactionRequestBean.setStrMerchantCode(paymentRequestVO.getMerchantId());
  				   transactionRequestBean.setMerchantTxnRefNumber(PaymentConstant.PG_REQUEST_PROPERTY.TXN+paymentRequestVO.getTxnid().toString());
  				
  				   if(paymentRequestVO.getProduction() !=null && paymentRequestVO.getProduction().equalsIgnoreCase("N"))
  				   {
  					   transactionRequestBean.setStrAmount("1.0");
  					   transactionRequestBean.setStrBankCode("470");
  					   ShoppingCartDetails =   paymentRequestVO.getSchemeCode().concat("_").concat("1.0").concat("_0.0");
  				   }		   
  				   else
  				   {
  					   transactionRequestBean.setStrAmount(paymentRequestVO.getDueAmt().toString());
  					   ShoppingCartDetails =   paymentRequestVO.getSchemeCode().concat("_").concat(paymentRequestVO.getDueAmt().toString()).concat("_0.0");
  					   transactionRequestBean.setStrBankCode("");
  				   }
  				   transactionRequestBean.setStrCurrencyCode(PaymentConstant.PG_REQUEST_PROPERTY.CRN);
  				   transactionRequestBean.setStrITC(paymentRequestVO.getTxnid()+"~"+paymentRequestVO.getServiceId()+"~"+paymentRequestVO.getApplicationId()+"~"+paymentRequestVO.getUdf3()+"~"+paymentRequestVO.getUdf5()+"~"+paymentRequestVO.getUdf6()+"~"+paymentRequestVO.getUdf7());
  				   transactionRequestBean.setStrReturnURL(paymentRequestVO.getSuccessUrl());
  				   transactionRequestBean.setStrShoppingCartDetails(ShoppingCartDetails);
  				   transactionRequestBean.setTxnDate(getCurrentDate());		  
  				   transactionRequestBean.setWebServiceLocator(paymentRequestVO.getPgUrl());
  				   transactionRequestBean.setCustID(customerId.toString());
  				   transactionRequestBean.setStrTPSLTxnID("");
  				   transactionRequestBean.setStrMobileNumber(paymentRequestVO.getMobNo());
  				   transactionRequestBean.setKey(paymentRequestVO.getKey().getBytes());
  				   transactionRequestBean.setIv(paymentRequestVO.getSalt().getBytes());
  				   transactionRequestBean.setStrCustomerName(paymentRequestVO.getApplicantName());
  				   if(paymentRequestVO.getEmail()  !=null  && !paymentRequestVO.getEmail().isEmpty()){
  				   transactionRequestBean.setStrEmail(paymentRequestVO.getEmail());
  				   }
  				   transactionRequestBean.setStrTimeOut(PaymentConstant.PG_REQUEST_PROPERTY.SERVERTIMEOUT);
  				   String tokenNo =  transactionRequestBean.getTransactionToken(); 
  				   paymentRequestVO.setPayRequestMsg(tokenNo);
  				   LOG.info("Single Token request String"+tokenNo);
  				   LOG.info("End  the genreatePaymentRequest() in HDFCPayment calss ");
  			  }
  		    else
  			   {
  			     LOG.error("Payment Required parameter are not fetch from tables");    
  			     throw new PaymentException("Payment Required parameter are not fetch from tables");
  			   }
  			}
  			 catch (Exception exception) 
  			     {
  				      LOG.error(" Exception occur in genreatePaymentRequest in HDFCPayment",exception);  
  				      throw new PaymentException("Exception occur in genreatePaymentRequest ...",exception);
  				 }
  			return paymentRequestVO;
  		}
  		
  		@Override
  		public  Map<String, String> generatePaymentResponse(String responseString, Map<String, String> responseMap) throws PaymentException{
  			  
  			LOG.info("Starts  the genratePaymentResponse() in HDFCPayment calss ");
  			
  			 if(responseMap.get(PaymentConstant.REQUIRED_PG_PARAM.KEY) != null && responseMap.get(PaymentConstant.REQUIRED_PG_PARAM.IV) != null  &&  responseString != null )
  			 {
  			
  				    LOG.info("Response message from the techprocess Payment in HashCode  "+responseString);
  					String key = responseMap.get(PaymentConstant.REQUIRED_PG_PARAM.KEY);		
  					String iv = responseMap.get(PaymentConstant.REQUIRED_PG_PARAM.IV);	
  					TransactionResponseBean responseBean = new TransactionResponseBean();		
  					responseBean.setIv(iv.getBytes());
  					responseBean.setKey(key.getBytes());
  					responseBean.setResponsePayload(responseString);		
  					String responseMsg =  responseBean.getResponsePayload();		
  					List<String> strings = Arrays.asList(responseMsg.split("\\|"));
  				    LOG.info("Response message after convert into string "+strings+ " response String  Size"+strings.size());
  					if(strings.size() > 0)
  					{
  							
  						if(strings.get(0).substring(11).equals(PaymentConstant.PG_REQUEST_PROPERTY.PAYMNETSTATUS))
  						{
  							responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.STATUS, PaymentConstant.PAYU_STATUS.SUCCESS);
  							
  						}
  						else
  						{
  							 responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.FIELD9, PaymentConstant.PAYU_STATUS.FAIL);
  							 
  						}
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.SUCEESS_MSG,strings.get(1).substring(8));
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.ERR_STR,strings.get(2).substring(12));
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.BNK_REF_NO,strings.get(3).substring(13));
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.BANKID,strings.get(4).substring(13));
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.TRANS_ID, strings.get(5).substring(12));
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.AMT, strings.get(6).substring(8));
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.DUE_AMT, strings.get(6).substring(8));
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.NET_AMT, strings.get(6).substring(8));
  					
  						if( !strings.get(7).substring(15).isEmpty() && !strings.get(7).substring(15).equalsIgnoreCase("NA")){
  							
  							String param[] = strings.get(7).substring(15).split("[{}]"+"[{}]");
  
  							if(param.length == 4)
  							{
  								
  								String itc  =  param[0].substring(5);
  								String email = param[1].substring(6);							
  								String mob   = param[2].substring(4);
  								String name  = param[3].substring(9).replace("}", "");
  								responseMap.put(PaymentConstant.BankParam.EMAIL,email);
  								responseMap.put(PaymentConstant.BankParam.FNAME,name);
  								responseMap.put(PaymentConstant.BankParam.PHONE,mob);
  								String strArray[] = itc.split("\\~");
  								responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.TRACK_ID, strArray[0]);
  								responseMap.put(PaymentConstant.BankParam.UDF1,strArray[1]);
  								responseMap.put(PaymentConstant.BankParam.UDF2,strArray[2]);				
  								responseMap.put(PaymentConstant.BankParam.UDF3,strArray[3]);
  								responseMap.put(PaymentConstant.BankParam.UDF5,strArray[4]);
  								responseMap.put(PaymentConstant.BankParam.UDF6,strArray[5]);
  								responseMap.put(PaymentConstant.BankParam.UDF7,strArray[6]);
  							}
  							else
  							{
  								String itc  =  param[0].substring(5);							
  								String mob   = param[1].substring(4);
  								String name  = param[2].substring(9).replace("}", "");				
  								responseMap.put(PaymentConstant.BankParam.FNAME,name);
  								responseMap.put(PaymentConstant.BankParam.PHONE,mob);
  								String strArray[] = itc.split("\\~");
  								responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.TRACK_ID, strArray[0]);
  								responseMap.put(PaymentConstant.BankParam.UDF1,strArray[1]);
  								responseMap.put(PaymentConstant.BankParam.UDF2,strArray[2]);				
  								responseMap.put(PaymentConstant.BankParam.UDF3,strArray[3]);
  								responseMap.put(PaymentConstant.BankParam.UDF5,strArray[4]);
  								responseMap.put(PaymentConstant.BankParam.UDF6,strArray[5]);
  								responseMap.put(PaymentConstant.BankParam.UDF7,strArray[6]);
  							
  							
  							}
  						}
  			
  						else
  						{
  							responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.ERR_STR, "Failed from fetch the data from payment gateway");
  						}
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.PAY_SRC, PaymentConstant.PG_SHORTNAME.HDFC);
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.PAYDATE, strings.get(8).substring(14));		
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.BNK_REF_NO,strings.get(9).substring(13));
  						responseMap.put(PaymentConstant.BankParam.HASH,strings.get(12).substring(5));								
  				    }
  					else
  					{
  						LOG.error("Payment Required parameter are not fetch from tables");
  						responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.ERR_STR, "CheckSum not Match");
  						throw new PaymentException("additional  data are not fetch in response send by techprocess");
  					}
  			     }
  			 else
  				{
  				    LOG.error("Response message are not convert into string");
  					responseMap.put(PaymentConstant.REQUIRED_PG_PARAM.ERR_STR, "CheckSum not Match");
  					throw new PaymentException("Response message are not correct send by techprocess");
  				}
  			LOG.info("End  the genratePaymentResponse() in HDFCPayment calss ");
  				
  			return responseMap;
  		}
  
  		public String  getCurrentDate(){
  		
  		
  		   DateFormat inputformat = new SimpleDateFormat("dd-MM-yyyy");
  