Rev 3185 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.serving.controllers;import in.shop2020.datalogger.EventType;import in.shop2020.model.v1.order.Order;import in.shop2020.model.v1.order.TransactionServiceException;import in.shop2020.payments.PaymentException;import in.shop2020.serving.utils.Utils;import in.shop2020.thrift.clients.PaymentClient;import in.shop2020.thrift.clients.TransactionClient;import in.shop2020.thrift.clients.UserClient;import in.shop2020.utils.DataLogger;import java.io.IOException;import java.util.List;import org.apache.log4j.Logger;import org.apache.struts2.convention.annotation.InterceptorRef;import org.apache.struts2.convention.annotation.InterceptorRefs;import org.apache.thrift.TException;@InterceptorRefs({@InterceptorRef("myDefault"),@InterceptorRef("login")})public class PayErrorController extends BaseController{private static final long serialVersionUID = 1L;private static Logger log = Logger.getLogger(Class.class);PaymentClient pclient = null;TransactionClient tsc = null;UserClient usc = null;long merchantPaymentId;List<Order> orders = null;String message = null;public PayErrorController(){super();try {pclient = new PaymentClient();tsc = new TransactionClient();usc = new UserClient();} catch (Exception e) {log.error("Could not initialize the paymentservice client");}}public String index() throws IOException, SecurityException, PaymentException, TException, TransactionServiceException{this.message = "Payment failed at the payment gateway. Please pay again.";String merchantPaymentIdString = this.request.getParameter("paymentId");if(merchantPaymentIdString!=null){merchantPaymentId = Long.parseLong(merchantPaymentIdString);long txnId = pclient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();orders = tsc.getClient().getOrdersForTransaction(txnId, userinfo.getUserId());}DataLogger.logData(EventType.PAYMENT_FAILURE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),Long.toString(merchantPaymentId), Utils.getItemIdStringFromOrders(orders));return "index";}public String getMessage(){return this.message;}}