| Line 3... |
Line 3... |
| 3 |
import in.shop2020.datalogger.EventType;
|
3 |
import in.shop2020.datalogger.EventType;
|
| 4 |
import in.shop2020.model.v1.order.RechargeOrder;
|
4 |
import in.shop2020.model.v1.order.RechargeOrder;
|
| 5 |
import in.shop2020.model.v1.order.RechargeOrderStatus;
|
5 |
import in.shop2020.model.v1.order.RechargeOrderStatus;
|
| 6 |
import in.shop2020.model.v1.order.RechargeType;
|
6 |
import in.shop2020.model.v1.order.RechargeType;
|
| 7 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
7 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 8 |
import in.shop2020.model.v1.user.Affiliate;
|
- |
|
| 9 |
import in.shop2020.model.v1.user.TrackLogType;
|
- |
|
| 10 |
import in.shop2020.model.v1.user.UserAffiliateException;
|
- |
|
| 11 |
import in.shop2020.payments.PaymentException;
|
8 |
import in.shop2020.payments.PaymentException;
|
| 12 |
import in.shop2020.serving.interceptors.TrackingInterceptor;
|
- |
|
| 13 |
import in.shop2020.serving.utils.FormattingUtils;
|
9 |
import in.shop2020.serving.utils.FormattingUtils;
|
| 14 |
import in.shop2020.thrift.clients.PaymentClient;
|
10 |
import in.shop2020.thrift.clients.PaymentClient;
|
| 15 |
import in.shop2020.thrift.clients.TransactionClient;
|
11 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 16 |
import in.shop2020.thrift.clients.UserClient;
|
- |
|
| 17 |
import in.shop2020.utils.DataLogger;
|
12 |
import in.shop2020.utils.DataLogger;
|
| 18 |
|
13 |
|
| 19 |
import java.text.SimpleDateFormat;
|
14 |
import java.text.SimpleDateFormat;
|
| 20 |
import java.util.Date;
|
15 |
import java.util.Date;
|
| - |
|
16 |
import java.util.HashMap;
|
| 21 |
import java.util.Map;
|
17 |
import java.util.Map;
|
| 22 |
|
18 |
|
| 23 |
import org.apache.log4j.Logger;
|
19 |
import org.apache.log4j.Logger;
|
| 24 |
import org.apache.thrift.TException;
|
20 |
import org.apache.thrift.TException;
|
| 25 |
import org.apache.thrift.transport.TTransportException;
|
21 |
import org.apache.thrift.transport.TTransportException;
|
| 26 |
|
22 |
|
| 27 |
public class RechargeResultController extends BaseController {
|
23 |
public class RechargeResultController extends BaseController {
|
| 28 |
private static final long serialVersionUID = 1L;
|
24 |
private static final long serialVersionUID = 1L;
|
| 29 |
|
25 |
|
| 30 |
private static final String SHOOGLOO_AFF_NAME = "shoogloo";
|
26 |
// private static final String SHOOGLOO_AFF_NAME = "shoogloo";
|
| 31 |
|
27 |
|
| 32 |
private static Logger log = Logger.getLogger(Class.class);
|
28 |
private static Logger log = Logger.getLogger(Class.class);
|
| 33 |
private FormattingUtils formattingUtils = new FormattingUtils();
|
29 |
private FormattingUtils formattingUtils = new FormattingUtils();
|
| 34 |
|
30 |
|
| 35 |
private boolean isShooglooAff = false;
|
31 |
//private boolean isShooglooAff = false;
|
| - |
|
32 |
|
| 36 |
private static Map<Long,String> allProviders;
|
33 |
private static Map<Long,String> allProviders;
|
| 37 |
static {
|
34 |
static {
|
| 38 |
try {
|
35 |
try {
|
| 39 |
allProviders = new TransactionClient().getClient().getServiceProviders(RechargeType.DTH, true);
|
36 |
allProviders = new TransactionClient().getClient().getServiceProviders(RechargeType.DTH, true);
|
| 40 |
allProviders.putAll(new TransactionClient().getClient().getServiceProviders(RechargeType.MOBILE, true));
|
37 |
allProviders.putAll(new TransactionClient().getClient().getServiceProviders(RechargeType.MOBILE, true));
|
| Line 44... |
Line 41... |
| 44 |
} catch (TException e) {
|
41 |
} catch (TException e) {
|
| 45 |
// TODO Auto-generated catch block
|
42 |
// TODO Auto-generated catch block
|
| 46 |
e.printStackTrace();
|
43 |
e.printStackTrace();
|
| 47 |
}
|
44 |
}
|
| 48 |
}
|
45 |
}
|
| - |
|
46 |
|
| - |
|
47 |
private static Map<String, String> FailureReasonMap;
|
| - |
|
48 |
static {
|
| - |
|
49 |
FailureReasonMap = new HashMap<String, String>();
|
| - |
|
50 |
FailureReasonMap.put("Invalid Amount", "the amount you tried seems to be invalid. Please try another amount.");
|
| - |
|
51 |
FailureReasonMap.put("Customer Exceeded Daily Limit", "you have exceeded daily recharge limit for this number. Please try after 12 hours.");
|
| - |
|
52 |
FailureReasonMap.put("Invalid Mobile Number", "it seems that your mobile number is not being recognized by selected operator. Please make sure the number you tried is correct.");
|
| - |
|
53 |
}
|
| - |
|
54 |
|
| 49 |
long merchantPaymentId;
|
55 |
long merchantPaymentId;
|
| 50 |
RechargeOrder rechargeOrder = null;
|
56 |
RechargeOrder rechargeOrder = null;
|
| 51 |
String message = null;
|
57 |
String message = null;
|
| 52 |
|
58 |
|
| 53 |
public RechargeResultController(){
|
59 |
public RechargeResultController(){
|
| Line 55... |
Line 61... |
| 55 |
}
|
61 |
}
|
| 56 |
|
62 |
|
| 57 |
public String index() {
|
63 |
public String index() {
|
| 58 |
PaymentClient paymentServiceClient = null;
|
64 |
PaymentClient paymentServiceClient = null;
|
| 59 |
TransactionClient transactionServiceClient = null;
|
65 |
TransactionClient transactionServiceClient = null;
|
| 60 |
UserClient userServiceClient = null;
|
66 |
//UserClient userServiceClient = null;
|
| 61 |
|
67 |
|
| 62 |
try {
|
68 |
try {
|
| 63 |
paymentServiceClient = new PaymentClient();
|
69 |
paymentServiceClient = new PaymentClient();
|
| 64 |
transactionServiceClient = new TransactionClient();
|
70 |
transactionServiceClient = new TransactionClient();
|
| 65 |
userServiceClient = new UserClient();
|
71 |
// userServiceClient = new UserClient();
|
| 66 |
} catch (Exception e1) {
|
72 |
} catch (Exception e1) {
|
| 67 |
// TODO Nothing to worry
|
73 |
// TODO Nothing to worry
|
| 68 |
log.error("Unable to initialize the client for either payment or transaction or user service", e1);
|
74 |
log.error("Unable to initialize the client for either payment or transaction or user service", e1);
|
| 69 |
}
|
75 |
}
|
| 70 |
|
76 |
|
| Line 79... |
Line 85... |
| 79 |
txnId = paymentServiceClient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
|
85 |
txnId = paymentServiceClient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
|
| 80 |
rechargeOrder = transactionServiceClient.getClient().getRechargeOrdersForTransaction(txnId);
|
86 |
rechargeOrder = transactionServiceClient.getClient().getRechargeOrdersForTransaction(txnId);
|
| 81 |
|
87 |
|
| 82 |
this.message = "You have successfully recharged your mobile.";
|
88 |
this.message = "You have successfully recharged your mobile.";
|
| 83 |
|
89 |
|
| 84 |
if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
|
90 |
/*if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
|
| 85 |
long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
|
91 |
long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
|
| 86 |
userServiceClient.getClient().addTrackLog(affId, userinfo.getUserId(), TrackLogType.PAYMENT_SUCCESS, "",
|
92 |
userServiceClient.getClient().addTrackLog(affId, userinfo.getUserId(), TrackLogType.PAYMENT_SUCCESS, "",
|
| 87 |
Long.toString(merchantPaymentId), (new Date()).getTime());
|
93 |
Long.toString(merchantPaymentId), (new Date()).getTime());
|
| 88 |
Affiliate aff = userServiceClient.getClient().getAffiliateById(affId);
|
94 |
Affiliate aff = userServiceClient.getClient().getAffiliateById(affId);
|
| 89 |
if (aff.getName().equals(SHOOGLOO_AFF_NAME)) {
|
95 |
if (aff.getName().equals(SHOOGLOO_AFF_NAME)) {
|
| 90 |
isShooglooAff = true;
|
96 |
isShooglooAff = true;
|
| 91 |
}
|
97 |
}
|
| 92 |
}
|
98 |
}*/
|
| 93 |
|
99 |
|
| 94 |
} catch (PaymentException e) {
|
100 |
} catch (PaymentException e) {
|
| 95 |
log.error("Payment service not responding. Payment id is" + merchantPaymentId, e);
|
101 |
log.error("Payment service not responding. Payment id is" + merchantPaymentId, e);
|
| 96 |
} catch (TException e) {
|
102 |
} catch (TException e) {
|
| 97 |
log.error("Thrift service exception. Payment id is" + merchantPaymentId, e);
|
103 |
log.error("Thrift service exception. Payment id is" + merchantPaymentId, e);
|
| 98 |
} catch (TransactionServiceException e) {
|
104 |
} catch (TransactionServiceException e) {
|
| 99 |
log.error("Transaction service exception. Payment id is" + merchantPaymentId, e);
|
105 |
log.error("Transaction service exception. Payment id is" + merchantPaymentId, e);
|
| 100 |
} catch (UserAffiliateException e) {
|
- |
|
| 101 |
log.error("Affiliate service exception. Payment id is" + merchantPaymentId, e);
|
- |
|
| 102 |
}
|
106 |
}
|
| - |
|
107 |
|
| - |
|
108 |
// catch (UserAffiliateException e) {
|
| - |
|
109 |
// log.error("Affiliate service exception. Payment id is" + merchantPaymentId, e);
|
| - |
|
110 |
// }
|
| 103 |
|
111 |
|
| 104 |
return "index";
|
112 |
return "index";
|
| 105 |
}
|
113 |
}
|
| 106 |
|
114 |
|
| 107 |
public String formatPrice(double price) {
|
115 |
public String formatPrice(double price) {
|
| Line 110... |
Line 118... |
| 110 |
|
118 |
|
| 111 |
public String getMessage(){
|
119 |
public String getMessage(){
|
| 112 |
return this.message;
|
120 |
return this.message;
|
| 113 |
}
|
121 |
}
|
| 114 |
|
122 |
|
| 115 |
public boolean getIsShooglooAff() {
|
123 |
// public boolean getIsShooglooAff() {
|
| 116 |
return this.isShooglooAff;
|
124 |
// return this.isShooglooAff;
|
| 117 |
}
|
125 |
// }
|
| 118 |
|
126 |
|
| 119 |
public long getMerchantPaymentId() {
|
127 |
public long getMerchantPaymentId() {
|
| 120 |
return merchantPaymentId;
|
128 |
return merchantPaymentId;
|
| 121 |
}
|
129 |
}
|
| 122 |
|
130 |
|
| Line 178... |
Line 186... |
| 178 |
}
|
186 |
}
|
| 179 |
else if (status.equals(RechargeOrderStatus.RECHARGE_FAILED)){
|
187 |
else if (status.equals(RechargeOrderStatus.RECHARGE_FAILED)){
|
| 180 |
DataLogger.logData(EventType.RECHARGE_PAYMENT_SUCCESSFUL, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
|
188 |
DataLogger.logData(EventType.RECHARGE_PAYMENT_SUCCESSFUL, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
|
| 181 |
Long.toString(rechargeOrder.getOperatorId()), Long.toString(rechargeOrder.getTotalAmount()), Long.toString(rechargeOrder.getWalletAmount()),
|
189 |
Long.toString(rechargeOrder.getOperatorId()), Long.toString(rechargeOrder.getTotalAmount()), Long.toString(rechargeOrder.getWalletAmount()),
|
| 182 |
rechargeOrder.getRechargeType().toString());
|
190 |
rechargeOrder.getRechargeType().toString());
|
| - |
|
191 |
String displayReason = FailureReasonMap.get(rechargeOrder.getDescription());
|
| - |
|
192 |
if (!(displayReason == null || displayReason.isEmpty())) {
|
| - |
|
193 |
displayReason = "Your Payment was successful but unfortunately the recharge failed because " + displayReason + "<br>";
|
| - |
|
194 |
} else {
|
| 183 |
return new String[]{"red", "RECHARGE FAILED", "Your Payment was successful but unfortunately the recharge failed.<br>" +
|
195 |
displayReason = "Your Payment was successful but unfortunately the recharge failed.<br>";
|
| - |
|
196 |
}
|
| - |
|
197 |
return new String[]{"red", "RECHARGE FAILED", displayReason +
|
| 184 |
"Don't worry your payment is safe with us. The entire Amount has been refunded to your " +
|
198 |
"Don't worry your payment is safe with us. The entire Amount has been refunded to your " +
|
| 185 |
"<a href='/my-wallet'>recharge wallet</a>.<br><br> You " +
|
199 |
"<a href='/my-wallet'>recharge wallet</a>.<br><br> You " +
|
| 186 |
"will need to <a href='/login?redirectUrl=/recharge'>login</a> to use your Wallet.<br> If you are registered on" +
|
200 |
"will need to <a href='/login?redirectUrl=/recharge'>login</a> to use your Wallet.<br> If you are registered on" +
|
| 187 |
" Saholic.com please use your username and password to Login.<br> In case you are " +
|
201 |
" Saholic.com please use your username and password to Login.<br> In case you are " +
|
| 188 |
"a first time user, we have sent your login details on the emailId you gave us. " +
|
202 |
"a first time user, we have sent your login details on the emailId you gave us. " +
|