Subversion Repositories SmartDukaan

Rev

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

Rev 829 Rev 894
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.HashMap;
-
 
5
import java.util.List;
4
import java.util.List;
6
import java.util.Map;
-
 
7
import java.util.Random;
5
import java.util.Random;
8
 
6
 
9
import javax.servlet.http.HttpServletResponse;
7
import javax.servlet.http.HttpServletResponse;
10
 
8
 
-
 
9
import org.apache.log4j.Logger;
11
import org.apache.struts2.convention.annotation.Result;
10
import org.apache.struts2.convention.annotation.Result;
12
import org.apache.struts2.convention.annotation.Results;
11
import org.apache.struts2.convention.annotation.Results;
13
import org.apache.struts2.rest.DefaultHttpHeaders;
-
 
14
import org.apache.struts2.rest.HttpHeaders;
-
 
15
import org.apache.thrift.TException;
12
import org.apache.thrift.TException;
16
 
13
 
17
import in.shop2020.config.ConfigException;
14
import in.shop2020.config.ConfigException;
18
import in.shop2020.model.v1.order.LineItem;
15
import in.shop2020.model.v1.order.LineItem;
19
import in.shop2020.model.v1.order.Order;
16
import in.shop2020.model.v1.order.Order;
20
import in.shop2020.model.v1.order.Transaction;
17
import in.shop2020.model.v1.order.Transaction;
-
 
18
import in.shop2020.model.v1.order.TransactionServiceException;
-
 
19
import in.shop2020.model.v1.user.Cart;
-
 
20
import in.shop2020.model.v1.user.Line;
21
import in.shop2020.model.v1.user.ShoppingCartException;
21
import in.shop2020.model.v1.user.ShoppingCartException;
22
import in.shop2020.payments.Attribute;
22
import in.shop2020.payments.Attribute;
23
import in.shop2020.payments.PaymentException;
-
 
24
import in.shop2020.payments.PaymentStatus;
23
import in.shop2020.payments.PaymentStatus;
25
import in.shop2020.serving.utils.Utils;
24
import in.shop2020.serving.utils.Utils;
26
import in.shop2020.thrift.clients.PaymentServiceClient;
25
import in.shop2020.thrift.clients.PaymentServiceClient;
27
import in.shop2020.thrift.clients.TransactionServiceClient;
26
import in.shop2020.thrift.clients.TransactionServiceClient;
-
 
27
import in.shop2020.thrift.clients.UserContextServiceClient;
28
import in.shop2020.thrift.clients.config.ConfigClient;
28
import in.shop2020.thrift.clients.config.ConfigClient;
29
 
29
 
30
 
30
 
31
 
31
 
32
import com.aciworldwide.commerce.gateway.plugins.NotEnoughDataException;
32
import com.aciworldwide.commerce.gateway.plugins.NotEnoughDataException;
33
import com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe;
33
import com.aciworldwide.commerce.gateway.plugins.e24PaymentPipe;
34
@Results({
34
@Results({
35
	@Result(name="redirect", type="redirectAction", 
35
	@Result(name="redirect", type="redirectAction", 
36
			params = {"actionName" , "${url}"})
36
			params = {"actionName" , "${url}"}),
-
 
37
	@Result(name="shipping-redirect", type="redirectAction", 
-
 
38
    		params = {"actionName" , "shipping"})
37
})
39
})
38
 
40
 
