Subversion Repositories SmartDukaan

Rev

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

Rev 2692 Rev 2707
Line 16... Line 16...
16
import in.shop2020.model.v1.order.TransactionServiceException;
16
import in.shop2020.model.v1.order.TransactionServiceException;
17
import in.shop2020.model.v1.user.ShoppingCartException;
17
import in.shop2020.model.v1.user.ShoppingCartException;
18
import in.shop2020.payments.Attribute;
18
import in.shop2020.payments.Attribute;
19
import in.shop2020.payments.Payment;
19
import in.shop2020.payments.Payment;
20
import in.shop2020.payments.PaymentStatus;
20
import in.shop2020.payments.PaymentStatus;
-
 
21
import in.shop2020.payments.PaymentService.Client;
21
import in.shop2020.thrift.clients.PaymentServiceClient;
22
import in.shop2020.thrift.clients.PaymentServiceClient;
22
import in.shop2020.thrift.clients.TransactionServiceClient;
23
import in.shop2020.thrift.clients.TransactionServiceClient;
23
import in.shop2020.thrift.clients.config.ConfigClient;
24
import in.shop2020.thrift.clients.config.ConfigClient;
24
 
25
 
25
import com.aciworldwide.commerce.gateway.plugins.NotEnoughDataException;
26
import com.aciworldwide.commerce.gateway.plugins.NotEnoughDataException;
Line 155... Line 156...
155
		
156
		
156
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
157
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
157
		Map<String, String> resultMap = new HashMap<String, String>();
158
		Map<String, String> resultMap = new HashMap<String, String>();
158
	    resultMap.put(STATUS, "-2");
159
	    resultMap.put(STATUS, "-2");
159
	    
160
	    
160
		e24TranPipe pipe = new e24TranPipe();
-
 
161
		pipe.setResourcePath(resourceFilePath);
-
 
162
		pipe.setAlias(aliasName);
-
 
163
		pipe.setAction(ActionType.CAPTURE.value());
-
 
164
		pipe.setAmt(amount);
-
 
165
		pipe.setTrackId("" + payment.getPaymentId());
-
 
166
		pipe.setMember("SAHOLIC");
-
 
167
		pipe.setCurrencyCode(currencyCode);
-
 
168
		pipe.setTransId(gatewayTxnId);
-
 
169
		
-
 
170
		//Check if the values have been set properly
-
 
171
		log.info("Pipe Amount: " + pipe.getAmt());
-
 
172
		log.info("Pipe Action Code: " + pipe.getAction());
-
 
173
		log.info("Pipe Currency Code: " + pipe.getCurrencyCode());
-
 
174
		log.info("Pipe Track Id: " + pipe.getTrackId());
-
 
175
		log.info("Pipe Trans Id:" + pipe.getTransId());
-
 
176
		
-
 
177
		int captureStatus = e24TranPipe.FAILURE;
-
 
178
		try {
161
		try {
179
			captureStatus = pipe.performTransaction();
-
 
180
			
-
 
181
			log.info("Capture Status: " + captureStatus);
-
 
182
			log.info("Gateway Txn Status: " + pipe.getResult());
162
			PaymentServiceClient paymentServiceClient = new PaymentServiceClient();
183
			log.info("Debug Msg: " + pipe.getDebugMsg());
-
 
184
			log.info("Auth: " + pipe.getAuth());
-
 
185
			log.info("Ref: " + pipe.getRef());
-
 
186
			log.info("TransId:" + pipe.getTransId());
-
 
187
			log.info("Amount: " + pipe.getAmt());
-
 
188
			
-
 
189
			resultMap.put(STATUS, "" + captureStatus);
-
 
190
			String result = pipe.getResult();
163
			Client paymentClient = paymentServiceClient.getClient();
191
			resultMap.put(GATEWAY_STATUS, result.substring(0, Math.min(result.length(), 20)).trim());		//This will return the result of the transaction. (Successful or Failed)
-
 
192
			if(captureStatus != e24TranPipe.SUCCESS || !"CAPTURED".equals(result)){
-
 
193
				resultMap.put(ERROR, pipe.getErrorMsg());				// In case of any error, we only need to get the error message
-
 
194
			}else{
-
 
195
				resultMap.put(CAPTURE_AUTH_ID, pipe.getAuth());			// Unique ID generated by Authorizer of the transaction
-
 
196
				resultMap.put(CAPTURE_REF_ID, pipe.getRef());			// Unique reference number generated during the transaction
-
 
197
				resultMap.put(CAPTURE_TXN_ID, pipe.getTransId());		// Unique Transaction ID generated after every successful transaction
-
 
198
				resultMap.put(CAPTURE_AMNT, pipe.getAmt());			// Original Amount of the transaction
164
			resultMap = paymentClient.captureHdfcPayment(payment.getPaymentId());
199
			}
-
 
200
		} catch (NotEnoughDataException e) {
165
		} catch (Exception e) {
201
			log.error("Unable to capture payment", e);
166
			log.error("Unable to capture payment", e);
202
			resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);
167
			resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);
