Subversion Repositories SmartDukaan

Rev

Rev 693 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 693 Rev 719
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
-
 
3
import java.io.IOException;
-
 
4
import java.util.HashMap;
-
 
5
import java.util.List;
-
 
6
import java.util.Map;
-
 
7
 
-
 
8
import org.apache.struts2.convention.annotation.Result;
-
 
9
import org.apache.struts2.convention.annotation.Results;
-
 
10
import org.apache.thrift.TException;
-
 
11
 
-
 
12
import in.shop2020.model.v1.order.Order;
-
 
13
import in.shop2020.model.v1.order.TransactionServiceException;
-
 
14
import in.shop2020.payments.PaymentException;
3
import in.shop2020.thrift.clients.PaymentServiceClient;
15
import in.shop2020.thrift.clients.PaymentServiceClient;
-
 
16
import in.shop2020.thrift.clients.TransactionServiceClient;
-
 
17
import in.shop2020.thrift.clients.UserContextServiceClient;
-
 
18
import in.shop2020.utils.Logger;
4
 
19
 
-
 
20
@Results({
5
import org.apache.struts2.rest.DefaultHttpHeaders;
21
    @Result(name="redirect", type="redirectAction", 
6
import org.apache.struts2.rest.HttpHeaders;
22
    		params = {"actionName" , "login"})
-
 
23
})
7
 
24
 
8
public class PayErrorController extends BaseController{
25
public class PayErrorController extends BaseController{
9
	public static String AMOUNT = "amount";
-
 
10
	public static String TRACKID = "trackid";
-
 
11
	public static String TRACKID_CANCELLED = "trackId";
-
 
12
	public static String RESULT = "ErrorText";
-
 
13
	public static String AUTH = "auth";
-
 
14
	public static String TRANID = "tranid";
-
 
15
	public static String PAYMENTID = "paymentId";
-
 
16
	public static String REF = "ref";
-
 
17
	public static String POSTDATE = "postdate";
26
	private static final long serialVersionUID = 1L;
18
	public static String CANCELED = "CANCELED";
-
 
19
	public static String APPROVED = "APPROVED";
-
 
20
	public static String CAPTURED = "CAPTURED";
-
 
21
	
-
 
22
	
-
 
23
	String amount;
-
 
24
	String trackId;
-
 
25
	String result;
-
 
26
	String paymentId;
-
 
27
	
-
 
28
	PaymentServiceClient pclient = null;
27
	PaymentServiceClient pclient = null;
-
 
28
	TransactionServiceClient tsc = null;
-
 
29
	UserContextServiceClient usc = null;
-
 
30
	
-
 
31
	long merchantPaymentId;
-
 
32
	List<Order> orders = null;
-
 
33
	String message = null;
29
	
34
	
30
	public PayErrorController(){
35
	public PayErrorController(){
-
 
36
		super();
31
		try {
37
		try {
32
			pclient = new PaymentServiceClient();
38
			pclient = new PaymentServiceClient();
-
 
39
			tsc = new TransactionServiceClient();
-
 
40
			usc = new UserContextServiceClient();
33
		} catch (Exception e) {
41
		} catch (Exception e) {
34
			e.printStackTrace();
42
			Logger.log("Could not initialize the paymentservice client", this);
35
		}
43
		}
36
	}
44
	}
37
	
45
	
38
	public String index(){
-
 
39
		amount = this.request.getParameter(AMOUNT);
46
	public String index() throws IOException, SecurityException, PaymentException, TException, TransactionServiceException{
40
		paymentId = this.request.getParameter(PAYMENTID);
47
		this.message = "Payment failed at the payment gateway. Please pay again.";
41
		trackId = this.request.getParameter(TRACKID);
-
 
42
		result = this.request.getParameter(RESULT);
-
 
43
		
48
		
-
 
49
    	if(!userinfo.isLoggedIn()){
-
 
50
    		System.out.println("Inside user is not logged in");
-
 
51
    		setRedirectUrl();
-
 
52
    		return "redirect";
-
 
53
    	}
-
 
54
    	merchantPaymentId = Long.parseLong(this.request.getParameter("paymentId"));
44
		return "";
55
    	return "index";
45
	}
56
	}
46
	
57
	
-
 
58
	
47
	public String getErrorText(){
59
	public String getMessage(){
48
		return result;
60
		return this.message;
49
	}
61
	}
50
 
62
	
51
}
63
}