39
public class HdfcPayController extends BaseController {
41
public class HdfcPayController extends BaseController {
40
	
-
 
41
	private static final long serialVersionUID = 1L;
42
	private static final long serialVersionUID = 1L;
-
 
43
	private static Logger log = Logger.getLogger(Class.class);
42
	
44
	
-
 
45
	private static String resourceFilePath;
-
 
46
	private static String aliasName;
-
 
47
	private static String responseURL;
-
 
48
	private static String errorURL;
-
 
49
	private static final String regex = "[^a-zA-Z0-9\\s\\-\\@\\/\\.]";
43
	PaymentServiceClient paymentServiceClient = null;
50
	private static final String replacement = " ";
-
 
51
	private static final int MAX_UDF_LENGTH = 30;
44
	private String redirectURL;
52
	private String redirectURL;
-
 
53
	private e24PaymentPipe pipe = null;
-
 
54
	
45
	private enum ActionType{
55
	private enum ActionType{
46
		PURCHASE("1"),
56
		PURCHASE("1"),
47
		AUTH ("4");
57
		AUTH ("4");
48
		private String value;
58
		private String value;
49
		ActionType(String value) {
59
		ActionType(String value) {
Line 53... Line 63...
53
			return this.value;
63
			return this.value;
54
		}
64
		}
55
	}
65
	}
56
	
66
	
57
	public HdfcPayController(){
67
	public HdfcPayController(){
58
		try {
-
 
59
			paymentServiceClient = new PaymentServiceClient();
-
 
60
		} catch (Exception e) {
-
 
61
			e.printStackTrace();
-
 
62
		}
-
 
63
	}
-
 
64
	
-
 
65
	public String getRedirectURL(){
-
 
66
		return this.redirectURL;
-
 
67
	}
-
 
68
	
-
 
69
	public String index(){
-
 
70
		String orderDetails = "";
-
 
71
		String email = "";
-
 
72
		String contactNumber = "";
-
 
73
		String billingAddress = "";
-
 
74
		String merchantInfo = "";
-
 
75
		String amount;
-
 
76
		long txnId;
-
 
77
		
-
 
78
		
-
 
79
		System.out.println("amount:" + request.getParameter("amount"));
-
 
80
		System.out.println("amount:" + request.getParameter("txnid"));
-
 
81
		System.out.println("amount:" + request.getParameter("paymentid"));
-
 
82
		
-
 
83
		try{
-
 
84
			amount = request.getParameter("amount");
-
 
85
		}catch(Exception e){
-
 
86
			amount = (new Double(Utils.getPaymentAmount(userinfo.getCartId()))).toString();
-
 
87
		}
-
 
88
		txnId = Long.parseLong(request.getParameter("txnid"));
-
 
89
			
-
 
90
		
-
 
91
		
-
 
92
//	    Random rnd = new Random(System.currentTimeMillis());
-
 
93
//		String trackId = String.valueOf(Math.abs(rnd.nextLong()));	//Merchant must generate the Track Id
-
 
94
		
68
		
95
		String merchantPaymentId = request.getParameter("paymentid");	
-
 
96
		
69
	}
97
		session.setAttribute("trackId",merchantPaymentId);
-
 
98
//		String InstituteID=request.getParameter("InstituteID");	//Must be 1 for the merchant having only one bank(mandatory must be initilized)
-
 
99
	
70
	
100
		
71
	static{
101
		//Following is the code which initilize e24PaymentPipe with proper value
-
 
102
		e24PaymentPipe pipe=new e24PaymentPipe();
-
 
103
		String resourceFilePath = "";
-
 
104
		String aliasName = "";
-
 
105
		String responseURL = "";
-
 
106
		String errorURL = "";
-
 
107
		try {
72
		try {
108
			resourceFilePath = ConfigClient.getClient().get("payment_resource_file_path");
73
			resourceFilePath = ConfigClient.getClient().get("payment_resource_file_path");
109
			aliasName  = ConfigClient.getClient().get("payment_alias_name");
74
			aliasName  = ConfigClient.getClient().get("payment_alias_name");
110
			responseURL = ConfigClient.getClient().get("payment_response_url");
75
			responseURL = ConfigClient.getClient().get("payment_response_url");
111
			errorURL = ConfigClient.getClient().get("payment_error_url");
76
			errorURL = ConfigClient.getClient().get("payment_error_url");
112
		} catch (ConfigException e1) {
77
		} catch (ConfigException e) {
113
			// TODO Auto-generated catch block
-
 
114
			resourceFilePath = "/home/rajveer/shop2020/payments/resource/";
78
			log.error("Unable to get data from config server.");
115
			aliasName = "90001194";
-
 
116
			
-
 
117
			responseURL = "http://74.207.248.175:8080/JSP-Pages/HRedirect.jsp";
-
 
118
			errorURL = "http://74.207.248.175:8080/JSP-Pages/HError.jsp";
-
 
119
//			responseURL = "http://securemtp.fssnet.co.in/MerchantDemo/viren/TESTTEST/HRedirect.jsp";
-
 
120
//			errorURL = "http://securemtp.fssnet.co.in/MerchantDemo/viren/TESTTEST/HError.jsp";
-
 
121
			e1.printStackTrace();
-
 
122
		}
79
		}
123
		
80
	}
124
		pipe.setResourcePath(resourceFilePath);	//mandatory 
-
 
125
		String as = pipe.getResourcePath();
-
 
126
		System.out.println("Resource="+as+ "<br>");
-
 
127
		
-
 
128
		pipe.setAlias(aliasName);			//mandatory 
-
 
129
		String ab=pipe.getAlias();
-
 
130
		System.out.println("Alias="+ab+ "<br>");
-
 
131
 
-
 
132
		pipe.setAction(ActionType.PURCHASE.value());			//mandatory 
-
 
133
		String ac=pipe.getAction();
-
 
134
		System.out.println("Action="+ac+ "<br>");
-
 
135
 
-
 
136
		pipe.setResponseURL( responseURL );	//mandatory
-
 
137
		String at=pipe.getResponseURL();
-
 
138
		System.out.println("ResponseURL="+at+ "<br>");
-
 
139
	
81
	
140
		pipe.setErrorURL( errorURL );		//mandatory 
-
 
141
        String ak=pipe.getErrorURL();
-
 
142
        System.out.println("ErrorURL="+ak+ "<br>");
-
 
143
	
82
	
144
 
-
 
145
		pipe.setAmt(amount);		
-
 
146
		String ap=pipe.getAmt();
83
	public String index(){
147
		System.out.println("Amt="+ap);
-
 
148
 
-
 
149
		pipe.setCurrency("356");
-
 
150
		String a=pipe.getCurrency();
-
 
151
		System.out.println("Currency="+a+ "<br>");
-
 
152
 
-
 
153
		pipe.setLanguage("USA");
-
 
154
		String p=pipe.getLanguage();
-
 
155
		System.out.println("Language="+p+ "<br>");
-
 
156
        
-
 
157
		pipe.setTrackId(merchantPaymentId);
-
 
158
		
84
		
-
 
85
		String merchantPaymentId = request.getParameter("paymentid");
-
 
86
		long txnId = Long.parseLong(request.getParameter("txnid"));
-
 
87
		
159
		//get udfs
88
		if(merchantPaymentId == null){
-
 
89
			addActionError("We are experiencing problem. Please try later.");
-
 
90
			log.error("Merchant payment is null. It should not have reached here.");
160
		Transaction transaction;
91
			return "shipping-redirect";
-
 
92
		}
-
 
93
		
-
 
94
		PaymentServiceClient paymentServiceClient = null;
161
		try {
95
		try {
162
			TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
96
			paymentServiceClient = new PaymentServiceClient();
163
			in.shop2020.model.v1.order.TransactionService.Client txnClient = transactionServiceClient.getClient();
-
 
164
			transaction = txnClient.getTransaction(txnId);
-
 
165
			orderDetails = orderDetails + transaction.getOrdersSize() + " ";
-
 
166
			for (Order order : transaction.getOrders()) {
-
 
167
				contactNumber = order.getCustomer_mobilenumber();
-
 
168
				email = order.getCustomer_email();
-
 
169
				billingAddress = " ";
-
 
170
				if(order.getCustomer_pincode()!=null){
-
 
171
					billingAddress = billingAddress + order.getCustomer_pincode();
-
 
172
				}
-
 
173
				if(order.getCustomer_city()!=null){
-
 
174
					billingAddress = billingAddress + " " + order.getCustomer_city();
-
 
175
				}
-
 
176
				if(order.getCustomer_address1()!=null){
-
 
177
					billingAddress = billingAddress + " " + order.getCustomer_address1();
-
 
178
				}
-
 
179
				if(order.getCustomer_address2()!=null){
-
 
180
					billingAddress = billingAddress + order.getCustomer_address2();
-
 
181
				}
-
 
182
				if(order.getCustomer_state()!=null){
-
 
183
					billingAddress = billingAddress + order.getCustomer_state();
-
 
184
				}
-
 
185
				
-
 
186
 
-
 
187
				for(LineItem line: order.getLineitems()){
-
 
188
					if(line.getBrand() != null){
-
 
189
						orderDetails = orderDetails + line.getBrand();
-
 
190
					}
-
 
191
					if(line.getModel_name() != null){
-
 
192
						orderDetails = orderDetails + line.getModel_name(); 
-
 
193
					}
-
 
194
					if(line.getModel_number() != null){
-
 
195
						orderDetails = orderDetails + line.getModel_number();
-
 
196
					}
-
 
197
					if(line.getColor() != null){
-
 
198
						orderDetails = orderDetails + line.getColor();
-
 
199
					}
-
 
200
					orderDetails = orderDetails + " ";
-
 
201
				}
-
 
202
				
-
 
203
			}
-
 
204
		} catch (TException e) {
-
 
205
			e.printStackTrace();
-
 
206
		} catch (Exception e) {
97
		} catch (Exception e) {
207
			e.printStackTrace();
98
			e.printStackTrace();
208
		}
99
		}
209
		
100
		
210
	
-
 
211
		String regex = "[^a-zA-Z0-9\\s\\-\\@\\/\\.]";
-
 
212
		String replacement = " ";
-
 
213
		
101
		try {
214
		orderDetails = orderDetails.replaceAll(regex, replacement);
102
			initializePayment(merchantPaymentId);
215
		email = email.replaceAll(regex, replacement);
103
		} catch (ShoppingCartException e1) {
216
		//contactNumber = replacement.replaceAll(regex, replacement);
104
			addActionError("We are experiencing problem. Please try later.");
217
		billingAddress = billingAddress.replaceAll(regex, replacement);
105
			log.error("Error while creating hdfc payment.");
218
		if(email.length() > 30){
106
			e1.printStackTrace();
219
			email = email.substring(0, 30);
107
			return "shipping-redirect";
220
		}
-
 
221
		if(contactNumber.length() > 30){
108
		} catch (TException e1) {
222
			contactNumber = contactNumber.substring(0, 30);
109
			addActionError("We are experiencing problem. Please try later.");
223
		}
-
 
224
		if(orderDetails.length() > 30){
-
 
225
			orderDetails = orderDetails.substring(0, 30);
110
			log.error("Error while creating hdfc payment.");
226
		}
-
 
227
		if(billingAddress.length() > 30){
111
			e1.printStackTrace();
228
			billingAddress = billingAddress.substring(0, 30);
112
			return "shipping-redirect";
229
		}
113
		}
230
		Random random = new Random();
-
 
231
		merchantInfo = ""+random.nextLong(); 
-
 
232
		
-
 
233
		
114
		
234
//		UDF 1 - Order details
-
 
235
//		UDF 2 - Email ID
-
 
236
//		UDF 3 - Contact Number. 
115
		List<Attribute> attributes = null;
237
//		UDF 4 - Billing Address
-
 
238
//		UDF 5 - Merchant specific
-
 
239
		
-
 
240
		
116
		try {
241
        System.out.println("udf1:"  + orderDetails);
117
			attributes = getAttributesAndSetUdfs(txnId);
242
        System.out.println("udf2:"  + email);
118
		} catch (TransactionServiceException e1) {
243
        System.out.println("udf3:"  + contactNumber);
119
			addActionError("We are experiencing problem. Please try later.");
244
        System.out.println("udf4:"  + billingAddress);
120
			log.error("Error while setting udfs to payment.");
245
        System.out.println("udf5:"  + merchantInfo);
121
			e1.printStackTrace();
246
        
-
 
247
        
-
 
248
		pipe.setUdf1(orderDetails);
122
			return "shipping-redirect";
249
		pipe.setUdf2(email);
123
		} catch (TException e1) {
-
 
124
			addActionError("We are experiencing problem. Please try later.");
250
		pipe.setUdf3(contactNumber);
125
			log.error("Error while setting udfs to payment.");
251
		pipe.setUdf4(billingAddress);
126
			e1.printStackTrace();
252
		pipe.setUdf5(merchantInfo);
127
			return "shipping-redirect";
-
 
128
		}
253
		
129
		
254
		List<Attribute> attributes = new ArrayList<Attribute>();
-
 
255
		Attribute attribute1 = new Attribute();
-
 
256
		Attribute attribute2 = new Attribute();
-
 
257
		Attribute attribute3 = new Attribute();
-
 
258
		Attribute attribute4 = new Attribute();
-
 
259
		Attribute attribute5 = new Attribute();
-
 
260
		attribute1.setName("udf1");
-
 
261
		attribute1.setValue(orderDetails);
-
 
262
		attribute2.setName("udf2");
-
 
263
		attribute2.setValue(email);
-
 
264
		attribute3.setName("udf3");
-
 
265
		attribute3.setValue(contactNumber);
-
 
266
		attribute4.setName("udf4");
-
 
267
		attribute4.setValue(billingAddress);
-
 
268
		attribute5.setName("udf5");
-
 
269
		attribute5.setValue(merchantInfo);
-
 
270
		attributes.add(attribute1);
-
 
271
		attributes.add(attribute2);
-
 
272
		attributes.add(attribute3);
-
 
273
		attributes.add(attribute4);
-
 
274
		attributes.add(attribute5);
-
 
275
		
130
		
276
		try {
131
		try {
277
			if(pipe.performPaymentInitialization() != e24PaymentPipe.SUCCESS) 
132
			if(pipe.performPaymentInitialization() != e24PaymentPipe.SUCCESS) 
278
				{
133
				{
279
					System.out.println("Error sending Payment Initialization Request: ");
134
					System.out.println("Error sending Payment Initialization Request: ");
Line 296... Line 151...
296
					response.setHeader("Location", redirectURL);
151
					response.setHeader("Location", redirectURL);
297
					response.setStatus(HttpServletResponse.SC_FOUND);
152
					response.setStatus(HttpServletResponse.SC_FOUND);
298
				}
153
				}
299
			return "success";
154
			return "success";
300
		} catch (NotEnoughDataException e) {
155
		} catch (NotEnoughDataException e) {
301
			// TODO Auto-generated catch block
156
			log.error("Error while initializing payment." + e.getMessage());
302
			e.printStackTrace();
157
			e.printStackTrace();
303
		}catch (Exception e) {
158
		}catch (Exception e) {
304
			// TODO Auto-generated catch block
159
			log.error("Error while initializing payment." + e.getMessage());
305
			e.printStackTrace();
160
			e.printStackTrace();
306
		}
161
		}
307
		
162
		
308
		//response.sendRedirect(response.encodeRedirectURL( "www.yahoo.com" ));
-
 
309
		redirectURL = errorURL + "?ErrorText=Error while initializing payment.";
163
		redirectURL = errorURL + "?paymentId="+merchantPaymentId + "?ErrorText=Error while initializing payment.";
310
		return "success";
164
		return "success";
311
	}
165
	}
312
	
166
	
-
 
167
	
-
 
168
	private double getPaymentAmount(long cartId) throws ShoppingCartException, TException{
-
 
169
		double totalAmount = 0;
-
 
170
		Cart cart;
-
 
171
		UserContextServiceClient userContextServiceClient = null;
-
 
172
		try {
-
 
173
			userContextServiceClient = new UserContextServiceClient();
-
 
174
		} catch (Exception e) {
-
 
175
			e.printStackTrace();
-
 
176
		}
-
 
177
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
-
 
178
		cart = userClient.getCart(cartId);
-
 
179
	
-
 
180
		List<Line> lineItems = cart.getLines(); 
-
 
181
	
-
 
182
		for (Line line : lineItems) {
-
 
183
			long productId = line.getItemId();
-
 
184
			totalAmount =  totalAmount + line.getQuantity() * Utils.getItemPrice(productId);
-
 
185
		}
-
 
186
 
-
 
187
		return totalAmount;
-
 
188
	}
-
 
189
	
-
 
190
	
-
 
191
	private List<Attribute> getAttributesAndSetUdfs(long txnId) throws TransactionServiceException, TException{
-
 
192
		StringBuilder orderDetails = new StringBuilder();
-
 
193
		StringBuilder billingAddress = new StringBuilder();
313
	String getUrl(){
194
		String email = "";
-
 
195
		String contactNumber = "";
-
 
196
		
-
 
197
		//get udfs
-
 
198
		Transaction transaction;
-
 
199
		TransactionServiceClient transactionServiceClient = null;
-
 
200
		try {
-
 
201
			transactionServiceClient = new TransactionServiceClient();
-
 
202
		} catch (Exception e) {
-
 
203
			// TODO Auto-generated catch block
-
 
204
			e.printStackTrace();
-
 
205
		}
-
 
206
		
-
 
207
		in.shop2020.model.v1.order.TransactionService.Client txnClient = transactionServiceClient.getClient();
-
 
208
		transaction = txnClient.getTransaction(txnId);
-
 
209
		orderDetails.append(transaction.getOrdersSize() + " ");
-
 
210
		for (Order order : transaction.getOrders()) {
-
 
211
			contactNumber= order.getCustomer_mobilenumber();
-
 
212
			email = order.getCustomer_email();
-
 
213
			billingAddress.append(" ");
-
 
214
			if(order.getCustomer_pincode()!=null){
-
 
215
				billingAddress.append(order.getCustomer_pincode());
-
 
216
			}
-
 
217
			if(order.getCustomer_city()!=null){
-
 
218
				billingAddress.append(" " + order.getCustomer_city());
-
 
219
			}
-
 
220
			if(order.getCustomer_address1()!=null){
-
 
221
				billingAddress.append(" " + order.getCustomer_address1());
-
 
222
			}
-
 
223
			if(order.getCustomer_address2()!=null){
-
 
224
				billingAddress.append(" " + order.getCustomer_address2());
-
 
225
			}
-
 
226
			if(order.getCustomer_state()!=null){
-
 
227
				billingAddress.append(" " + order.getCustomer_state());
-
 
228
			}
-
 
229
			
-
 
230
 
-
 
231
			for(LineItem line: order.getLineitems()){
-
 
232
				if(line.getBrand() != null){
-
 
233
					orderDetails.append(line.getBrand());
-
 
234
				}
-
 
235
				if(line.getModel_name() != null){
-
 
236
					orderDetails.append(line.getModel_name()); 
-
 
237
				}
-
 
238
				if(line.getModel_number() != null){
-
 
239
					orderDetails.append(line.getModel_number());
-
 
240
				}
-
 
241
				if(line.getColor() != null){
-
 
242
					orderDetails.append(line.getColor());
-
 
243
				}
-
 
244
				orderDetails.append(" ");
-
 
245
			}
-
 
246
			
-
 
247
		}
-
 
248
		
-
 
249
		Random random = new Random();
-
 
250
		String merchantInfo = ""+random.nextLong(); 
-
 
251
		
-
 
252
	    log.info("udf1:"  + orderDetails);
-
 
253
	    log.info("udf2:"  + email);
-
 
254
	    log.info("udf3:"  + contactNumber);
-
 
255
	    log.info("udf4:"  + billingAddress);
-
 
256
	    log.info("udf5:"  + merchantInfo);
-
 
257
	    
-
 
258
	    String udf1 = formatUdf(orderDetails.toString()); 
-
 
259
	    String udf2 = formatUdf(email);
-
 
260
	    String udf3 = formatUdf(contactNumber);
-
 
261
	    String udf4 = formatUdf(billingAddress.toString());
-
 
262
	    String udf5 = merchantInfo;
-
 
263
	    
-
 
264
	    pipe.setUdf1(udf1);       //	UDF 1 - Order details
-
 
265
		pipe.setUdf2(udf2);        	  				//	UDF 2 - Email ID
-
 
266
		pipe.setUdf3(udf3);      			//	UDF 3 - Contact Number. 
-
 
267
		pipe.setUdf4(udf4);     //	UDF 4 - Billing Address
-
 
268
		pipe.setUdf5(udf5);		  						//	UDF 5 - Merchant specific
-
 
269
	    
-
 
270
		List<Attribute> attributes = new ArrayList<Attribute>();
-
 
271
		Attribute attribute1 = new Attribute("udf1",udf1);
-
 
272
		Attribute attribute2 = new Attribute("udf2",udf2);
-
 
273
		Attribute attribute3 = new Attribute("udf3",udf3);
-
 
274
		Attribute attribute4 = new Attribute("udf4",udf4);
-
 
275
		Attribute attribute5 = new Attribute("udf5",udf5);
-
 
276
		
-
 
277
		attributes.add(attribute1);
-
 
278
		attributes.add(attribute2);
-
 
279
		attributes.add(attribute3);
-
 
280
		attributes.add(attribute4);
-
 
281
		attributes.add(attribute5);
-
 
282
		
314
		return this.redirectURL;
283
		return attributes;
315
	}
284
	}
316
 
285
 
-
 
286
	
-
 
287
	
-
 
288
	private void initializePayment(String merchantPaymentId) throws ShoppingCartException, TException{
-
 
289
		String amount;
-
 
290
		
-
 
291
		amount = (new Double(getPaymentAmount(userinfo.getCartId()))).toString();
-
 
292
		
-
 
293
		//Following is the code which initilize e24PaymentPipe with proper value		
-
 
294
		pipe=new e24PaymentPipe();
-
 
295
		pipe.setResourcePath(resourceFilePath);	//mandatory 
-
 
296
		String as = pipe.getResourcePath();
-
 
297
		log.info("Resource="+as+ "<br>");
-
 
298
		
-
 
299
		pipe.setAlias(aliasName);			//mandatory 
-
 
300
		String ab=pipe.getAlias();
-
 
301
		log.info("Alias="+ab+ "<br>");
-
 
302
	
-
 
303
		pipe.setAction(ActionType.PURCHASE.value());			//mandatory 
-
 
304
		String ac=pipe.getAction();
-
 
305
		log.info("Action="+ac+ "<br>");
-
 
306
	
-
 
307
		pipe.setResponseURL( responseURL );	//mandatory
-
 
308
		String at=pipe.getResponseURL();
-
 
309
		log.info("ResponseURL="+at+ "<br>");
-
 
310
	
-
 
311
		pipe.setErrorURL( errorURL );		//mandatory 
-
 
312
	    String ak=pipe.getErrorURL();
-
 
313
	    log.info("ErrorURL="+ak+ "<br>");
-
 
314
	
-
 
315
	
-
 
316
		pipe.setAmt(amount);		
-
 
317
		String ap=pipe.getAmt();
-
 
318
		log.info("Amt="+ap);
-
 
319
	
-
 
320
		pipe.setCurrency("356");
-
 
321
		String a=pipe.getCurrency();
-
 
322
		log.info("Currency="+a+ "<br>");
-
 
323
	
-
 
324
		pipe.setLanguage("USA");
-
 
325
		String p=pipe.getLanguage();
-
 
326
		log.info("Language="+p+ "<br>");
-
 
327
	    
-
 
328
		pipe.setTrackId(merchantPaymentId);
-
 
329
	
-
 
330
	}
-
 
331
	
-
 
332
	String formatUdf(String udfString){
-
 
333
		udfString.replaceAll(regex, replacement);
-
 
334
		if(udfString.length() > MAX_UDF_LENGTH){
-
 
335
			udfString = udfString.substring(0, MAX_UDF_LENGTH);
-
 
336
		}
-
 
337
		return udfString;
-
 
338
	}
317
 
339
 
318
}
340
}
319
 
341