203
			resultMap.put(ERROR, "Unable to capture transaction.");
168
			resultMap.put(ERROR, "Unable to capture transaction.");
204
		}
169
		}
205
		        		
170
		
206
		return resultMap;
171
		return resultMap;
-
 
172
//		
-
 
173
//		
-
 
174
//		
-
 
175
//
-
 
176
//	    
-
 
177
//		e24TranPipe pipe = new e24TranPipe();
-
 
178
//		pipe.setResourcePath(resourceFilePath);
-
 
179
//		pipe.setAlias(aliasName);
-
 
180
//		pipe.setAction(ActionType.CAPTURE.value());
-
 
181
//		pipe.setAmt(amount);
-
 
182
//		pipe.setTrackId("" + payment.getPaymentId());
-
 
183
//		pipe.setMember("SAHOLIC");
-
 
184
//		pipe.setCurrencyCode(currencyCode);
-
 
185
//		pipe.setTransId(gatewayTxnId);
-
 
186
//		
-
 
187
//		//Check if the values have been set properly
-
 
188
//		log.info("Pipe Amount: " + pipe.getAmt());
-
 
189
//		log.info("Pipe Action Code: " + pipe.getAction());
-
 
190
//		log.info("Pipe Currency Code: " + pipe.getCurrencyCode());
-
 
191
//		log.info("Pipe Track Id: " + pipe.getTrackId());
-
 
192
//		log.info("Pipe Trans Id:" + pipe.getTransId());
-
 
193
//		
-
 
194
//		int captureStatus = e24TranPipe.FAILURE;
-
 
195
//		try {
-
 
196
//			captureStatus = pipe.performTransaction();
-
 
197
//			
-
 
198
//			log.info("Capture Status: " + captureStatus);
-
 
199
//			log.info("Gateway Txn Status: " + pipe.getResult());
-
 
200
//			log.info("Debug Msg: " + pipe.getDebugMsg());
-
 
201
//			log.info("Auth: " + pipe.getAuth());
-
 
202
//			log.info("Ref: " + pipe.getRef());
-
 
203
//			log.info("TransId:" + pipe.getTransId());
-
 
204
//			log.info("Amount: " + pipe.getAmt());
-
 
205
//			
-
 
206
//			resultMap.put(STATUS, "" + captureStatus);
-
 
207
//			String result = pipe.getResult();
-
 
208
//			resultMap.put(GATEWAY_STATUS, result.substring(0, Math.min(result.length(), 20)).trim());		//This will return the result of the transaction. (Successful or Failed)
-
 
209
//			if(captureStatus != e24TranPipe.SUCCESS || !"CAPTURED".equals(result)){
-
 
210
//				resultMap.put(ERROR, pipe.getErrorMsg());				// In case of any error, we only need to get the error message
-
 
211
//			}else{
-
 
212
//				resultMap.put(CAPTURE_AUTH_ID, pipe.getAuth());			// Unique ID generated by Authorizer of the transaction
-
 
213
//				resultMap.put(CAPTURE_REF_ID, pipe.getRef());			// Unique reference number generated during the transaction
-
 
214
//				resultMap.put(CAPTURE_TXN_ID, pipe.getTransId());		// Unique Transaction ID generated after every successful transaction
-
 
215
//				resultMap.put(CAPTURE_AMNT, pipe.getAmt());			// Original Amount of the transaction
-
 
216
//			}
-
 
217
//		} catch (NotEnoughDataException e) {
-
 
218
//			log.error("Unable to capture payment", e);
-
 
219
//			resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);
-
 
220
//			resultMap.put(ERROR, "Unable to capture transaction.");
-
 
221
//		}
-
 
222
//		        		
-
 
223
//		return resultMap;
207
	}
224
	}
208
	
225
	
209
	private List<Attribute> getAttributesAndSetUdfs(long txnId) throws TransactionServiceException, TException{
226
	private List<Attribute> getAttributesAndSetUdfs(long txnId) throws TransactionServiceException, TException{
210
		StringBuilder orderDetails = new StringBuilder();
227
		StringBuilder orderDetails = new StringBuilder();
211
		StringBuilder billingAddress = new StringBuilder();
228
		StringBuilder billingAddress = new StringBuilder();