| Line 84... |
Line 84... |
| 84 |
|
84 |
|
| 85 |
String merchantPaymentId = request.getParameter("paymentid");
|
85 |
String merchantPaymentId = request.getParameter("paymentid");
|
| 86 |
long txnId = Long.parseLong(request.getParameter("txnid"));
|
86 |
long txnId = Long.parseLong(request.getParameter("txnid"));
|
| 87 |
|
87 |
|
| 88 |
if(merchantPaymentId == null){
|
88 |
if(merchantPaymentId == null){
|
| 89 |
addActionError("We are experiencing problem. Please try later.");
|
89 |
addActionError("We are experiencing some problems. Please try later.");
|
| 90 |
log.error("Merchant payment is null. It should not have reached here.");
|
90 |
log.error("Merchant payment is null. It should not have reached here.");
|
| 91 |
return "shipping-redirect";
|
91 |
return "shipping-redirect";
|
| 92 |
}
|
92 |
}
|
| 93 |
|
93 |
|
| 94 |
PaymentServiceClient paymentServiceClient = null;
|
94 |
PaymentServiceClient paymentServiceClient = null;
|
| Line 99... |
Line 99... |
| 99 |
}
|
99 |
}
|
| 100 |
|
100 |
|
| 101 |
try {
|
101 |
try {
|
| 102 |
initializePayment(merchantPaymentId);
|
102 |
initializePayment(merchantPaymentId);
|
| 103 |
} catch (ShoppingCartException e1) {
|
103 |
} catch (ShoppingCartException e1) {
|
| 104 |
addActionError("We are experiencing problem. Please try later.");
|
104 |
addActionError("We are experiencing some problems. Please try later.");
|
| 105 |
log.error("Error while creating hdfc payment.");
|
105 |
log.error("Error while creating hdfc payment.");
|
| 106 |
e1.printStackTrace();
|
106 |
e1.printStackTrace();
|
| 107 |
return "shipping-redirect";
|
107 |
return "shipping-redirect";
|
| 108 |
} catch (TException e1) {
|
108 |
} catch (TException e1) {
|
| 109 |
addActionError("We are experiencing problem. Please try later.");
|
109 |
addActionError("We are experiencing some problems. Please try later.");
|
| 110 |
log.error("Error while creating hdfc payment.");
|
110 |
log.error("Error while creating hdfc payment.");
|
| 111 |
e1.printStackTrace();
|
111 |
e1.printStackTrace();
|
| 112 |
return "shipping-redirect";
|
112 |
return "shipping-redirect";
|
| 113 |
}
|
113 |
}
|
| 114 |
|
114 |
|
| 115 |
List<Attribute> attributes = null;
|
115 |
List<Attribute> attributes = null;
|
| 116 |
try {
|
116 |
try {
|
| 117 |
attributes = getAttributesAndSetUdfs(txnId);
|
117 |
attributes = getAttributesAndSetUdfs(txnId);
|
| 118 |
} catch (TransactionServiceException e1) {
|
118 |
} catch (TransactionServiceException e1) {
|
| 119 |
addActionError("We are experiencing problem. Please try later.");
|
119 |
addActionError("We are experiencing some problems. Please try later.");
|
| 120 |
log.error("Error while setting udfs to payment.");
|
120 |
log.error("Error while setting udfs to payment.");
|
| 121 |
e1.printStackTrace();
|
121 |
e1.printStackTrace();
|
| 122 |
return "shipping-redirect";
|
122 |
return "shipping-redirect";
|
| 123 |
} catch (TException e1) {
|
123 |
} catch (TException e1) {
|
| 124 |
addActionError("We are experiencing problem. Please try later.");
|
124 |
addActionError("We are experiencing some problems. Please try later.");
|
| 125 |
log.error("Error while setting udfs to payment.");
|
125 |
log.error("Error while setting udfs to payment.");
|
| 126 |
e1.printStackTrace();
|
126 |
e1.printStackTrace();
|
| 127 |
return "shipping-redirect";
|
127 |
return "shipping-redirect";
|
| 128 |
}
|
128 |
}
|
| 129 |
|
129 |
|
| 130 |
|
130 |
|
| 131 |
try {
|
131 |
try {
|
| 132 |
if(pipe.performPaymentInitialization() != e24PaymentPipe.SUCCESS)
|
132 |
if(pipe.performPaymentInitialization() != e24PaymentPipe.SUCCESS)
|
| 133 |
{
|
133 |
{
|
| 134 |
System.out.println("Error sending Payment Initialization Request: ");
|
134 |
System.out.println("Error sending Payment Initialization Request: ");
|
| 135 |
paymentServiceClient.getClient().updatePaymentDetails(Long.parseLong(merchantPaymentId), null, "", "", pipe.getErrorMsg(), "", "", "", "", PaymentStatus.INIT, attributes);
|
135 |
paymentServiceClient.getClient().updatePaymentDetails(Long.parseLong(merchantPaymentId), null, "", "", pipe.getErrorMsg(), "", "", "", "", PaymentStatus.INIT, "", attributes);
|
| 136 |
response.sendRedirect(response.encodeRedirectURL( errorURL + "?ErrorText="+pipe.getErrorMsg()+"&paymentId="+merchantPaymentId));
|
136 |
response.sendRedirect(response.encodeRedirectURL( errorURL + "?ErrorText="+pipe.getErrorMsg()+"&paymentId="+merchantPaymentId));
|
| 137 |
redirectURL = errorURL + "?paymentId="+merchantPaymentId + "&ErrorText="+pipe.getErrorMsg();
|
137 |
redirectURL = errorURL + "?paymentId="+merchantPaymentId + "&ErrorText="+pipe.getErrorMsg();
|
| 138 |
response.setHeader("Location", redirectURL);
|
138 |
response.setHeader("Location", redirectURL);
|
| 139 |
response.setStatus(HttpServletResponse.SC_FOUND);
|
139 |
response.setStatus(HttpServletResponse.SC_FOUND);
|
| 140 |
}
|
140 |
}
|
| 141 |
else
|
141 |
else
|
| 142 |
{
|
142 |
{
|
| 143 |
String paymentID = pipe.getPaymentId();
|
143 |
String paymentID = pipe.getPaymentId();
|
| 144 |
// Update of payment information
|
144 |
// Update of payment information
|
| 145 |
paymentServiceClient.getClient().updatePaymentDetails(Long.parseLong(merchantPaymentId), paymentID, "", "", "", "", "", "", "", PaymentStatus.INIT, attributes);
|
145 |
paymentServiceClient.getClient().updatePaymentDetails(Long.parseLong(merchantPaymentId), paymentID, "", "", "", "", "", "", "", PaymentStatus.INIT, "", attributes);
|
| 146 |
|
146 |
|
| 147 |
String payURL = pipe.getPaymentPage();
|
147 |
String payURL = pipe.getPaymentPage();
|
| 148 |
redirectURL = payURL + "?PaymentID=" + paymentID;
|
148 |
redirectURL = payURL + "?PaymentID=" + paymentID;
|
| 149 |
response.sendRedirect(response.encodeRedirectURL( redirectURL ));
|
149 |
response.sendRedirect(response.encodeRedirectURL( redirectURL ));
|
| 150 |
|
150 |
|
| Line 247... |
Line 247... |
| 247 |
}
|
247 |
}
|
| 248 |
|
248 |
|
| 249 |
Random random = new Random();
|
249 |
Random random = new Random();
|
| 250 |
String merchantInfo = ""+random.nextLong();
|
250 |
String merchantInfo = ""+random.nextLong();
|
| 251 |
|
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());
|
252 |
String udf1 = formatUdf(orderDetails.toString());
|
| 259 |
String udf2 = formatUdf(email);
|
253 |
String udf2 = formatUdf(email);
|
| 260 |
String udf3 = formatUdf(contactNumber);
|
254 |
String udf3 = formatUdf(contactNumber);
|
| 261 |
String udf4 = formatUdf(billingAddress.toString());
|
255 |
String udf4 = formatUdf(billingAddress.toString());
|
| 262 |
String udf5 = merchantInfo;
|
256 |
String udf5 = merchantInfo;
|
| - |
|
257 |
|
| - |
|
258 |
log.info("udf1:" + udf1);
|
| - |
|
259 |
log.info("udf2:" + udf2);
|
| - |
|
260 |
log.info("udf3:" + udf3);
|
| - |
|
261 |
log.info("udf4:" + udf4);
|
| - |
|
262 |
log.info("udf5:" + udf5);
|
| 263 |
|
263 |
|
| - |
|
264 |
|
| 264 |
pipe.setUdf1(udf1); // UDF 1 - Order details
|
265 |
pipe.setUdf1(udf1); // UDF 1 - Order details
|
| 265 |
pipe.setUdf2(udf2); // UDF 2 - Email ID
|
266 |
pipe.setUdf2(udf2); // UDF 2 - Email ID
|
| 266 |
pipe.setUdf3(udf3); // UDF 3 - Contact Number.
|
267 |
pipe.setUdf3(udf3); // UDF 3 - Contact Number.
|
| 267 |
pipe.setUdf4(udf4); // UDF 4 - Billing Address
|
268 |
pipe.setUdf4(udf4); // UDF 4 - Billing Address
|
| 268 |
pipe.setUdf5(udf5); // UDF 5 - Merchant specific
|
269 |
pipe.setUdf5(udf5); // UDF 5 - Merchant specific
|
| Line 292... |
Line 293... |
| 292 |
|
293 |
|
| 293 |
//Following is the code which initilize e24PaymentPipe with proper value
|
294 |
//Following is the code which initilize e24PaymentPipe with proper value
|
| 294 |
pipe=new e24PaymentPipe();
|
295 |
pipe=new e24PaymentPipe();
|
| 295 |
pipe.setResourcePath(resourceFilePath); //mandatory
|
296 |
pipe.setResourcePath(resourceFilePath); //mandatory
|
| 296 |
String as = pipe.getResourcePath();
|
297 |
String as = pipe.getResourcePath();
|
| 297 |
log.info("Resource="+as+ "<br>");
|
298 |
log.info("Resource= " +as);
|
| 298 |
|
299 |
|
| 299 |
pipe.setAlias(aliasName); //mandatory
|
300 |
pipe.setAlias(aliasName); //mandatory
|
| 300 |
String ab=pipe.getAlias();
|
301 |
String ab=pipe.getAlias();
|
| 301 |
log.info("Alias="+ab+ "<br>");
|
302 |
log.info("Alias= " +ab);
|
| 302 |
|
303 |
|
| 303 |
pipe.setAction(ActionType.PURCHASE.value()); //mandatory
|
304 |
pipe.setAction(ActionType.PURCHASE.value()); //mandatory
|
| 304 |
String ac=pipe.getAction();
|
305 |
String ac=pipe.getAction();
|
| 305 |
log.info("Action="+ac+ "<br>");
|
306 |
log.info("Action= " +ac);
|
| 306 |
|
307 |
|
| 307 |
pipe.setResponseURL( responseURL ); //mandatory
|
308 |
pipe.setResponseURL( responseURL ); //mandatory
|
| 308 |
String at=pipe.getResponseURL();
|
309 |
String at=pipe.getResponseURL();
|
| 309 |
log.info("ResponseURL="+at+ "<br>");
|
310 |
log.info("ResponseURL= "+at);
|
| 310 |
|
311 |
|
| 311 |
//pipe.setErrorURL( errorURL + "?paymentId=" + merchantPaymentId ); //mandatory
|
312 |
//pipe.setErrorURL( errorURL + "?paymentId=" + merchantPaymentId ); //mandatory
|
| 312 |
pipe.setErrorURL( errorURL);
|
313 |
pipe.setErrorURL( errorURL);
|
| 313 |
String ak=pipe.getErrorURL();
|
314 |
String ak=pipe.getErrorURL();
|
| 314 |
log.info("ErrorURL="+ak+ "<br>");
|
315 |
log.info("ErrorURL= " + ak);
|
| 315 |
|
316 |
|
| 316 |
|
317 |
|
| 317 |
pipe.setAmt(amount);
|
318 |
pipe.setAmt(amount);
|
| 318 |
String ap=pipe.getAmt();
|
319 |
String ap=pipe.getAmt();
|
| 319 |
log.info("Amt="+ap);
|
320 |
log.info("Amt= " + ap);
|
| 320 |
|
321 |
|
| 321 |
pipe.setCurrency("356");
|
322 |
pipe.setCurrency("356");
|
| 322 |
String a=pipe.getCurrency();
|
323 |
String a=pipe.getCurrency();
|
| 323 |
log.info("Currency="+a+ "<br>");
|
324 |
log.info("Currency= " + a);
|
| 324 |
|
325 |
|
| 325 |
pipe.setLanguage("USA");
|
326 |
pipe.setLanguage("USA");
|
| 326 |
String p=pipe.getLanguage();
|
327 |
String p=pipe.getLanguage();
|
| 327 |
log.info("Language="+p+ "<br>");
|
328 |
log.info("Language= "+ p);
|
| 328 |
|
329 |
|
| 329 |
pipe.setTrackId(merchantPaymentId);
|
330 |
pipe.setTrackId(merchantPaymentId);
|
| 330 |
|
331 |
|
| 331 |
}
|
332 |
}
|
| 332 |
|
333 |
|
| 333 |
String formatUdf(String udfString){
|
334 |
String formatUdf(String udfString){
|
| 334 |
udfString.replaceAll(regex, replacement);
|
335 |
udfString = udfString.replaceAll(regex, replacement);
|
| 335 |
if(udfString.length() > MAX_UDF_LENGTH){
|
336 |
if(udfString.length() > MAX_UDF_LENGTH){
|
| 336 |
udfString = udfString.substring(0, MAX_UDF_LENGTH);
|
337 |
udfString = udfString.substring(0, MAX_UDF_LENGTH);
|
| 337 |
}
|
338 |
}
|
| 338 |
return udfString;
|
339 |
return udfString;
|
| 339 |
}
|
340 |
}
|