Rev 719 | 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.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;@Results({@Result(name="redirect", type="redirectAction",params = {"actionName" , "login"})})public class PaySuccessController extends BaseController{private static final long serialVersionUID = 1L;PaymentServiceClient pclient = null;TransactionServiceClient tsc = null;UserContextServiceClient usc = null;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() throws IOException, SecurityException, PaymentException, TException, TransactionServiceException, ShoppingCartException{this.message = "Payment completed successfully.";System.out.println("Inside the index method of pay response");if(!userinfo.isLoggedIn()){System.out.println("Inside user is not logged in");setRedirectUrl();return "redirect";}merchantPaymentId = Long.parseLong(this.request.getParameter("paymentId"));long txnId = pclient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();orders = tsc.getClient().getOrdersForTransaction(txnId);int totalItems = usc.getClient().getCart(userinfo.getCartId()).getLinesSize();userinfo.setTotalItems(totalItems);return "index";}public List<Order> getOrders(){return this.orders;}public String getMessage(){return this.message;}}