| Line 8... |
Line 8... |
| 8 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
8 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 9 |
import org.apache.thrift.TException;
|
9 |
import org.apache.thrift.TException;
|
| 10 |
|
10 |
|
| 11 |
import in.shop2020.model.v1.order.Order;
|
11 |
import in.shop2020.model.v1.order.Order;
|
| 12 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
12 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| - |
|
13 |
import in.shop2020.model.v1.user.Cart;
|
| 13 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
14 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| 14 |
import in.shop2020.payments.PaymentException;
|
15 |
import in.shop2020.payments.PaymentException;
|
| 15 |
import in.shop2020.thrift.clients.PaymentServiceClient;
|
16 |
import in.shop2020.thrift.clients.PaymentServiceClient;
|
| 16 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
17 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
| 17 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
18 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
| 18 |
import in.shop2020.utils.Logger;
|
- |
|
| - |
|
19 |
|
| 19 |
|
20 |
|
| 20 |
@InterceptorRefs({
|
21 |
@InterceptorRefs({
|
| 21 |
@InterceptorRef("myDefault"),
|
22 |
@InterceptorRef("myDefault"),
|
| 22 |
@InterceptorRef("login")
|
23 |
@InterceptorRef("login")
|
| 23 |
})
|
24 |
})
|
| 24 |
|
25 |
|
| 25 |
public class PaySuccessController extends BaseController{
|
26 |
public class PaySuccessController extends BaseController{
|
| 26 |
private static final long serialVersionUID = 1L;
|
27 |
private static final long serialVersionUID = 1L;
|
| 27 |
PaymentServiceClient pclient = null;
|
- |
|
| 28 |
TransactionServiceClient tsc = null;
|
- |
|
| 29 |
UserContextServiceClient usc = null;
|
- |
|
| 30 |
|
28 |
|
| 31 |
private static Log log = LogFactory.getLog(Class.class);
|
29 |
private static Log log = LogFactory.getLog(Class.class);
|
| 32 |
long merchantPaymentId;
|
30 |
long merchantPaymentId;
|
| 33 |
List<Order> orders = null;
|
31 |
List<Order> orders = null;
|
| 34 |
String message = null;
|
32 |
String message = null;
|
| 35 |
|
33 |
|
| 36 |
public PaySuccessController(){
|
34 |
public PaySuccessController(){
|
| 37 |
super();
|
35 |
super();
|
| 38 |
try {
|
- |
|
| 39 |
pclient = new PaymentServiceClient();
|
- |
|
| 40 |
tsc = new TransactionServiceClient();
|
- |
|
| 41 |
usc = new UserContextServiceClient();
|
- |
|
| 42 |
} catch (Exception e) {
|
- |
|
| 43 |
Logger.log("Could not initialize the paymentservice client", this);
|
- |
|
| 44 |
}
|
- |
|
| 45 |
}
|
36 |
}
|
| 46 |
|
37 |
|
| 47 |
public String index() {
|
38 |
public String index() {
|
| 48 |
this.message = "Payment completed successfully.";
|
39 |
this.message = "Payment completed successfully.";
|
| - |
|
40 |
PaymentServiceClient paymentServiceClient = null;
|
| - |
|
41 |
TransactionServiceClient transactionServiceClient = null;
|
| - |
|
42 |
UserContextServiceClient userServiceClient = null;
|
| - |
|
43 |
|
| - |
|
44 |
try {
|
| - |
|
45 |
paymentServiceClient = new PaymentServiceClient();
|
| - |
|
46 |
transactionServiceClient = new TransactionServiceClient();
|
| 49 |
System.out.println("Inside the index method of pay response");
|
47 |
userServiceClient = new UserContextServiceClient();
|
| - |
|
48 |
} catch (Exception e1) {
|
| - |
|
49 |
// TODO Nothing to worry
|
| - |
|
50 |
e1.printStackTrace();
|
| - |
|
51 |
}
|
| 50 |
|
52 |
|
| - |
|
53 |
|
| 51 |
merchantPaymentId = Long.parseLong(this.request.getParameter("paymentId"));
|
54 |
merchantPaymentId = Long.parseLong(this.request.getParameter("paymentId"));
|
| 52 |
|
55 |
|
| 53 |
long txnId;
|
56 |
long txnId;
|
| 54 |
try {
|
57 |
try {
|
| 55 |
txnId = pclient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
|
58 |
txnId = paymentServiceClient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
|
| 56 |
|
- |
|
| 57 |
orders = tsc.getClient().getOrdersForTransaction(txnId);
|
59 |
orders = transactionServiceClient.getClient().getOrdersForTransaction(txnId);
|
| - |
|
60 |
Cart cart = userServiceClient.getClient().getCart(userinfo.getCartId());
|
| - |
|
61 |
int totalItems = 0;
|
| - |
|
62 |
if(cart != null){
|
| - |
|
63 |
totalItems = cart.getLinesSize();
|
| 58 |
|
64 |
}
|
| 59 |
int totalItems = usc.getClient().getCart(userinfo.getCartId()).getLinesSize();
|
- |
|
| 60 |
userinfo.setTotalItems(totalItems);
|
65 |
userinfo.setTotalItems(totalItems);
|
| 61 |
} catch (PaymentException e) {
|
66 |
} catch (PaymentException e) {
|
| 62 |
log.error("Payment service not responding. Payment id is" + merchantPaymentId);
|
67 |
log.error("Payment service not responding. Payment id is" + merchantPaymentId);
|
| 63 |
e.printStackTrace();
|
68 |
e.printStackTrace();
|
| 64 |
} catch (TException e) {
|
69 |
} catch (TException e) {
|