Subversion Repositories SmartDukaan

Rev

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

Rev 3616 Rev 4421
Line 25... Line 25...
25
import com.aciworldwide.commerce.gateway.plugins.NotEnoughDataException;
25
import com.aciworldwide.commerce.gateway.plugins.NotEnoughDataException;
26
import com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe;
26
import com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe;
27
import com.aciworldwide.commerce.gateway.plugins.e24TranPipe;
27
import com.aciworldwide.commerce.gateway.plugins.e24TranPipe;
28
 
28
 
29
public class HdfcPaymentHandler implements IPaymentHandler {
29
public class HdfcPaymentHandler implements IPaymentHandler {
30
	private static Logger log = Logger.getLogger(HdfcPaymentHandler.class);
30
	private static final int CAPTURE_STATUS_FOR_CONNECTION_ISSUE = -1;
31
	
31
 
32
	private static final long gatewayId=1;
32
    private static Logger log = Logger.getLogger(HdfcPaymentHandler.class);
33
	
33
	
34
	private static String resourceFilePath;
34
	private static String resourceFilePath;
35
	private static String aliasName;
35
	private static String aliasName;
36
	private static String responseURL;
36
	private static String responseURL;
37
	private static String errorURL;
37
	private static String errorURL;
Line 73... Line 73...
73
		String gatewayPaymentId = payment.getGatewayPaymentId();
73
		String gatewayPaymentId = payment.getGatewayPaymentId();
74
		log.info("Capturing amount: Rs " + amount + " for payment Id: " + gatewayPaymentId);
74
		log.info("Capturing amount: Rs " + amount + " for payment Id: " + gatewayPaymentId);
75
		
75
		
76
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
76
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
77
		Map<String, String> resultMap = new HashMap<String, String>();
77
		Map<String, String> resultMap = new HashMap<String, String>();
78
	    resultMap.put(STATUS, "-2");
78
	    resultMap.put(STATUS, Errors.CAPTURE_FAILURE.code);
-
 
79
        resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
-
 
80
        resultMap.put(ERROR, Errors.CAPTURE_FAILURE.message);
79
	    
81
	    
80
		e24TranPipe pipe = new e24TranPipe();
82
		e24TranPipe pipe = new e24TranPipe();
81
		pipe.setResourcePath(resourceFilePath);
83
		pipe.setResourcePath(resourceFilePath);
82
		pipe.setAlias(aliasName);
84
		pipe.setAlias(aliasName);
83
		pipe.setAction(ActionType.CAPTURE.value());
85
		pipe.setAction(ActionType.CAPTURE.value());
Line 109... Line 111...
109
			resultMap.put(STATUS, "" + captureStatus);
111
			resultMap.put(STATUS, "" + captureStatus);
110
			String result = pipe.getResult();
112
			String result = pipe.getResult();
111
			resultMap.put(GATEWAY_STATUS, result.substring(0, Math.min(result.length(), 20)).trim());		//This will return the result of the transaction. (Successful or Failed)
113
			resultMap.put(GATEWAY_STATUS, result.substring(0, Math.min(result.length(), 20)).trim());		//This will return the result of the transaction. (Successful or Failed)
112
			if(captureStatus != e24TranPipe.SUCCESS || !"CAPTURED".equals(result)){
114
			if(captureStatus != e24TranPipe.SUCCESS || !"CAPTURED".equals(result)){
113
				resultMap.put(ERROR, pipe.getErrorMsg());				// In case of any error, we only need to get the error message
115
				resultMap.put(ERROR, pipe.getErrorMsg());				// In case of any error, we only need to get the error message
-
 
116
 
-
 
117
				if (captureStatus == CAPTURE_STATUS_FOR_CONNECTION_ISSUE) {
-
 
118
	                resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);
-
 
119
	            }
-
 
120
			}
114
			}else{
121
			else {
115
				resultMap.put(CAPTURE_AUTH_ID, pipe.getAuth());			// Unique ID generated by Authorizer of the transaction
122
				resultMap.put(CAPTURE_AUTH_ID, pipe.getAuth());			// Unique ID generated by Authorizer of the transaction
116
				resultMap.put(CAPTURE_REF_ID, pipe.getRef());			// Unique reference number generated during the transaction
123
				resultMap.put(CAPTURE_REF_ID, pipe.getRef());			// Unique reference number generated during the transaction
117
				resultMap.put(CAPTURE_TXN_ID, pipe.getTransId());		// Unique Transaction ID generated after every successful transaction
124
				resultMap.put(CAPTURE_TXN_ID, pipe.getTransId());		// Unique Transaction ID generated after every successful transaction
118
				resultMap.put(CAPTURE_AMNT, pipe.getAmt());			// Original Amount of the transaction
125
				resultMap.put(CAPTURE_AMNT, pipe.getAmt());			// Original Amount of the transaction
119
			}
126
			}
120
		} catch (NotEnoughDataException e) {
127
		} catch (NotEnoughDataException e) {
121
			log.error("Unable to capture payment", e);
128
            log.error(Errors.CAPTURE_FAILURE.message, e);
122
			resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);
129
            resultMap.put(ERR_CODE, Errors.CAPTURE_FAILURE.code);
123
			resultMap.put(ERROR, "Unable to capture transaction.");
130
            resultMap.put(ERROR, e.getMessage());
124
		}
131
		}
125
		        		
132
		        		
126
		return resultMap;
133
		return resultMap;
127
	}
134
	}
128
	
135