| Line 41... |
Line 41... |
| 41 |
|
41 |
|
| 42 |
private static Logger log = Logger.getLogger(HdfcPaymentHandler.class);
|
42 |
private static Logger log = Logger.getLogger(HdfcPaymentHandler.class);
|
| 43 |
|
43 |
|
| 44 |
private static String aliasName;
|
44 |
private static String aliasName;
|
| 45 |
private static String responseURL;
|
45 |
private static String responseURL;
|
| - |
|
46 |
private static String mResponseURL;
|
| 46 |
private static String errorURL;
|
47 |
private static String errorURL;
|
| - |
|
48 |
private static String mErrorURL;
|
| 47 |
private static final String regex = "[^a-zA-Z0-9\\s\\-\\@\\/\\.]";
|
49 |
private static final String regex = "[^a-zA-Z0-9\\s\\-\\@\\/\\.]";
|
| 48 |
private static final String replacement = " ";
|
50 |
private static final String replacement = " ";
|
| 49 |
private static final int MAX_UDF_LENGTH = 30;
|
51 |
private static final int MAX_UDF_LENGTH = 30;
|
| 50 |
private static final String currencyCode = "356";
|
52 |
private static final String currencyCode = "356";
|
| 51 |
private static String resourceDirPath = "/tmp/resource/";
|
53 |
private static String resourceDirPath = "/tmp/resource/";
|
| 52 |
|
54 |
|
| 53 |
private static String responseURLforRecharge;
|
55 |
private static String responseURLforRecharge;
|
| - |
|
56 |
private static String mResponseURLforRecharge;
|
| 54 |
|
57 |
|
| 55 |
private static String errorURLforRecharge;
|
58 |
private static String errorURLforRecharge;
|
| - |
|
59 |
private static String mErrorURLforRecharge;
|
| 56 |
private static final String resourceFileName = "resource.cgn";
|
60 |
private static final String resourceFileName = "resource.cgn";
|
| 57 |
|
61 |
|
| 58 |
private enum ActionType{
|
62 |
private enum ActionType{
|
| 59 |
PURCHASE("1"),
|
63 |
PURCHASE("1"),
|
| 60 |
REFUND("2"),
|
64 |
REFUND("2"),
|
| Line 90... |
Line 94... |
| 90 |
outStream.close();
|
94 |
outStream.close();
|
| 91 |
inputStream.close();
|
95 |
inputStream.close();
|
| 92 |
|
96 |
|
| 93 |
aliasName = ConfigClient.getClient().get("payment_alias_name");
|
97 |
aliasName = ConfigClient.getClient().get("payment_alias_name");
|
| 94 |
responseURL = ConfigClient.getClient().get("payment_response_url");
|
98 |
responseURL = ConfigClient.getClient().get("payment_response_url");
|
| - |
|
99 |
mResponseURL = ConfigClient.getClient().get("m_payment_response_url");
|
| 95 |
errorURL = ConfigClient.getClient().get("payment_error_url");
|
100 |
errorURL = ConfigClient.getClient().get("payment_error_url");
|
| - |
|
101 |
mErrorURL = ConfigClient.getClient().get("m_payment_error_url");
|
| 96 |
responseURLforRecharge = ConfigClient.getClient().get("payment_response_url_for_recharge");
|
102 |
responseURLforRecharge = ConfigClient.getClient().get("payment_response_url_for_recharge");
|
| - |
|
103 |
mResponseURLforRecharge = ConfigClient.getClient().get("m_payment_response_url_for_recharge");
|
| 97 |
errorURLforRecharge = ConfigClient.getClient().get("recharge_success_url");
|
104 |
errorURLforRecharge = ConfigClient.getClient().get("recharge_success_url");
|
| - |
|
105 |
mErrorURLforRecharge = ConfigClient.getClient().get("m_recharge_success_url");
|
| 98 |
} catch (ConfigException e) {
|
106 |
} catch (ConfigException e) {
|
| 99 |
log.error("Unable to get data from config server.");
|
107 |
log.error("Unable to get data from config server.");
|
| 100 |
} catch (FileNotFoundException e) {
|
108 |
} catch (FileNotFoundException e) {
|
| 101 |
// TODO Auto-generated catch block
|
109 |
// TODO Auto-generated catch block
|
| 102 |
e.printStackTrace();
|
110 |
e.printStackTrace();
|
| Line 293... |
Line 301... |
| 293 |
log.error(Errors.CAPTURE_FAILURE.message, e);
|
301 |
log.error(Errors.CAPTURE_FAILURE.message, e);
|
| 294 |
}
|
302 |
}
|
| 295 |
return PaymentStatus.INIT;
|
303 |
return PaymentStatus.INIT;
|
| 296 |
}
|
304 |
}
|
| 297 |
|
305 |
|
| 298 |
public static String initializeHdfcPayment(Payment payment, PaymentServiceHandler handler) throws Exception{
|
306 |
public static String initializeHdfcPayment(Payment payment, PaymentServiceHandler handler, boolean isMobile) throws Exception{
|
| 299 |
long merchantPaymentId = payment.getId();
|
307 |
long merchantPaymentId = payment.getId();
|
| 300 |
double amount = payment.getAmount();
|
308 |
double amount = payment.getAmount();
|
| 301 |
e24PaymentPipe pipe = new e24PaymentPipe();
|
309 |
e24PaymentPipe pipe = new e24PaymentPipe();
|
| 302 |
|
310 |
|
| 303 |
try {
|
311 |
try {
|
| 304 |
initializePayment(pipe, merchantPaymentId, amount, false);
|
312 |
initializePayment(pipe, merchantPaymentId, amount, false, isMobile);
|
| 305 |
} catch (ShoppingCartException e1) {
|
313 |
} catch (ShoppingCartException e1) {
|
| 306 |
log.error("Error while creating hdfc payment.", e1);
|
314 |
log.error("Error while creating hdfc payment.", e1);
|
| 307 |
throw e1; //Payment couldn't be initialized. Will be redirected to the shipping page.
|
315 |
throw e1; //Payment couldn't be initialized. Will be redirected to the shipping page.
|
| 308 |
} catch (TException e1) {
|
316 |
} catch (TException e1) {
|
| 309 |
log.error("Error while creating hdfc payment.", e1);
|
317 |
log.error("Error while creating hdfc payment.", e1);
|
| Line 436... |
Line 444... |
| 436 |
attributes.add(attribute5);
|
444 |
attributes.add(attribute5);
|
| 437 |
|
445 |
|
| 438 |
return attributes;
|
446 |
return attributes;
|
| 439 |
}
|
447 |
}
|
| 440 |
|
448 |
|
| 441 |
private static void initializePayment(e24PaymentPipe pipe, long merchantPaymentId, double amounta, boolean isDigital) throws ShoppingCartException, TException{
|
449 |
private static void initializePayment(e24PaymentPipe pipe, long merchantPaymentId, double amounta, boolean isDigital, boolean isMobile) throws ShoppingCartException, TException{
|
| 442 |
String amount = (new Double(amounta)).toString();
|
450 |
String amount = (new Double(amounta)).toString();
|
| 443 |
|
451 |
|
| 444 |
//Following is the code which initilize e24PaymentPipe with proper value
|
452 |
//Following is the code which initilize e24PaymentPipe with proper value
|
| 445 |
pipe.setResourcePath(resourceDirPath); //mandatory
|
453 |
pipe.setResourcePath(resourceDirPath); //mandatory
|
| 446 |
String as = pipe.getResourcePath();
|
454 |
String as = pipe.getResourcePath();
|
| Line 453... |
Line 461... |
| 453 |
|
461 |
|
| 454 |
String ac=pipe.getAction();
|
462 |
String ac=pipe.getAction();
|
| 455 |
log.info("Action= " +ac);
|
463 |
log.info("Action= " +ac);
|
| 456 |
|
464 |
|
| 457 |
if(isDigital) {
|
465 |
if(isDigital) {
|
| 458 |
pipe.setAction(ActionType.PURCHASE.value()); //mandatory
|
466 |
pipe.setAction(ActionType.PURCHASE.value()); //mandatory
|
| - |
|
467 |
if(isMobile) {
|
| - |
|
468 |
pipe.setResponseURL(mResponseURLforRecharge);
|
| - |
|
469 |
pipe.setErrorURL(mErrorURLforRecharge);
|
| - |
|
470 |
} else {
|
| 459 |
pipe.setResponseURL( responseURLforRecharge ); //mandatory
|
471 |
pipe.setResponseURL( responseURLforRecharge ); //mandatory
|
| 460 |
pipe.setErrorURL( errorURLforRecharge); //mandatory
|
472 |
pipe.setErrorURL( errorURLforRecharge); //mandatory
|
| - |
|
473 |
}
|
| 461 |
} else {
|
474 |
} else {
|
| 462 |
pipe.setAction(ActionType.AUTH.value()); //mandatory
|
475 |
pipe.setAction(ActionType.AUTH.value());//mandatory
|
| - |
|
476 |
if(isMobile) {
|
| - |
|
477 |
pipe.setResponseURL(mResponseURL);
|
| - |
|
478 |
pipe.setErrorURL( mErrorURL);
|
| - |
|
479 |
} else {
|
| 463 |
pipe.setResponseURL( responseURL );
|
480 |
pipe.setResponseURL( responseURL );
|
| 464 |
pipe.setErrorURL( errorURL);
|
481 |
pipe.setErrorURL( errorURL);
|
| - |
|
482 |
}
|
| 465 |
}
|
483 |
}
|
| 466 |
String at=pipe.getResponseURL();
|
484 |
String at=pipe.getResponseURL();
|
| 467 |
log.info("ResponseURL= "+at);
|
485 |
log.info("ResponseURL= "+at);
|
| 468 |
|
486 |
|
| 469 |
//pipe.setErrorURL( errorURL + "?paymentId=" + merchantPaymentId ); //mandatory
|
487 |
//pipe.setErrorURL( errorURL + "?paymentId=" + merchantPaymentId ); //mandatory
|
| Line 493... |
Line 511... |
| 493 |
}
|
511 |
}
|
| 494 |
return udfString;
|
512 |
return udfString;
|
| 495 |
}
|
513 |
}
|
| 496 |
|
514 |
|
| 497 |
public static String initializeHdfcPayment(in.shop2020.payment.domain.Payment payment, RechargeOrder rechargeOrder,
|
515 |
public static String initializeHdfcPayment(in.shop2020.payment.domain.Payment payment, RechargeOrder rechargeOrder,
|
| 498 |
String phone, PaymentServiceHandler paymentServiceHandler) throws Exception {
|
516 |
String phone, PaymentServiceHandler paymentServiceHandler, boolean isMobile) throws Exception {
|
| 499 |
Long merchantPaymentId = payment.getId();
|
517 |
Long merchantPaymentId = payment.getId();
|
| 500 |
double amount = payment.getAmount();
|
518 |
double amount = payment.getAmount();
|
| 501 |
e24PaymentPipe pipe = new e24PaymentPipe();
|
519 |
e24PaymentPipe pipe = new e24PaymentPipe();
|
| 502 |
|
520 |
|
| 503 |
try {
|
521 |
try {
|
| 504 |
initializePayment(pipe, merchantPaymentId, amount, true);
|
522 |
initializePayment(pipe, merchantPaymentId, amount, true, isMobile);
|
| 505 |
} catch (ShoppingCartException e1) {
|
523 |
} catch (ShoppingCartException e1) {
|
| 506 |
log.error("Error while creating hdfc payment.", e1);
|
524 |
log.error("Error while creating hdfc payment.", e1);
|
| 507 |
throw e1; //Payment couldn't be initialized. Will be redirected to the shipping page.
|
525 |
throw e1; //Payment couldn't be initialized. Will be redirected to the shipping page.
|
| 508 |
} catch (TException e1) {
|
526 |
} catch (TException e1) {
|
| 509 |
log.error("Error while creating hdfc payment.", e1);
|
527 |
log.error("Error while creating hdfc payment.", e1);
|