Subversion Repositories SmartDukaan

Rev

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

Rev 2334 Rev 2419
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import java.io.BufferedReader;
-
 
4
import java.io.ByteArrayInputStream;
-
 
5
import java.io.IOException;
-
 
6
import java.io.InputStreamReader;
-
 
7
import java.util.ArrayList;
-
 
8
import java.util.List;
-
 
9
import java.util.Map;
-
 
10
import java.util.StringTokenizer;
-
 
11
import java.util.TreeMap;
-
 
12
 
-
 
13
import in.shop2020.config.ConfigException;
3
import in.shop2020.config.ConfigException;
14
import in.shop2020.datalogger.EventType;
4
import in.shop2020.datalogger.EventType;
15
import in.shop2020.payments.Attribute;
5
import in.shop2020.payments.Attribute;
16
import in.shop2020.payments.Payment;
6
import in.shop2020.payments.Payment;
17
import in.shop2020.payments.PaymentException;
7
import in.shop2020.payments.PaymentException;
Line 25... Line 15...
25
import in.shop2020.thrift.clients.PaymentServiceClient;
15
import in.shop2020.thrift.clients.PaymentServiceClient;
26
import in.shop2020.thrift.clients.TransactionServiceClient;
16
import in.shop2020.thrift.clients.TransactionServiceClient;
27
import in.shop2020.thrift.clients.UserContextServiceClient;
17
import in.shop2020.thrift.clients.UserContextServiceClient;
28
import in.shop2020.thrift.clients.config.ConfigClient;
18
import in.shop2020.thrift.clients.config.ConfigClient;
29
 
19
 
-
 
20
import java.io.BufferedReader;
-
 
21
import java.io.ByteArrayInputStream;
-
 
22
import java.io.IOException;
-
 
23
import java.io.InputStreamReader;
-
 
24
import java.util.ArrayList;
-
 
25
import java.util.List;
-
 
26
import java.util.Map;
-
 
27
import java.util.StringTokenizer;
-
 
28
import java.util.TreeMap;
-
 
29
 
30
import javax.servlet.http.HttpServletRequest;
30
import javax.servlet.http.HttpServletRequest;
31
 
31
 
32
import org.apache.log4j.Logger;
32
import org.apache.log4j.Logger;
33
import org.apache.thrift.TException;
33
import org.apache.thrift.TException;
34
 
34
 
Line 145... Line 145...
145
				} catch (PaymentException e) {
145
				} catch (PaymentException e) {
146
					log.error("Error while updating failed capture payment attempt: ", e);
146
					log.error("Error while updating failed capture payment attempt: ", e);
147
				} catch (TException e) {
147
				} catch (TException e) {
148
					log.error("Error while updating failed capture payment attempt: ", e);
148
					log.error("Error while updating failed capture payment attempt: ", e);
149
				}
149
				}
150
				DataLogger.logData(EventType.PAYMENT_FAILURE.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
150
				DataLogger.logData(EventType.PAYMENT_FAILURE, session.getId(), userinfo.getUserId(), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
151
                        gatewayTxnStatus, description, errorCode);
151
                        gatewayTxnStatus, description, errorCode);
152
				this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
152
				this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
153
			}else{
153
			}else{
154
				//Success
154
				//Success
155
				try {
155
				try {
Line 164... Line 164...
164
					log.error("Error while updating successful capture payment attempt: ", e);
164
					log.error("Error while updating successful capture payment attempt: ", e);
165
				}
165
				}
166
				
166
				
167
				CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
167
				CommonPaymentService.processSuccessfulTxn(txnId, userServiceClient, transactionServiceClient);
168
 
168
 
169
				DataLogger.logData(EventType.PAYMENT_SUCCESS.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
169
				DataLogger.logData(EventType.PAYMENT_SUCCESS, session.getId(), userinfo.getUserId(), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
170
                        gatewayTxnStatus, description, captureStatus);
170
                        gatewayTxnStatus, description, captureStatus);
171
				this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;				
171
				this.redirectUrl = successUrl + "?paymentId=" + merchantPaymentId;				
172
			}
172
			}
173
		}else{
173
		}else{
174
			try {
174
			try {
Line 179... Line 179...
179
			} catch (TException e) {
179
			} catch (TException e) {
180
				e.printStackTrace();
180
				e.printStackTrace();
181
			}
181
			}
182
			
182
			
183
			CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
183
			CommonPaymentService.processFailedTxn(txnId, transactionServiceClient);
184
			DataLogger.logData(EventType.PAYMENT_FAILURE.name(), session.getId(), Long.toString(userinfo.getUserId()), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
184
			DataLogger.logData(EventType.PAYMENT_FAILURE, session.getId(), userinfo.getUserId(), userinfo.getEmail(), Long.toString(merchantPaymentId), gatewayPaymentId,
185
                    gatewayTxnStatus, description);
185
                    gatewayTxnStatus, description);
186
 
186
 
187
			this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
187
			this.redirectUrl = errorUrl + "?paymentId=" + merchantPaymentId;
188
		}
188
		}
189
		
189