Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
428 ashish 1
package in.shop2020.serving.controllers;
2
 
3
import java.io.IOException;
712 rajveer 4
import java.util.HashMap;
428 ashish 5
import java.util.List;
712 rajveer 6
import java.util.Map;
428 ashish 7
 
822 vikas 8
import org.apache.struts2.convention.annotation.InterceptorRef;
9
import org.apache.struts2.convention.annotation.InterceptorRefs;
712 rajveer 10
import org.apache.struts2.convention.annotation.Result;
11
import org.apache.struts2.convention.annotation.Results;
428 ashish 12
import org.apache.thrift.TException;
13
 
712 rajveer 14
import in.shop2020.model.v1.order.LineItem;
555 chandransh 15
import in.shop2020.model.v1.order.Order;
428 ashish 16
import in.shop2020.model.v1.order.TransactionServiceException;
712 rajveer 17
import in.shop2020.model.v1.order.TransactionStatus;
18
import in.shop2020.model.v1.user.ShoppingCartException;
428 ashish 19
import in.shop2020.payments.PaymentException;
693 rajveer 20
import in.shop2020.payments.PaymentStatus;
712 rajveer 21
import in.shop2020.serving.utils.Utils;
428 ashish 22
import in.shop2020.thrift.clients.PaymentServiceClient;
23
import in.shop2020.thrift.clients.TransactionServiceClient;
712 rajveer 24
import in.shop2020.thrift.clients.UserContextServiceClient;
428 ashish 25
import in.shop2020.utils.Logger;
26
 
822 vikas 27
@InterceptorRefs({
28
    @InterceptorRef("myDefault"),
29
    @InterceptorRef("login")
712 rajveer 30
})
693 rajveer 31
 
719 rajveer 32
public class PaySuccessController extends BaseController{
693 rajveer 33
	private static final long serialVersionUID = 1L;
428 ashish 34
	PaymentServiceClient pclient = null;
35
	TransactionServiceClient tsc = null;
712 rajveer 36
	UserContextServiceClient usc = null;
428 ashish 37
 
712 rajveer 38
	long merchantPaymentId;
39
	List<Order> orders = null;
719 rajveer 40
	String message = null;
428 ashish 41
 
719 rajveer 42
	public PaySuccessController(){
428 ashish 43
		super();
44
		try {
45
			pclient = new PaymentServiceClient();
46
			tsc = new TransactionServiceClient();
712 rajveer 47
			usc = new UserContextServiceClient();
428 ashish 48
		} catch (Exception e) {
49
			Logger.log("Could not initialize the paymentservice client", this);
50
		}
51
	}
52
 
762 rajveer 53
	public String index() throws IOException, SecurityException, PaymentException, TException, TransactionServiceException, ShoppingCartException{
719 rajveer 54
		this.message = "Payment completed successfully.";
55
		System.out.println("Inside the index method of pay response");
56
 
57
		merchantPaymentId = Long.parseLong(this.request.getParameter("paymentId"));
58
 
59
		long txnId = pclient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
712 rajveer 60
 
719 rajveer 61
		orders = tsc.getClient().getOrdersForTransaction(txnId);
62
 
762 rajveer 63
		int totalItems = usc.getClient().getCart(userinfo.getCartId()).getLinesSize();
64
		userinfo.setTotalItems(totalItems);
65
 
693 rajveer 66
		return "index";
428 ashish 67
	}
68
 
719 rajveer 69
 
70
 
712 rajveer 71
	public List<Order> getOrders(){
72
		return this.orders;
485 rajveer 73
	}
74
 
75
	public String getMessage(){
76
		return this.message;
77
	}
78
 
79
}