| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.controllers;
|
1 |
package in.shop2020.serving.controllers;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.config.ConfigException;
|
| 3 |
import in.shop2020.model.v1.order.LineItem;
|
4 |
import in.shop2020.model.v1.order.LineItem;
|
| 4 |
import in.shop2020.model.v1.order.Order;
|
5 |
import in.shop2020.model.v1.order.Order;
|
| 5 |
import in.shop2020.model.v1.order.Transaction;
|
6 |
import in.shop2020.model.v1.order.Transaction;
|
| 6 |
import in.shop2020.model.v1.order.TransactionStatus;
|
7 |
import in.shop2020.model.v1.order.TransactionStatus;
|
| - |
|
8 |
import in.shop2020.payments.Payment;
|
| - |
|
9 |
import in.shop2020.payments.PaymentException;
|
| 7 |
import in.shop2020.payments.PaymentStatus;
|
10 |
import in.shop2020.payments.PaymentStatus;
|
| 8 |
import in.shop2020.thrift.clients.PaymentServiceClient;
|
11 |
import in.shop2020.thrift.clients.PaymentServiceClient;
|
| 9 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
12 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
| 10 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
13 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
| 11 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
14 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| Line 20... |
Line 23... |
| 20 |
|
23 |
|
| 21 |
import org.apache.juli.logging.Log;
|
24 |
import org.apache.juli.logging.Log;
|
| 22 |
import org.apache.juli.logging.LogFactory;
|
25 |
import org.apache.juli.logging.LogFactory;
|
| 23 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
26 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
| 24 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
27 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
| - |
|
28 |
import org.apache.thrift.TException;
|
| 25 |
|
29 |
|
| 26 |
public class HdfcPayResponseController implements ServletResponseAware, ServletRequestAware{
|
30 |
public class HdfcPayResponseController implements ServletResponseAware, ServletRequestAware{
|
| 27 |
private static final long serialVersionUID = 1L;
|
31 |
private static final long serialVersionUID = 1L;
|
| 28 |
|
32 |
|
| 29 |
private enum PaymentReturnStatus{
|
33 |
private enum PaymentReturnStatus{
|
| Line 100... |
Line 104... |
| 100 |
merchantPaymentId = Long.parseLong(trackId);
|
104 |
merchantPaymentId = Long.parseLong(trackId);
|
| 101 |
sessionId = this.request.getSession().getId();
|
105 |
sessionId = this.request.getSession().getId();
|
| 102 |
errorNo = request.getParameter(ERROR);
|
106 |
errorNo = request.getParameter(ERROR);
|
| 103 |
errorText = request.getParameter(ERRORTEXT);
|
107 |
errorText = request.getParameter(ERRORTEXT);
|
| 104 |
//FIXME dump them somewhere
|
108 |
//FIXME dump them somewhere
|
| - |
|
109 |
/*
|
| 105 |
String udf1=request.getParameter("udf1");
|
110 |
String udf1=request.getParameter("udf1");
|
| 106 |
String udf2=request.getParameter("udf2");
|
111 |
String udf2=request.getParameter("udf2");
|
| 107 |
String udf3=request.getParameter("udf3");
|
112 |
String udf3=request.getParameter("udf3");
|
| 108 |
String udf4=request.getParameter("udf4");
|
113 |
String udf4=request.getParameter("udf4");
|
| - |
|
114 |
*/
|
| 109 |
String udf5=request.getParameter("udf5");
|
115 |
String udf5=request.getParameter("udf5");
|
| 110 |
|
116 |
|
| 111 |
|
117 |
|
| - |
|
118 |
Payment payment = null;
|
| - |
|
119 |
try {
|
| - |
|
120 |
payment = pclient.getClient().getPayment(merchantPaymentId);
|
| - |
|
121 |
if(Long.parseLong(paymentId) != payment.getPaymentId() && udf5.compareToIgnoreCase(payment.getAttributes().get(5).getValue())!=0){
|
| - |
|
122 |
this.redirectUrl = ConfigClient.getClient().get("payment_error_url") + "?paymentId="+merchantPaymentId;
|
| - |
|
123 |
return "index";
|
| - |
|
124 |
}
|
| - |
|
125 |
} catch (PaymentException e1) {
|
| - |
|
126 |
// TODO Auto-generated catch block
|
| - |
|
127 |
e1.printStackTrace();
|
| - |
|
128 |
} catch (TException e1) {
|
| - |
|
129 |
// TODO Auto-generated catch block
|
| - |
|
130 |
e1.printStackTrace();
|
| - |
|
131 |
} catch (ConfigException e) {
|
| - |
|
132 |
this.redirectUrl = "http://173.230.147.250:8080/pay-error?paymentId="+merchantPaymentId;
|
| - |
|
133 |
e.printStackTrace();
|
| - |
|
134 |
return "index";
|
| - |
|
135 |
}
|
| 112 |
|
136 |
|
| 113 |
if(result.trim().equals(PaymentReturnStatus.CAPTURED.value())){
|
137 |
if(result.trim().equals(PaymentReturnStatus.CAPTURED.value())){
|
| 114 |
try {
|
138 |
try {
|
| 115 |
String message = "Payment successful";
|
139 |
String message = "Payment successful";
|
| - |
|
140 |
|
| - |
|
141 |
|
| 116 |
pclient.getClient().updatePaymentDetails(merchantPaymentId, paymentId, sessionId, result, message, tranId, auth, ref, errorNo, PaymentStatus.SUCCESS, null);
|
142 |
pclient.getClient().updatePaymentDetails(merchantPaymentId, paymentId, sessionId, result, message, tranId, auth, ref, errorNo, PaymentStatus.SUCCESS, null);
|
| 117 |
txnId = pclient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
|
143 |
txnId = pclient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
|
| 118 |
|
144 |
|
| 119 |
tsc.getClient().changeTransactionStatus(txnId, TransactionStatus.IN_PROCESS, "Payment received for the order");
|
145 |
tsc.getClient().changeTransactionStatus(txnId, TransactionStatus.IN_PROCESS, "Payment received for the order");
|
| 120 |
|
146 |
|