| 428 |
ashish |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
| 2263 |
vikas |
3 |
import in.shop2020.datalogger.EventType;
|
|
|
4 |
import in.shop2020.model.v1.order.Order;
|
|
|
5 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
|
|
6 |
import in.shop2020.payments.PaymentException;
|
| 3209 |
vikas |
7 |
import in.shop2020.serving.utils.Utils;
|
| 3126 |
rajveer |
8 |
import in.shop2020.thrift.clients.PaymentClient;
|
|
|
9 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
10 |
import in.shop2020.thrift.clients.UserClient;
|
| 2511 |
vikas |
11 |
import in.shop2020.utils.DataLogger;
|
| 2263 |
vikas |
12 |
|
| 719 |
rajveer |
13 |
import java.io.IOException;
|
|
|
14 |
import java.util.List;
|
|
|
15 |
|
| 2087 |
vikas |
16 |
import org.apache.log4j.Logger;
|
| 822 |
vikas |
17 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
|
|
18 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 719 |
rajveer |
19 |
import org.apache.thrift.TException;
|
|
|
20 |
|
| 822 |
vikas |
21 |
@InterceptorRefs({
|
|
|
22 |
@InterceptorRef("myDefault"),
|
|
|
23 |
@InterceptorRef("login")
|
| 719 |
rajveer |
24 |
})
|
| 428 |
ashish |
25 |
|
| 517 |
rajveer |
26 |
public class PayErrorController extends BaseController{
|
| 719 |
rajveer |
27 |
private static final long serialVersionUID = 1L;
|
| 2087 |
vikas |
28 |
private static Logger log = Logger.getLogger(Class.class);
|
| 3126 |
rajveer |
29 |
PaymentClient pclient = null;
|
|
|
30 |
TransactionClient tsc = null;
|
|
|
31 |
UserClient usc = null;
|
| 428 |
ashish |
32 |
|
| 719 |
rajveer |
33 |
long merchantPaymentId;
|
|
|
34 |
List<Order> orders = null;
|
|
|
35 |
String message = null;
|
| 428 |
ashish |
36 |
|
| 517 |
rajveer |
37 |
public PayErrorController(){
|
| 719 |
rajveer |
38 |
super();
|
| 428 |
ashish |
39 |
try {
|
| 3126 |
rajveer |
40 |
pclient = new PaymentClient();
|
|
|
41 |
tsc = new TransactionClient();
|
|
|
42 |
usc = new UserClient();
|
| 428 |
ashish |
43 |
} catch (Exception e) {
|
| 2087 |
vikas |
44 |
log.error("Could not initialize the paymentservice client");
|
| 428 |
ashish |
45 |
}
|
|
|
46 |
}
|
|
|
47 |
|
| 719 |
rajveer |
48 |
public String index() throws IOException, SecurityException, PaymentException, TException, TransactionServiceException{
|
|
|
49 |
this.message = "Payment failed at the payment gateway. Please pay again.";
|
| 2692 |
rajveer |
50 |
String merchantPaymentIdString = this.request.getParameter("paymentId");
|
|
|
51 |
if(merchantPaymentIdString!=null){
|
|
|
52 |
merchantPaymentId = Long.parseLong(merchantPaymentIdString);
|
| 3209 |
vikas |
53 |
long txnId = pclient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
|
|
|
54 |
orders = tsc.getClient().getOrdersForTransaction(txnId, userinfo.getUserId());
|
| 2692 |
rajveer |
55 |
}
|
| 12616 |
anikendra |
56 |
// DataLogger.logData(EventType.PAYMENT_FAILURE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
|
|
|
57 |
// Long.toString(merchantPaymentId), Utils.getItemIdStringFromOrders(orders));
|
| 719 |
rajveer |
58 |
return "index";
|
| 428 |
ashish |
59 |
}
|
|
|
60 |
|
| 719 |
rajveer |
61 |
|
|
|
62 |
public String getMessage(){
|
|
|
63 |
return this.message;
|
| 428 |
ashish |
64 |
}
|
| 719 |
rajveer |
65 |
|
| 428 |
ashish |
66 |
}
|