Subversion Repositories SmartDukaan

Rev

Rev 6503 | Rev 8914 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6503 Rev 8907
Line 7... Line 7...
7
import in.shop2020.model.v1.order.Transaction;
7
import in.shop2020.model.v1.order.Transaction;
8
import in.shop2020.model.v1.order.TransactionServiceException;
8
import in.shop2020.model.v1.order.TransactionServiceException;
9
import in.shop2020.model.v1.user.Address;
9
import in.shop2020.model.v1.user.Address;
10
import in.shop2020.model.v1.user.ShoppingCartException;
10
import in.shop2020.model.v1.user.ShoppingCartException;
11
import in.shop2020.payment.domain.Payment;
11
import in.shop2020.payment.domain.Payment;
-
 
12
import in.shop2020.payment.service.handler.PaymentServiceHandler.HdfcPaymentReturnStatus;
12
import in.shop2020.payments.Attribute;
13
import in.shop2020.payments.Attribute;
13
import in.shop2020.payments.PaymentException;
14
import in.shop2020.payments.PaymentException;
14
import in.shop2020.payments.PaymentStatus;
15
import in.shop2020.payments.PaymentStatus;
15
import in.shop2020.thrift.clients.TransactionClient;
16
import in.shop2020.thrift.clients.TransactionClient;
16
import in.shop2020.thrift.clients.UserClient;
17
import in.shop2020.thrift.clients.UserClient;
Line 56... Line 57...
56
	
57
	
57
	private enum ActionType{
58
	private enum ActionType{
58
		PURCHASE("1"),
59
		PURCHASE("1"),
59
		REFUND("2"),
60
		REFUND("2"),
60
		AUTH ("4"),
61
		AUTH ("4"),
61
		CAPTURE("5");
62
		CAPTURE("5"),
-
 
63
		INQUIRY("8");
62
		private String value;
64
		private String value;
63
		ActionType(String value) {
65
		ActionType(String value) {
64
			this.value = value;
66
			this.value = value;
65
		}
67
		}
66
		public String value(){
68
		public String value(){
Line 233... Line 235...
233
		}
235
		}
234
		        		
236
		        		
235
		return resultMap;
237
		return resultMap;
236
	}
238
	}
237
 
239
 
-
 
240
	public static boolean validateHdfcPayment(Payment payment, double amount){
-
 
241
		String ramount = "" + amount;
-
 
242
		//String gatewayPaymentId = payment.getGatewayPaymentId();
-
 
243
		
-
 
244
		e24TranPipe pipe = new e24TranPipe();
-
 
245
		pipe.setResourcePath(resourceDirPath);
-
 
246
		pipe.setAlias(aliasName);
-
 
247
		pipe.setAction(ActionType.INQUIRY.value());
-
 
248
		pipe.setAmt(ramount);
-
 
249
		pipe.setTrackId("" + payment.getId());
-
 
250
		pipe.setMember("SAHOLIC");
-
 
251
		pipe.setCurrencyCode(currencyCode);
-
 
252
		pipe.setTransId(payment.getGatewayTxnId());
-
 
253
		
-
 
254
		//Check if the values have been set properly
-
 
255
		log.info("Pipe Amount: " + pipe.getAmt());
-
 
256
		log.info("Pipe Action Code: " + pipe.getAction());
-
 
257
		log.info("Pipe Currency Code: " + pipe.getCurrencyCode());
-
 
258
		log.info("Pipe Track Id: " + pipe.getTrackId());
-
 
259
		log.info("Pipe Trans Id:" + pipe.getTransId());
-
 
260
		
-
 
261
		int refundStatus = e24TranPipe.FAILURE;
-
 
262
		String gatewayStatus = "";
-
 
263
		try {
-
 
264
			refundStatus = pipe.performTransaction();
-
 
265
			
-
 
266
			log.info("Inquiry Status: " + refundStatus);
-
 
267
			log.info("Gateway Txn Status: " + pipe.getResult());
-
 
268
			log.info("Debug Msg: " + pipe.getDebugMsg());
-
 
269
			log.info("Auth: " + pipe.getAuth());
-
 
270
			log.info("Ref: " + pipe.getRef());
-
 
271
			log.info("TransId:" + pipe.getTransId());
-
 
272
			log.info("Amount: " + pipe.getAmt());
-
 
273
			
-
 
274
			String result = pipe.getResult();
-
 
275
			log.info("Result: " + pipe.getResult());
-
 
276
			gatewayStatus = result.substring(0, Math.min(result.length(), 20)).trim();		//This will return the result of the transaction. (Successful or Failed)
-
 
277
			if ((""+refundStatus).trim().equals("0") && HdfcPaymentReturnStatus.SUCCESS.value().equals(gatewayStatus)) {
-
 
278
				return true;
-
 
279
			}
-
 
280
			else {
-
 
281
				return false;
-
 
282
			}
-
 
283
		} catch (NotEnoughDataException e) {
-
 
284
            log.error(Errors.CAPTURE_FAILURE.message, e);
-
 
285
		}	
-
 
286
		return false;
-
 
287
	}
-
 
288
	
238
	public static String initializeHdfcPayment(Payment payment, PaymentServiceHandler handler) throws Exception{
289
	public static String initializeHdfcPayment(Payment payment, PaymentServiceHandler handler) throws Exception{
239
		long merchantPaymentId = payment.getId();
290
		long merchantPaymentId = payment.getId();
240
		double amount = payment.getAmount();
291
		double amount = payment.getAmount();
241
		e24PaymentPipe pipe = new e24PaymentPipe();
292
		e24PaymentPipe pipe = new e24PaymentPipe();
242
		
293