Subversion Repositories SmartDukaan

Rev

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

Rev 1905 Rev 1999
Line 14... Line 14...
14
import in.shop2020.payments.Payment;
14
import in.shop2020.payments.Payment;
15
import in.shop2020.payments.PaymentException;
15
import in.shop2020.payments.PaymentException;
16
import in.shop2020.payments.PaymentStatus;
16
import in.shop2020.payments.PaymentStatus;
17
import in.shop2020.serving.services.CommonPaymentService;
17
import in.shop2020.serving.services.CommonPaymentService;
18
import in.shop2020.serving.services.EbsPaymentService;
18
import in.shop2020.serving.services.EbsPaymentService;
-
 
19
import in.shop2020.serving.utils.DataLogger;
-
 
20
import in.shop2020.serving.utils.DataLogger.Event;
19
import in.shop2020.serving.utils.ebs.Base64;
21
import in.shop2020.serving.utils.ebs.Base64;
20
import in.shop2020.serving.utils.ebs.RC4;
22
import in.shop2020.serving.utils.ebs.RC4;
21
import in.shop2020.thrift.clients.PaymentServiceClient;
23
import in.shop2020.thrift.clients.PaymentServiceClient;
22
import in.shop2020.thrift.clients.TransactionServiceClient;
24
import in.shop2020.thrift.clients.TransactionServiceClient;
23
import in.shop2020.thrift.clients.UserContextServiceClient;
25
import in.shop2020.thrift.clients.UserContextServiceClient;
24
import in.shop2020.thrift.clients.config.ConfigClient;
26
import in.shop2020.thrift.clients.config.ConfigClient;
25
 
27
 
26
import javax.servlet.http.HttpServletRequest;
28
import javax.servlet.http.HttpServletRequest;
27
 
29
 
-
 
30
import org.apache.commons.lang.StringUtils;
28
import org.apache.log4j.Logger;
31
import org.apache.log4j.Logger;
29
import org.apache.struts2.interceptor.ServletRequestAware;
32
import org.apache.struts2.interceptor.ServletRequestAware;
30
import org.apache.thrift.TException;
33
import org.apache.thrift.TException;
31
 
34
 
32
public class EbsPayResponseController implements ServletRequestAware{
35
public class EbsPayResponseController implements ServletRequestAware{
33
	
36
	
34
	private HttpServletRequest request;
37
	private HttpServletRequest request;
35
	
38
	
36
	private static Logger log = Logger.getLogger(Class.class);
39
	private static Logger log = Logger.getLogger(Class.class);
-
 
40
	private static Logger dataLog = DataLogger.getLogger();
37
	
41
	
38
	private static final String FLAG_KEY = "IsFlagged";
42
	private static final String FLAG_KEY = "IsFlagged";
39
	private static final String TXN_KEY = "TransactionID";
43
	private static final String TXN_KEY = "TransactionID";
40
	private static final String AUTH_TXN_ID = "AuthTxnId";
44
	private static final String AUTH_TXN_ID = "AuthTxnId";
41
	private static final String CAPTURE_TXN_ID = "CaptureTxnId";
45
	private static final String CAPTURE_TXN_ID = "CaptureTxnId";
Line 141... Line 145...
141
				} catch (PaymentException e) {
145
				} catch (PaymentException e) {
142
					log.error("Error while updating failed capture payment attempt: ", e);
146
					log.error("Error while updating failed capture payment attempt: ", e);
143
				} catch (TException e) {
147
				} catch (TException e) {
144
					log.error("Error while updating failed capture payment attempt: ", e);
148
					log.error("Error while updating failed capture payment attempt: ", e);
145
				}
149
				}
-
 
150
				dataLog.info(StringUtils.join(new String[] {
-
 
151
                        Event.PAYMENT_FAILURE.name(), Long.toString(merchantPaymentId), gatewayPaymentId,
-
 
152
                        gatewayTxnStatus, description, errorCode },
-
 
153
                        ", "));
146
				this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
154
				this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
147
			}else{
155
			}else{
148
				//Success
156
				//Success
149
				try {
157
				try {
150
					attributes.add(new Attribute(CAPTURE_TXN_ID, captureResult.get(EbsPaymentService.TXN_ID)));
158
					attributes.add(new Attribute(CAPTURE_TXN_ID, captureResult.get(EbsPaymentService.TXN_ID)));
Line 159... Line 167...
159
				}
167
				}
160
				
168
				
161
				CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
169
				CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
162
 
170
 
163
				CommonPaymentService.sendTxnEmail(txnId, transactionServiceClient);
171
				CommonPaymentService.sendTxnEmail(txnId, transactionServiceClient);
164
 
-
 
-
 
172
				dataLog.info(StringUtils.join(new String[] {
-
 
173
                        Event.PAYMENT_SUCCESS.name(), Long.toString(merchantPaymentId), gatewayPaymentId,
-
 
174
                        gatewayTxnStatus, description, captureStatus },
-
 
175
                        ", "));
165
				this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;				
176
				this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;				
166
			}
177
			}
167
		}else{
178
		}else{
168
			try {
179
			try {
169
				paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
180
				paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
Line 173... Line 184...
173
			} catch (TException e) {
184
			} catch (TException e) {
174
				e.printStackTrace();
185
				e.printStackTrace();
175
			}
186
			}
176
			
187
			
177
			CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
188
			CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
-
 
189
			dataLog.info(StringUtils.join(new String[] {
-
 
190
                    Event.PAYMENT_FAILURE.name(), Long.toString(merchantPaymentId), gatewayPaymentId,
-
 
191
                    gatewayTxnStatus, description },
-
 
192
                    ", "));
178
 
193
 
179
			this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
194
			this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
180
		}
195
		}
181
		
196
		
182
		log.info("User will be redirected to: " + this.redirectUrl);
197
		log.info("User will be redirected to: " + this.redirectUrl);