Subversion Repositories SmartDukaan

Rev

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

Rev 517 Rev 682
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.Date;
-
 
5
import java.util.Map;
-
 
6
import java.util.Random;
-
 
7
 
-
 
8
import javax.servlet.ServletContext;
-
 
9
import javax.servlet.http.Cookie;
-
 
10
import javax.servlet.http.HttpServletResponse;
3
import javax.servlet.http.HttpServletResponse;
11
 
-
 
12
import org.apache.struts2.convention.annotation.Result;
-
 
13
import org.apache.struts2.convention.annotation.Results;
-
 
14
import org.apache.struts2.interceptor.ParameterAware;
-
 
15
import org.apache.struts2.rest.DefaultHttpHeaders;
4
import org.apache.struts2.rest.DefaultHttpHeaders;
16
import org.apache.struts2.rest.HttpHeaders;
5
import org.apache.struts2.rest.HttpHeaders;
17
import org.apache.struts2.util.ServletContextAware;
-
 
18
import org.apache.thrift.TException;
6
import org.apache.thrift.TException;
19
 
7
 
20
import in.shop2020.config.ConfigException;
8
import in.shop2020.config.ConfigException;
21
import in.shop2020.model.v1.user.AuthenticationException;
-
 
22
import in.shop2020.model.v1.user.UserContextException;
-
 
23
import in.shop2020.model.v1.user.UserContextService.Client;
-
 
24
import in.shop2020.payments.PaymentException;
9
import in.shop2020.payments.PaymentException;
25
import in.shop2020.payments.PaymentService;
-
 
26
import in.shop2020.serving.services.UserSessionInfo;
-
 
27
import in.shop2020.serving.utils.Utils;
10
import in.shop2020.serving.utils.Utils;
28
import in.shop2020.thrift.clients.PaymentServiceClient;
11
import in.shop2020.thrift.clients.PaymentServiceClient;
29
import in.shop2020.thrift.clients.UserContextServiceClient;
-
 
30
import in.shop2020.thrift.clients.UserProfileClient;
-
 
31
import in.shop2020.thrift.clients.config.ConfigClient;
12
import in.shop2020.thrift.clients.config.ConfigClient;
32
 
13
 
33
 
14
 
34
 
15
 
35
import com.aciworldwide.commerce.gateway.plugins.NotEnoughDataException;
16
import com.aciworldwide.commerce.gateway.plugins.NotEnoughDataException;
36
import com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe;
17
import com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe;
37
import com.opensymphony.xwork2.ModelDriven;
-
 
38
/*
18
/*
39
@Results({
19
@Results({
40
    @Result(name="success", type="redirectAction", params = {"actionName" , 
20
    @Result(name="success", type="redirectAction", params = {"actionName" , 
41
    		"pay"})
21
    		"pay"})
42
})
22
})
43
*/
23
*/
44
public class PayController extends BaseController implements ParameterAware, ServletContextAware {
24
public class HdfcPayController extends BaseController {
45
 
25
	
46
	Map<String, String[]> reqparams;
26
	private static final long serialVersionUID = 1L;
47
	
27
	
48
	private String id;
-
 
49
	PaymentServiceClient paymentServiceClient = null;
28
	PaymentServiceClient paymentServiceClient = null;
50
	private String redirectURL;
29
	private String redirectURL;
-
 
30
	private enum ActionType{
-
 
31
		PURCHASE("1"),
-
 
32
		AUTH ("4");
-
 
33
		private String value;
-
 
34
		ActionType(String value) {
-
 
35
			this.value = value;
-
 
36
		}
-
 
37
		public String value(){
-
 
38
			return this.value;
-
 
39
		}
-
 
40
	}
51
	
41
	
52
	private ServletContext servletContext;
-
 
53
	
-
 
54
	public PayController(){
42
	public HdfcPayController(){
55
		
-
 
56
		try {
43
		try {
57
			paymentServiceClient = new PaymentServiceClient();
44
			paymentServiceClient = new PaymentServiceClient();
58
		} catch (Exception e) {
45
		} catch (Exception e) {
59
			e.printStackTrace();
46
			e.printStackTrace();
60
		}
47
		}
Line 74... Line 61...
74
		String email = "";
61
		String email = "";
75
		String contactNumber = "";
62
		String contactNumber = "";
76
		String billingAddress = "";
63
		String billingAddress = "";
77
		String merchantInfo = "";
64
		String merchantInfo = "";
78
		String amount;
65
		String amount;
-
 
66
		
79
		try{
67
		try{
80
			amount = this.reqparams.get("amount")[0];
68
			amount = request.getParameter("amount");
81
		}catch(Exception e){
69
		}catch(Exception e){
82
			amount = (new Double(Utils.getPaymentAmount(userinfo.getCartId()))).toString();
70
			amount = (new Double(Utils.getPaymentAmount(userinfo.getCartId()))).toString();
83
		}
71
		}
84
		//String amount = this.request.getParameter("amount");
-
 
85
		session.setAttribute("amount", amount);
-
 
-
 
72
		
86
		// May be we can use some utils function to get the prices in cart but it is better to get price from post form
73
		// May be we can use some utils function to get the prices in cart but it is better to get price from post form
87
		
74
		
88
		long paymentId = 0;
75
		long paymentId = 0;
89
		in.shop2020.payments.PaymentService.Client client = paymentServiceClient.getClient();
76
		in.shop2020.payments.PaymentService.Client client = paymentServiceClient.getClient();
90
	
77
	
Line 144... Line 131...
144
		
131
		
145
		pipe.setAlias(aliasName);			//mandatory 
132
		pipe.setAlias(aliasName);			//mandatory 
146
		String ab=pipe.getAlias();
133
		String ab=pipe.getAlias();
147
		System.out.println("Alias="+ab+ "<br>");
134
		System.out.println("Alias="+ab+ "<br>");
148
 
135
 
149
		pipe.setAction("1");			//mandatory 
136
		pipe.setAction(ActionType.PURCHASE.value());			//mandatory 
150
		String ac=pipe.getAction();
137
		String ac=pipe.getAction();
151
		System.out.println("Action="+ac+ "<br>");
138
		System.out.println("Action="+ac+ "<br>");
152
 
139
 
153
		pipe.setResponseURL( responseURL );	//mandatory
140
		pipe.setResponseURL( responseURL );	//mandatory
154
		String at=pipe.getResponseURL();
141
		String at=pipe.getResponseURL();
Line 224... Line 211...
224
		
211
		
225
		//response.sendRedirect(response.encodeRedirectURL( "www.yahoo.com" ));
212
		//response.sendRedirect(response.encodeRedirectURL( "www.yahoo.com" ));
226
		
213
		
227
		return new DefaultHttpHeaders("fail");
214
		return new DefaultHttpHeaders("fail");
228
	}
215
	}
229
	
-
 
230
	public String getId(){
-
 
231
		return id;
-
 
232
	}
-
 
233
	
-
 
234
	public void setId(String id){
-
 
235
		this.id = id;
-
 
236
	}
-
 
237
 
216
 
238
	@Override
-
 
239
	public void setParameters(Map<String, String[]> reqmap) {
-
 
240
		//log.info("setParameters:" + reqmap);
-
 
241
		
-
 
242
		this.reqparams = reqmap;
-
 
243
	}
-
 
244
	
-
 
245
	@Override
-
 
246
	public void setServletContext(ServletContext servletContext) {
-
 
247
		this.servletContext = servletContext;
-
 
248
	}
-
 
249
	
-
 
250
}
217
}
251
 
218