Subversion Repositories SmartDukaan

Rev

Rev 1905 | Rev 2183 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1905 Rev 2159
Line 12... Line 12...
12
import org.apache.struts2.convention.annotation.InterceptorRefs;
12
import org.apache.struts2.convention.annotation.InterceptorRefs;
13
import org.apache.struts2.convention.annotation.Result;
13
import org.apache.struts2.convention.annotation.Result;
14
import org.apache.struts2.convention.annotation.Results;
14
import org.apache.struts2.convention.annotation.Results;
15
import org.apache.thrift.TException;
15
import org.apache.thrift.TException;
16
 
16
 
-
 
17
@SuppressWarnings("serial")
17
@InterceptorRefs({
18
@InterceptorRefs({
18
    @InterceptorRef("myDefault"),
19
    @InterceptorRef("myDefault"),
19
    @InterceptorRef("login")
20
    @InterceptorRef("login")
20
})
21
})
21
 
22
 
Line 27... Line 28...
27
public class OrderController extends BaseController {
28
public class OrderController extends BaseController {
28
	
29
	
29
	public long getPaymentId() {
30
	public long getPaymentId() {
30
		return paymentId;
31
		return paymentId;
31
	}
32
	}
32
 
-
 
33
	private static final long serialVersionUID = 1L;
-
 
34
	
33
	
35
	private static Logger log = Logger.getLogger(Class.class);
34
	private static Logger log = Logger.getLogger(Class.class);
36
	private String id;
35
	private String id;
37
	private long txnId = 0;
36
	private long txnId = 0;
38
	
37
	
Line 57... Line 56...
57
    	String addressIdString = this.request.getParameter("addressid");
56
    	String addressIdString = this.request.getParameter("addressid");
58
    	if(addressIdString == null){
57
    	if(addressIdString == null){
59
    		addActionError("Please specify shipping address to continue.");
58
    		addActionError("Please specify shipping address to continue.");
60
    		return "shipping-redirect";
59
    		return "shipping-redirect";
61
    	}
60
    	}
-
 
61
    	
-
 
62
    	String paymentOption = request.getParameter("payment_option");
-
 
63
    	log.info("Payment Option Selected: " + paymentOption);
-
 
64
    	if(paymentOption == null || paymentOption.equals("")){
-
 
65
    		addActionError("Please select a payment method to continue.");
-
 
66
    		return "shipping-redirect";
-
 
67
    	}
-
 
68
    	
-
 
69
    	
62
    	long addressId = Long.parseLong(addressIdString);
70
    	long addressId = Long.parseLong(addressIdString);
63
    	long currentCartId = userinfo.getCartId();
71
    	long currentCartId = userinfo.getCartId();
64
    	try{
72
    	try{
65
    		if(!createOrders(addressId, currentCartId)){
73
    		if(!createOrders(addressId, currentCartId)){
66
    			addActionError("We are experiencing some problems. Please try later.");
74
    			addActionError("We are experiencing some problems. Please try later.");
Line 70... Line 78...
70
    		addActionError("We are experiencing some problems. Please try later.");
78
    		addActionError("We are experiencing some problems. Please try later.");
71
    		log.error("Exception in createOrders function. Something want wrong.");
79
    		log.error("Exception in createOrders function. Something want wrong.");
72
    		e.printStackTrace();
80
    		e.printStackTrace();
73
    		return "shipping-redirect";
81
    		return "shipping-redirect";
74
		}
82
		}
75
		
83
    	
76
    	boolean paymode = Boolean.parseBoolean(request.getParameter("paymode"));
84
		if (paymentOption.equals(IPaymentService.EBS_MASTERCARD) || paymentOption.equals(IPaymentService.EBS_VISA)) {
77
		if (paymode) {
85
			// User has selected Visa or MasterCard CC
78
			HdfcPaymentService hdfcPaymentService = new HdfcPaymentService();
86
			IPaymentService hdfcPaymentService = new HdfcPaymentService();
79
			paymentId = hdfcPaymentService.createPayment(userinfo.getCartId(), userinfo.getUserId(), txnId);
87
			paymentId = hdfcPaymentService.createPayment(userinfo.getCartId(), userinfo.getUserId(), txnId, paymentOption);
80
			if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
88
			if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
81
				addActionError("We are experiencing some problems. Please try later.");
89
				addActionError("We are experiencing some problems. Please try later.");
82
				return "shipping-redirect";
90
				return "shipping-redirect";
83
			} else {
91
			} else {
84
				this.redirectURL = hdfcPaymentService.getRedirectUrl();
92
				this.redirectURL = ((HdfcPaymentService)hdfcPaymentService).getRedirectUrl();
85
				log.info(this.redirectURL);
93
				log.info(this.redirectURL);
86
				return "success";
94
				return "success";
87
			}
95
			}
88
		} else {
96
		} else {
89
			EbsPaymentService ebsPaymentService = new EbsPaymentService();
97
			IPaymentService ebsPaymentService = new EbsPaymentService();
90
			paymentId = ebsPaymentService.createPayment(userinfo.getCartId(), userinfo.getUserId(), txnId);
98
			paymentId = ebsPaymentService.createPayment(userinfo.getCartId(), userinfo.getUserId(), txnId, paymentOption);
91
			if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
99
			if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
92
				addActionError("We are experiencing some problems. Please try later.");
100
				addActionError("We are experiencing some problems. Please try later.");
93
				return "shipping-redirect";
101
				return "shipping-redirect";
94
			}else{
102
			}else{
95
				log.info("Successfully created payment for EBS to process. Redirecting to: ");
103
				log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
96
				return "ebs-pay-redirect";
104
				return "ebs-pay-redirect";
97
			}
105
			}
98
		}
106
		}
99
    }
107
    }
100
    
108