Rev 822 | Blame | Last modification | View Log | RSS feed
package in.shop2020.serving.controllers;import java.io.IOException;import java.util.HashMap;import java.util.List;import java.util.Map;import org.apache.juli.logging.Log;import org.apache.juli.logging.LogFactory;import org.apache.struts2.convention.annotation.InterceptorRef;import org.apache.struts2.convention.annotation.InterceptorRefs;import org.apache.struts2.convention.annotation.Result;import org.apache.struts2.convention.annotation.Results;import org.apache.thrift.TException;import in.shop2020.model.v1.order.LineItem;import in.shop2020.model.v1.order.Order;import in.shop2020.model.v1.order.TransactionServiceException;import in.shop2020.model.v1.order.TransactionStatus;import in.shop2020.model.v1.user.ShoppingCartException;import in.shop2020.payments.PaymentException;import in.shop2020.payments.PaymentStatus;import in.shop2020.serving.utils.Utils;import in.shop2020.thrift.clients.PaymentServiceClient;import in.shop2020.thrift.clients.TransactionServiceClient;import in.shop2020.thrift.clients.UserContextServiceClient;import in.shop2020.utils.Logger;@InterceptorRefs({@InterceptorRef("myDefault"),@InterceptorRef("login")})public class PaySuccessController extends BaseController{private static final long serialVersionUID = 1L;PaymentServiceClient pclient = null;TransactionServiceClient tsc = null;UserContextServiceClient usc = null;private static Log log = LogFactory.getLog(Class.class);long merchantPaymentId;List<Order> orders = null;String message = null;public PaySuccessController(){super();try {pclient = new PaymentServiceClient();tsc = new TransactionServiceClient();usc = new UserContextServiceClient();} catch (Exception e) {Logger.log("Could not initialize the paymentservice client", this);}}public String index() {this.message = "Payment completed successfully.";System.out.println("Inside the index method of pay response");merchantPaymentId = Long.parseLong(this.request.getParameter("paymentId"));long txnId;try {txnId = pclient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();orders = tsc.getClient().getOrdersForTransaction(txnId);int totalItems = usc.getClient().getCart(userinfo.getCartId()).getLinesSize();userinfo.setTotalItems(totalItems);} catch (PaymentException e) {log.error("Payment service not responding. Payment id is" + merchantPaymentId);e.printStackTrace();} catch (TException e) {log.error("Thrift service exception. Payment id is" + merchantPaymentId);e.printStackTrace();} catch (TransactionServiceException e) {log.error("Transaction service exception. Payment id is" + merchantPaymentId);e.printStackTrace();} catch (ShoppingCartException e) {log.error("Shopping cart service exception. Payment id is" + merchantPaymentId + " message id and name are " + e.getId() + e.getMessage());e.printStackTrace();}return "index";}public List<Order> getOrders(){return this.orders;}public String getMessage(){return this.message;}}