Subversion Repositories SmartDukaan

Rev

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

Rev 2134 Rev 2157
Line 26... Line 26...
26
import in.shop2020.thrift.clients.UserContextServiceClient;
26
import in.shop2020.thrift.clients.UserContextServiceClient;
27
import in.shop2020.thrift.clients.config.ConfigClient;
27
import in.shop2020.thrift.clients.config.ConfigClient;
28
 
28
 
29
import javax.servlet.http.HttpServletRequest;
29
import javax.servlet.http.HttpServletRequest;
30
 
30
 
31
import org.apache.commons.lang.StringUtils;
-
 
32
import org.apache.log4j.Logger;
31
import org.apache.log4j.Logger;
33
import org.apache.thrift.TException;
32
import org.apache.thrift.TException;
34
 
33
 
35
@SuppressWarnings("serial")
34
@SuppressWarnings("serial")
36
public class EbsPayResponseController extends BaseController{
35
public class EbsPayResponseController extends BaseController{
37
	
36
	
38
	private static Logger log = Logger.getLogger(Class.class);
37
	private static Logger log = Logger.getLogger(Class.class);
39
	private static Logger dataLog = DataLogger.getLogger();
-
 
40
	
38
	
41
	private static final String FLAG_KEY = "IsFlagged";
39
	private static final String FLAG_KEY = "IsFlagged";
42
	private static final String TXN_KEY = "TransactionID";
40
	private static final String TXN_KEY = "TransactionID";
43
	private static final String AUTH_TXN_ID = "AuthTxnId";
41
	private static final String AUTH_TXN_ID = "AuthTxnId";
44
	private static final String CAPTURE_TXN_ID = "CaptureTxnId";
42
	private static final String CAPTURE_TXN_ID = "CaptureTxnId";
Line 152... Line 150...
152
				} catch (PaymentException e) {
150
				} catch (PaymentException e) {
153
					log.error("Error while updating failed capture payment attempt: ", e);
151
					log.error("Error while updating failed capture payment attempt: ", e);
154
				} catch (TException e) {
152
				} catch (TException e) {
155
					log.error("Error while updating failed capture payment attempt: ", e);
153
					log.error("Error while updating failed capture payment attempt: ", e);
156
				}
154
				}
157
				dataLog.info(StringUtils.join(new String[] {
-
 
158
                        Event.PAYMENT_FAILURE.name(), Long.toString(merchantPaymentId), gatewayPaymentId,
155
				DataLogger.logData(Event.PAYMENT_FAILURE.name(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
159
                        gatewayTxnStatus, description, errorCode },
156
                        gatewayTxnStatus, description, errorCode);
160
                        ", "));
-
 
161
				this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
157
				this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
162
			}else{
158
			}else{
163
				//Success
159
				//Success
164
				try {
160
				try {
165
					attributes.add(new Attribute(CAPTURE_TXN_ID, captureResult.get(EbsPaymentService.TXN_ID)));
161
					attributes.add(new Attribute(CAPTURE_TXN_ID, captureResult.get(EbsPaymentService.TXN_ID)));
Line 174... Line 170...
174
				}
170
				}
175
				
171
				
176
				CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
172
				CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
177
 
173
 
178
				CommonPaymentService.sendTxnEmail(txnId, transactionServiceClient);
174
				CommonPaymentService.sendTxnEmail(txnId, transactionServiceClient);
179
				dataLog.info(StringUtils.join(new String[] {
-
 
180
                        Event.PAYMENT_SUCCESS.name(), Long.toString(merchantPaymentId), gatewayPaymentId,
175
				DataLogger.logData(Event.PAYMENT_SUCCESS.name(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
181
                        gatewayTxnStatus, description, captureStatus },
176
                        gatewayTxnStatus, description, captureStatus);
182
                        ", "));
-
 
183
				this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;				
177
				this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;				
184
			}
178
			}
185
		}else{
179
		}else{
186
			try {
180
			try {
187
				paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
181
				paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, gatewayPaymentId,
Line 191... Line 185...
191
			} catch (TException e) {
185
			} catch (TException e) {
192
				e.printStackTrace();
186
				e.printStackTrace();
193
			}
187
			}
194
			
188
			
195
			CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
189
			CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
196
			dataLog.info(StringUtils.join(new String[] {
-
 
197
                    Event.PAYMENT_FAILURE.name(), Long.toString(merchantPaymentId), gatewayPaymentId,
190
			DataLogger.logData(Event.PAYMENT_FAILURE.name(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
198
                    gatewayTxnStatus, description },
191
                    gatewayTxnStatus, description);
199
                    ", "));
-
 
200
 
192
 
201
			this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
193
			this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
202
		}
194
		}
203
		
195
		
204
		log.info("User will be redirected to: " + this.redirectUrl);
196
		log.info("User will be redirected to: " + this.redirectUrl);