| 6050 |
anupam.sin |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
| 6091 |
anupam.sin |
3 |
import in.shop2020.datalogger.EventType;
|
| 6050 |
anupam.sin |
4 |
import in.shop2020.model.v1.order.OrderType;
|
|
|
5 |
import in.shop2020.model.v1.order.RechargeCoupon;
|
|
|
6 |
import in.shop2020.model.v1.order.RechargeOrder;
|
|
|
7 |
import in.shop2020.model.v1.order.RechargeOrderStatus;
|
| 6397 |
anupam.sin |
8 |
import in.shop2020.model.v1.order.RechargePlan;
|
| 6050 |
anupam.sin |
9 |
import in.shop2020.model.v1.order.RechargeType;
|
| 6057 |
anupam.sin |
10 |
import in.shop2020.model.v1.order.UserWallet;
|
| 6050 |
anupam.sin |
11 |
import in.shop2020.model.v1.user.User;
|
|
|
12 |
import in.shop2020.model.v1.user.UserContextException;
|
|
|
13 |
import in.shop2020.serving.utils.DesEncrypter;
|
|
|
14 |
import in.shop2020.serving.utils.Utils;
|
|
|
15 |
import in.shop2020.thrift.clients.HelperClient;
|
| 6433 |
anupam.sin |
16 |
import in.shop2020.thrift.clients.PromotionClient;
|
| 6050 |
anupam.sin |
17 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
18 |
import in.shop2020.thrift.clients.UserClient;
|
| 6228 |
anupam.sin |
19 |
import in.shop2020.utils.DataLogger;
|
| 6091 |
anupam.sin |
20 |
import in.shop2020.utils.Mail;
|
| 6050 |
anupam.sin |
21 |
|
| 6495 |
anupam.sin |
22 |
import java.math.BigInteger;
|
| 6050 |
anupam.sin |
23 |
import java.util.ArrayList;
|
| 6433 |
anupam.sin |
24 |
import java.util.HashMap;
|
| 6050 |
anupam.sin |
25 |
import java.util.List;
|
| 6433 |
anupam.sin |
26 |
import java.util.Map;
|
| 6091 |
anupam.sin |
27 |
import java.util.Random;
|
| 6050 |
anupam.sin |
28 |
|
| 6495 |
anupam.sin |
29 |
import javax.mail.internet.AddressException;
|
|
|
30 |
import javax.mail.internet.InternetAddress;
|
| 6601 |
anupam.sin |
31 |
import javax.servlet.http.HttpServletRequest;
|
| 6495 |
anupam.sin |
32 |
|
| 6249 |
anupam.sin |
33 |
import nl.captcha.Captcha;
|
|
|
34 |
|
| 6050 |
anupam.sin |
35 |
import org.apache.log4j.Logger;
|
|
|
36 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
37 |
import org.apache.struts2.convention.annotation.Results;
|
|
|
38 |
import org.apache.thrift.TException;
|
|
|
39 |
import org.apache.thrift.transport.TTransportException;
|
|
|
40 |
|
|
|
41 |
@Results({
|
| 6228 |
anupam.sin |
42 |
@Result(name="recharge-pay-options-redirect", type="redirectAction", params = {"actionName" , "recharge-pay-options", "rechargeOrderId", "${rechargeOrderId}"}),
|
| 6103 |
amit.gupta |
43 |
@Result(name="create-recharge-redirect", type="redirectAction", params = {"actionName" , "wallet-only-payment", "rechargeOrderId", "${rechargeOrderId}"}),
|
| 6730 |
anupam.sin |
44 |
@Result(name="recharge-redirect", type="redirectAction", params = {"actionName" , "recharge", "error", "${errorMessage}"}),
|
|
|
45 |
@Result(name="login-redirect", type="redirectAction", params = {"actionName", "login", "redirectUrl", "recharge"})
|
| 6050 |
anupam.sin |
46 |
})
|
|
|
47 |
|
|
|
48 |
public class ConfirmController extends BaseController{
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
*
|
|
|
52 |
*/
|
|
|
53 |
private static final long serialVersionUID = 1L;
|
| 6057 |
anupam.sin |
54 |
private long rechargeOrderId = 0;
|
| 6050 |
anupam.sin |
55 |
private String amount = "";
|
| 6086 |
anupam.sin |
56 |
private String walletAmountUsed = "0";
|
| 6050 |
anupam.sin |
57 |
private String operator = "";
|
|
|
58 |
private String number = "";
|
|
|
59 |
private String email = "";
|
|
|
60 |
private String rechargeType = "";
|
|
|
61 |
private DesEncrypter desEncrypter = new DesEncrypter("saholic");
|
|
|
62 |
private List<String> couponIds = null;
|
|
|
63 |
private List<RechargeCoupon> coupons = null;
|
| 6058 |
anupam.sin |
64 |
private String userId;
|
| 6057 |
anupam.sin |
65 |
private String message = "";
|
| 6249 |
anupam.sin |
66 |
private String errorMessage = "";
|
| 6070 |
anupam.sin |
67 |
private String totalAmount = "";
|
| 6178 |
anupam.sin |
68 |
private String plan = "";
|
| 6307 |
anupam.sin |
69 |
private String circleCode;
|
| 6433 |
anupam.sin |
70 |
private String couponCode = "";
|
|
|
71 |
private String couponMessage = "";
|
| 6495 |
anupam.sin |
72 |
private String hiddenUserId = "";
|
| 6433 |
anupam.sin |
73 |
private long couponAmount = 0;
|
| 6091 |
anupam.sin |
74 |
private static final String chars = "abcdefghijklmonpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
| 6495 |
anupam.sin |
75 |
private static final BigInteger key = new BigInteger("0333910847013829827302347601486730417451");
|
| 6504 |
anupam.sin |
76 |
private static final String COUPON_APPLIED_SUCCESSFULLY = "Coupon Applied";
|
| 6495 |
anupam.sin |
77 |
|
| 6091 |
anupam.sin |
78 |
private static final Random random = new Random();
|
|
|
79 |
private static final int LENGTH = 10;
|
| 6601 |
anupam.sin |
80 |
private static final String HEADER_X_FORWARDED_FOR = "X-FORWARDED-FOR";
|
| 6050 |
anupam.sin |
81 |
private static Logger log = Logger.getLogger(Class.class);
|
|
|
82 |
|
|
|
83 |
public String index() {
|
|
|
84 |
return "index";
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
public String create() {
|
| 6270 |
rajveer |
88 |
errorMessage = validateRecharge();
|
|
|
89 |
if(!errorMessage.equals("SUCCESS")){
|
| 6108 |
amar.kumar |
90 |
DataLogger.logData(EventType.PROVIDER_FETCH_FAILURE, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
|
|
|
91 |
rechargeType.toString(), number, operator);
|
| 6103 |
amit.gupta |
92 |
return "recharge-redirect";
|
|
|
93 |
}
|
| 6433 |
anupam.sin |
94 |
|
| 6294 |
rajveer |
95 |
setErrorMessage("");
|
| 6086 |
anupam.sin |
96 |
setTotalAmount(amount);
|
| 6433 |
anupam.sin |
97 |
|
| 6057 |
anupam.sin |
98 |
if(userinfo.isLoggedIn()) {
|
| 6124 |
anupam.sin |
99 |
setUserId("" + userinfo.getUserId());
|
| 6433 |
anupam.sin |
100 |
calculateAmounts();
|
| 6124 |
anupam.sin |
101 |
} else {
|
|
|
102 |
long tempUserId = createUserAndSendMail(email);
|
|
|
103 |
if(tempUserId == -1)
|
|
|
104 |
{
|
| 6270 |
rajveer |
105 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
| 6124 |
anupam.sin |
106 |
return "recharge-redirect";
|
|
|
107 |
} else {
|
|
|
108 |
setUserId("" + tempUserId);
|
|
|
109 |
}
|
| 6057 |
anupam.sin |
110 |
}
|
| 6495 |
anupam.sin |
111 |
|
|
|
112 |
setHash(encrypt(getUserId()));
|
| 6050 |
anupam.sin |
113 |
return index();
|
|
|
114 |
}
|
| 6996 |
anupam.sin |
115 |
|
|
|
116 |
public String rechargeAgain() {
|
|
|
117 |
try {
|
|
|
118 |
TransactionClient tcl = new TransactionClient();
|
|
|
119 |
RechargeOrder rechargeOrder = tcl.getClient().getRechargeOrder(rechargeOrderId);
|
|
|
120 |
rechargeType = rechargeOrder.getRechargeType().getValue() + "";
|
|
|
121 |
setNumber(rechargeOrder.getDeviceNumber());
|
|
|
122 |
setOperator(rechargeOrder.getOperatorId() + "");
|
|
|
123 |
setPlan(rechargeOrder.getPlan());
|
|
|
124 |
setAmount(rechargeOrder.getTotalAmount() + "");
|
|
|
125 |
setEmail(rechargeOrder.getUserEmailId());
|
|
|
126 |
} catch(Exception e) {
|
|
|
127 |
log.error("Unable to get the old recharge order : " + rechargeOrderId, e);
|
|
|
128 |
errorMessage = "Oops! There seems to be a problem. Please enter the details";
|
|
|
129 |
return "recharge-redirect";
|
|
|
130 |
}
|
|
|
131 |
return create();
|
|
|
132 |
}
|
| 6433 |
anupam.sin |
133 |
|
| 6723 |
anupam.sin |
134 |
private String calculateAmounts() {
|
| 6433 |
anupam.sin |
135 |
|
|
|
136 |
try {
|
|
|
137 |
TransactionClient tc = new TransactionClient();
|
|
|
138 |
UserWallet wallet = tc.getClient().getUserWallet(userinfo.getUserId());
|
|
|
139 |
long amountA = 0;
|
|
|
140 |
if(wallet.getAmount() == 0){
|
|
|
141 |
setAmount("" + (Long.parseLong(totalAmount) - couponAmount));
|
|
|
142 |
setMessage("");
|
|
|
143 |
} else if ((amountA = wallet.getAmount() - (Long.parseLong(totalAmount) - couponAmount)) >= 0) {
|
|
|
144 |
setAmount("0");
|
|
|
145 |
setWalletAmountUsed("" + (wallet.getAmount() - amountA));
|
|
|
146 |
setMessage("Amount used from RechargeWallet : Rs. " + walletAmountUsed
|
|
|
147 |
+ "<br>Amount left in your RechargeWallet : Rs. " + amountA);
|
|
|
148 |
|
|
|
149 |
} else {
|
|
|
150 |
setAmount("" + (0-amountA));
|
|
|
151 |
setWalletAmountUsed("" + wallet.getAmount());
|
|
|
152 |
setMessage("Amount used from RechargeWallet : Rs. " + walletAmountUsed
|
|
|
153 |
+ "<br>Amount left in your RechargeWallet : Rs.0");
|
|
|
154 |
}
|
| 6723 |
anupam.sin |
155 |
|
|
|
156 |
//Adding a dummy return statement
|
|
|
157 |
return "calculated successfully";
|
| 6433 |
anupam.sin |
158 |
} catch (Exception e) {
|
|
|
159 |
log.error("Unable to get user wallet", e);
|
| 6723 |
anupam.sin |
160 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
|
|
161 |
return "recharge-redirect";
|
| 6433 |
anupam.sin |
162 |
}
|
|
|
163 |
}
|
| 6050 |
anupam.sin |
164 |
|
| 6270 |
rajveer |
165 |
public String validateRecharge(){
|
| 6103 |
amit.gupta |
166 |
TransactionClient tcl;
|
|
|
167 |
try {
|
|
|
168 |
tcl = new TransactionClient();
|
| 6601 |
anupam.sin |
169 |
return tcl.getClient().validateRecharge(RechargeType.findByValue(Integer.parseInt(this.rechargeType)), number, Long.parseLong(operator), remoteAddr(request));
|
| 6103 |
amit.gupta |
170 |
} catch (Exception e) {
|
|
|
171 |
log.error("Unable to get service provider for Device number " + number + " and rechargeType : " + rechargeType, e);
|
|
|
172 |
}
|
| 6270 |
rajveer |
173 |
return "Oops! There seems to be a problem. Please try after some time";
|
| 6103 |
amit.gupta |
174 |
|
|
|
175 |
}
|
| 6495 |
anupam.sin |
176 |
|
|
|
177 |
private String validateFields() {
|
|
|
178 |
if(amount == null || amount == "") {
|
|
|
179 |
log.warn("Amount received is empty or null");
|
|
|
180 |
return "Amount cannot be empty";
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
if(rechargeType == null || rechargeType == "") {
|
|
|
184 |
log.warn("rechargeType received is empty or null");
|
|
|
185 |
return "Oops! There seems to be a problem. Please try after some time";
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
if(email == null || email == "") {
|
|
|
189 |
log.warn("Email received is empty or null");
|
|
|
190 |
return "Email address cannot be empty";
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
try {
|
|
|
194 |
InternetAddress emailAdd = new InternetAddress(email);
|
|
|
195 |
emailAdd.validate();
|
|
|
196 |
} catch (AddressException e1) {
|
|
|
197 |
log.warn("Invalid email address : " + email, e1);
|
|
|
198 |
return "ERROR : Invalid email address.";
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
if (RechargeType.findByValue(Integer.parseInt(this.rechargeType)) == RechargeType.DTH) {
|
| 6800 |
anupam.sin |
202 |
if (Long.parseLong(totalAmount) < 250 || Long.parseLong(totalAmount) > 2000) {
|
|
|
203 |
if(operator.equals("1")) {
|
|
|
204 |
return "DishTv recharge amount should be between Rs.250 and Rs.2000";
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
if (!(Long.parseLong(totalAmount) >= 200 && Long.parseLong(totalAmount) < 250)) {
|
|
|
208 |
return "DTH recharge amount should be between Rs.200 and Rs.2000";
|
|
|
209 |
}
|
| 6495 |
anupam.sin |
210 |
}
|
|
|
211 |
|
|
|
212 |
} else if (RechargeType.findByValue(Integer.parseInt(this.rechargeType)) == RechargeType.MOBILE) {
|
|
|
213 |
if (Long.parseLong(totalAmount) < 10 || Long.parseLong(totalAmount) > 1000) {
|
|
|
214 |
return "Recharge amount should be between Rs.10 and Rs.1000";
|
|
|
215 |
}
|
|
|
216 |
if (number.length() != 10) {
|
|
|
217 |
return "Number should be of 10 digits";
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
} else {
|
|
|
221 |
log.warn("Invalid rechargeType : " + rechargeType);
|
|
|
222 |
return "Oops! There seems to be a problem. Please try after some time";
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
if (operator == null || operator == "") {
|
|
|
226 |
log.warn("Invalid operator : " + operator);
|
|
|
227 |
return "Oops! There seems to be a problem. Please try after some time";
|
|
|
228 |
}
|
|
|
229 |
return "SUCCESS";
|
|
|
230 |
}
|
| 6103 |
amit.gupta |
231 |
|
| 6307 |
anupam.sin |
232 |
public boolean shouldPromptForWallet(){
|
|
|
233 |
if(!isLoggedIn()) {
|
|
|
234 |
try {
|
|
|
235 |
TransactionClient tc = new TransactionClient();
|
|
|
236 |
UserWallet wallet = tc.getClient().getUserWallet(Long.parseLong(userId));
|
|
|
237 |
if(wallet.getAmount() != 0) {
|
|
|
238 |
return true;
|
|
|
239 |
}
|
|
|
240 |
} catch (Exception e) {
|
|
|
241 |
log.error("Unable to get wallet for userId : " + userId, e);
|
|
|
242 |
}
|
|
|
243 |
}
|
|
|
244 |
return false;
|
|
|
245 |
}
|
|
|
246 |
|
| 6433 |
anupam.sin |
247 |
public String applyRechargeCoupon() {
|
|
|
248 |
Map<Long, String> couponResult = null;
|
|
|
249 |
try {
|
|
|
250 |
PromotionClient pc = new PromotionClient();
|
|
|
251 |
couponResult = pc.getClient().applyRechargeCoupon(couponCode, Long.parseLong(totalAmount), Long.parseLong(userId));
|
|
|
252 |
if (couponResult != null) {
|
|
|
253 |
for (long couponAmount : couponResult.keySet()) {
|
|
|
254 |
setCouponMessage(couponResult.get(couponAmount));
|
|
|
255 |
this.couponAmount = couponAmount;
|
|
|
256 |
}
|
| 6730 |
anupam.sin |
257 |
|
|
|
258 |
if (getCouponMessage().equals("login")) {
|
|
|
259 |
if (userinfo.isLoggedIn()) {
|
|
|
260 |
setCouponMessage("Coupon Applied");
|
|
|
261 |
} else {
|
|
|
262 |
couponAmount = 0;
|
|
|
263 |
setCouponMessage("Please <a href='login?redirectUrl=recharge' style='color:black;font-weight:bold;'>click here</a> to login and use this coupon");
|
|
|
264 |
}
|
|
|
265 |
}
|
| 6433 |
anupam.sin |
266 |
}
|
| 6443 |
anupam.sin |
267 |
|
|
|
268 |
if(couponAmount == 0) {
|
| 6495 |
anupam.sin |
269 |
couponCode = "";
|
| 6443 |
anupam.sin |
270 |
}
|
|
|
271 |
|
| 6433 |
anupam.sin |
272 |
if(userinfo.isLoggedIn()) {
|
|
|
273 |
calculateAmounts();
|
|
|
274 |
} else {
|
|
|
275 |
setAmount("" + (Long.parseLong(amount) - couponAmount));
|
|
|
276 |
}
|
|
|
277 |
return index();
|
|
|
278 |
} catch (Exception e) {
|
|
|
279 |
log.error("Unable to apply recharge coupon : " + couponCode, e);
|
|
|
280 |
setCouponMessage("Currently this coupon is unavailable");
|
|
|
281 |
}
|
|
|
282 |
return index();
|
|
|
283 |
}
|
|
|
284 |
|
| 6050 |
anupam.sin |
285 |
public String createRecharge(){
|
| 6249 |
anupam.sin |
286 |
if (amount.equals("0")) {
|
|
|
287 |
if (!verifyCaptcha()) {
|
|
|
288 |
setErrorMessage("Invalid captcha. Try Again.");
|
|
|
289 |
log.info("Invalid captcha error msg has been added");
|
|
|
290 |
return index();
|
|
|
291 |
}
|
|
|
292 |
}
|
| 6495 |
anupam.sin |
293 |
|
|
|
294 |
String decryptedUserId = decrypt(hiddenUserId);
|
|
|
295 |
if(!userId.equals(decryptedUserId)) {
|
|
|
296 |
log.warn("userId and hash do not match");
|
|
|
297 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
|
|
298 |
return "recharge-redirect";
|
|
|
299 |
}
|
|
|
300 |
|
|
|
301 |
errorMessage = validateFields();
|
|
|
302 |
if (!errorMessage.equals("SUCCESS")) {
|
|
|
303 |
return "recharge-redirect";
|
|
|
304 |
}
|
|
|
305 |
|
| 6050 |
anupam.sin |
306 |
try {
|
| 6058 |
anupam.sin |
307 |
TransactionClient tc = new TransactionClient();
|
| 6397 |
anupam.sin |
308 |
List<RechargePlan> plans = tc.getClient().getPlansForOperator(Long.parseLong(operator));
|
|
|
309 |
List<String> planNameList = new ArrayList<String>();
|
|
|
310 |
if (plans == null || plans.isEmpty()) {
|
|
|
311 |
setPlan("");
|
|
|
312 |
} else {
|
|
|
313 |
for (RechargePlan tempPlan : plans) {
|
|
|
314 |
planNameList.add(tempPlan.getName());
|
|
|
315 |
}
|
|
|
316 |
if (!planNameList.contains(plan)) {
|
|
|
317 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
|
|
318 |
log.warn("OperatorId : " + operator + " and plan : " + plan + " do not match");
|
|
|
319 |
return "recharge-redirect";
|
|
|
320 |
}
|
|
|
321 |
}
|
|
|
322 |
|
| 6433 |
anupam.sin |
323 |
if(userinfo.isLoggedIn()) {
|
|
|
324 |
UserWallet wallet = tc.getClient().getUserWallet(userinfo.getUserId());
|
|
|
325 |
if(wallet.getAmount() < Long.parseLong(walletAmountUsed)) {
|
|
|
326 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
|
|
327 |
log.warn("WalletAmount used : " + walletAmountUsed + " is greater than wallet Balance : " + wallet.getAmount());
|
|
|
328 |
return "recharge-redirect";
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
if (userinfo.getUserId() != Long.parseLong(userId)) {
|
|
|
332 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
|
|
333 |
log.warn("Logged in user : " + userinfo.getUserId() + " does not match with userId sent by user : " + userId);
|
|
|
334 |
return "recharge-redirect";
|
|
|
335 |
}
|
| 8756 |
rajveer |
336 |
}else{
|
|
|
337 |
if(Long.parseLong(walletAmountUsed) > 0) {
|
|
|
338 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
|
|
339 |
log.warn("WalletAmount used : " + walletAmountUsed + " is greater than zero for non logged-in user.");
|
|
|
340 |
return "recharge-redirect";
|
|
|
341 |
}
|
|
|
342 |
|
| 6433 |
anupam.sin |
343 |
}
|
|
|
344 |
|
|
|
345 |
PromotionClient pc = new PromotionClient();
|
|
|
346 |
Map<Long, String> couponResult = null;
|
|
|
347 |
couponResult = pc.getClient().applyRechargeCoupon(couponCode, Long.parseLong(totalAmount), Long.parseLong(userId));
|
|
|
348 |
if(couponResult != null) {
|
| 6754 |
anupam.sin |
349 |
for (long couponAmount : couponResult.keySet()) {
|
|
|
350 |
setCouponMessage(couponResult.get(couponAmount));
|
|
|
351 |
this.couponAmount = couponAmount;
|
| 6495 |
anupam.sin |
352 |
}
|
| 6754 |
anupam.sin |
353 |
|
|
|
354 |
if (getCouponMessage().equals("login")) {
|
|
|
355 |
setCouponMessage("Coupon Applied");
|
|
|
356 |
}
|
|
|
357 |
|
| 6495 |
anupam.sin |
358 |
} else {
|
|
|
359 |
couponCode = "";
|
|
|
360 |
couponAmount = 0;
|
| 6433 |
anupam.sin |
361 |
}
|
|
|
362 |
|
|
|
363 |
if (Long.parseLong(totalAmount) != Long.parseLong(amount) + Long.parseLong(walletAmountUsed) + couponAmount){
|
|
|
364 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
|
|
365 |
log.warn("WalletAmount : " + walletAmountUsed + " plus couponAmount : " + couponAmount + " plus amount to be paid : " +
|
| 10477 |
amit.gupta |
366 |
amount + " do not match with rechargeAmount : " + totalAmount);
|
| 6433 |
anupam.sin |
367 |
return "recharge-redirect";
|
|
|
368 |
}
|
|
|
369 |
|
|
|
370 |
|
| 6050 |
anupam.sin |
371 |
RechargeOrder rechargeOrder = new RechargeOrder();
|
| 6249 |
anupam.sin |
372 |
rechargeOrder.setTotalAmount(Long.parseLong(totalAmount));
|
| 6050 |
anupam.sin |
373 |
rechargeOrder.setUserEmailId(email);
|
| 6058 |
anupam.sin |
374 |
rechargeOrder.setUserId(Long.parseLong(userId));
|
| 6723 |
anupam.sin |
375 |
rechargeOrder.setDeviceNumber(number.trim());
|
| 6178 |
anupam.sin |
376 |
rechargeOrder.setPlan(plan);
|
| 6050 |
anupam.sin |
377 |
rechargeOrder.setOperatorId(Long.parseLong(operator));
|
| 6057 |
anupam.sin |
378 |
rechargeOrder.setRechargeType(RechargeType.findByValue(Integer.parseInt(rechargeType)));
|
| 6050 |
anupam.sin |
379 |
rechargeOrder.setStatus(RechargeOrderStatus.PAYMENT_PENDING);
|
|
|
380 |
rechargeOrder.setOrderType(OrderType.B2C);
|
| 6070 |
anupam.sin |
381 |
rechargeOrder.setWalletAmount(Long.parseLong(getWalletAmountUsed()));
|
| 6433 |
anupam.sin |
382 |
rechargeOrder.setCouponAmount(couponAmount);
|
|
|
383 |
rechargeOrder.setCouponCode(couponCode);
|
| 6601 |
anupam.sin |
384 |
rechargeOrder.setIpAddress(remoteAddr(request));
|
| 6397 |
anupam.sin |
385 |
TransactionClient tc1 = new TransactionClient();
|
|
|
386 |
rechargeOrder = tc1.getClient().createRechargeOrder(rechargeOrder);
|
| 6057 |
anupam.sin |
387 |
setRechargeOrderId(rechargeOrder.getId());
|
| 6050 |
anupam.sin |
388 |
|
| 6178 |
anupam.sin |
389 |
} catch (Exception e) {
|
|
|
390 |
log.error("Unable to create recharge order", e);
|
| 6270 |
rajveer |
391 |
errorMessage = "Oops! There seems to be a problem. Please try after some time";
|
| 6178 |
anupam.sin |
392 |
return "recharge-redirect";
|
| 6050 |
anupam.sin |
393 |
}
|
|
|
394 |
if(amount.equals("0")) {
|
|
|
395 |
return "create-recharge-redirect";
|
|
|
396 |
} else {
|
|
|
397 |
return "recharge-pay-options-redirect";
|
|
|
398 |
}
|
|
|
399 |
}
|
|
|
400 |
|
| 6249 |
anupam.sin |
401 |
private boolean verifyCaptcha() {
|
|
|
402 |
String cookieCaptchaAnswer = getCookie(Captcha.NAME, true, "saholic");
|
|
|
403 |
String captchaReceived = (String) request.getParameter("captcha_response_field");
|
|
|
404 |
|
|
|
405 |
if (captchaReceived.equalsIgnoreCase(cookieCaptchaAnswer)) {
|
|
|
406 |
try {
|
|
|
407 |
DataLogger.logData(EventType.CAPTCHA_SUCCESS, getSessionId(), userinfo.getUserId(), userinfo.getEmail());
|
|
|
408 |
} catch (Exception e1) {
|
|
|
409 |
log.warn("Unable to log orders through the datalogger", e1);
|
|
|
410 |
}
|
|
|
411 |
return true;
|
|
|
412 |
}
|
|
|
413 |
else {
|
|
|
414 |
try {
|
|
|
415 |
DataLogger.logData(EventType.CAPTCHA_FAILED, getSessionId(), userinfo.getUserId(), userinfo.getEmail());
|
|
|
416 |
} catch (Exception e1) {
|
|
|
417 |
log.warn("Unable to log orders through the datalogger", e1);
|
|
|
418 |
}
|
|
|
419 |
return false;
|
|
|
420 |
}
|
|
|
421 |
}
|
|
|
422 |
|
| 6091 |
anupam.sin |
423 |
private static String generateNewPassword() {
|
|
|
424 |
char[] buf = new char[LENGTH];
|
|
|
425 |
for (int i = 0; i < buf.length; i++) {
|
|
|
426 |
buf[i] = chars.charAt(random.nextInt(chars.length()));
|
|
|
427 |
}
|
|
|
428 |
return new String(buf);
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
private long createUserAndSendMail(String email) {
|
|
|
432 |
User user = null;
|
|
|
433 |
String password = null;
|
|
|
434 |
try{
|
|
|
435 |
UserClient ucl = new UserClient();
|
|
|
436 |
user = ucl.getClient().getUserByEmail(email);
|
| 6124 |
anupam.sin |
437 |
if(user.getUserId() == -1) {
|
| 6091 |
anupam.sin |
438 |
user.setEmail(email);
|
|
|
439 |
password = generateNewPassword();
|
|
|
440 |
String encryptedPassword = desEncrypter.encrypt(password);
|
|
|
441 |
user.setPassword(encryptedPassword);
|
|
|
442 |
user.setCommunicationEmail(email);
|
|
|
443 |
UserClient userContextServiceClient = new UserClient();
|
|
|
444 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
|
|
|
445 |
user = userClient.createUser(user);
|
| 6124 |
anupam.sin |
446 |
|
|
|
447 |
List<String> toList = new ArrayList<String>();
|
|
|
448 |
toList.add(email);
|
|
|
449 |
HelperClient helperServiceClient = null;
|
|
|
450 |
helperServiceClient = new HelperClient();
|
|
|
451 |
in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
|
|
|
452 |
Mail mail = new Mail();
|
| 6131 |
anupam.sin |
453 |
mail.setSubject("Saholic Registration successful");
|
| 6124 |
anupam.sin |
454 |
mail.setTo(toList);
|
|
|
455 |
mail.setData("Your have successfully registered with Saholic.com. Your user name is: " + email + " and your password is: " + password);
|
|
|
456 |
client.sendMail(mail);
|
| 6091 |
anupam.sin |
457 |
}
|
|
|
458 |
}catch (UserContextException ux){
|
|
|
459 |
return -1;
|
|
|
460 |
} catch (TTransportException e) {
|
|
|
461 |
return -1;
|
|
|
462 |
} catch (TException e) {
|
|
|
463 |
return -1;
|
| 6124 |
anupam.sin |
464 |
} catch (Exception e) {
|
|
|
465 |
log.error("Unexpected error while mailing the new password");
|
|
|
466 |
return -1;
|
| 6091 |
anupam.sin |
467 |
}
|
|
|
468 |
return user.getUserId();
|
|
|
469 |
}
|
|
|
470 |
|
| 6057 |
anupam.sin |
471 |
public String getOperatorName() {
|
| 6206 |
rajveer |
472 |
String operatorName = null;
|
|
|
473 |
if(rechargeType.equals("1")){
|
|
|
474 |
operatorName = Utils.getMobileProvidersMap().get(Long.parseLong(operator));
|
|
|
475 |
}
|
|
|
476 |
if(rechargeType.equals("2")){
|
|
|
477 |
operatorName = Utils.getDthProvidersMap().get(Long.parseLong(operator));
|
|
|
478 |
}
|
|
|
479 |
if(operatorName == null){
|
|
|
480 |
operatorName = "N/A";
|
|
|
481 |
}
|
|
|
482 |
return operatorName;
|
| 6057 |
anupam.sin |
483 |
}
|
|
|
484 |
|
| 6495 |
anupam.sin |
485 |
public String encrypt(String strToEncrypt) {
|
|
|
486 |
BigInteger strBigInt = new BigInteger(strToEncrypt.getBytes());
|
|
|
487 |
System.out.println(strBigInt);
|
|
|
488 |
BigInteger hashedPasswd = key.xor(strBigInt);
|
|
|
489 |
System.out.println(hashedPasswd);
|
|
|
490 |
return (hashedPasswd.toString(16));
|
|
|
491 |
}
|
|
|
492 |
|
|
|
493 |
public String decrypt(String encrypted) {
|
|
|
494 |
try
|
|
|
495 |
{
|
|
|
496 |
BigInteger encryptedBigInt = new BigInteger(encrypted, 16);
|
|
|
497 |
System.out.println(encryptedBigInt);
|
|
|
498 |
BigInteger strBigInt = encryptedBigInt.xor(key);
|
|
|
499 |
System.out.println(strBigInt);
|
|
|
500 |
String decrypted = new String(strBigInt.toByteArray());
|
|
|
501 |
return decrypted;
|
|
|
502 |
} catch (Exception e) {
|
|
|
503 |
System.out.println("oops");
|
|
|
504 |
return "";
|
|
|
505 |
}
|
|
|
506 |
}
|
|
|
507 |
|
| 6601 |
anupam.sin |
508 |
public String remoteAddr(HttpServletRequest request) {
|
|
|
509 |
String remoteAddr = "";
|
|
|
510 |
String x;
|
| 6605 |
anupam.sin |
511 |
x = request.getHeader(HEADER_X_FORWARDED_FOR);
|
|
|
512 |
if (x != null && !x.isEmpty()) {
|
| 6601 |
anupam.sin |
513 |
remoteAddr = x;
|
|
|
514 |
int idx = remoteAddr.lastIndexOf(',');
|
|
|
515 |
if (idx > -1) {
|
|
|
516 |
remoteAddr = remoteAddr.substring(idx + 1).trim();
|
|
|
517 |
}
|
| 6605 |
anupam.sin |
518 |
} else {
|
|
|
519 |
remoteAddr = request.getRemoteAddr();
|
| 6601 |
anupam.sin |
520 |
}
|
|
|
521 |
return remoteAddr;
|
|
|
522 |
}
|
|
|
523 |
|
| 6050 |
anupam.sin |
524 |
public String getAmount() {
|
|
|
525 |
return amount;
|
|
|
526 |
}
|
|
|
527 |
public void setAmount(String amount) {
|
|
|
528 |
this.amount = amount;
|
|
|
529 |
}
|
| 6073 |
amit.gupta |
530 |
|
|
|
531 |
public void setDthamount(String amount) {
|
|
|
532 |
this.amount = amount;
|
|
|
533 |
}
|
| 6050 |
anupam.sin |
534 |
public String getOperator() {
|
|
|
535 |
return operator;
|
|
|
536 |
}
|
|
|
537 |
public void setOperator(String operator) {
|
|
|
538 |
this.operator = operator;
|
|
|
539 |
}
|
|
|
540 |
public String getNumber() {
|
|
|
541 |
return number;
|
|
|
542 |
}
|
|
|
543 |
public void setNumber(String number) {
|
|
|
544 |
this.number = number;
|
|
|
545 |
}
|
| 6073 |
amit.gupta |
546 |
|
|
|
547 |
public void setDthnumber(String dthnumber) {
|
|
|
548 |
this.number = dthnumber;
|
|
|
549 |
}
|
|
|
550 |
|
|
|
551 |
|
| 6050 |
anupam.sin |
552 |
public String getEmail() {
|
|
|
553 |
return email;
|
|
|
554 |
}
|
|
|
555 |
public void setEmail(String email) {
|
|
|
556 |
this.email = email;
|
|
|
557 |
}
|
|
|
558 |
|
|
|
559 |
public void setCouponIds(List<String> couponIds) {
|
|
|
560 |
this.couponIds = couponIds;
|
|
|
561 |
}
|
|
|
562 |
|
|
|
563 |
public List<String> getCouponIds() {
|
|
|
564 |
return couponIds;
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
public void setCoupons(List<RechargeCoupon> coupons) {
|
|
|
568 |
this.coupons = coupons;
|
|
|
569 |
}
|
|
|
570 |
|
|
|
571 |
public List<RechargeCoupon> getCoupons() {
|
|
|
572 |
return coupons;
|
|
|
573 |
}
|
|
|
574 |
|
|
|
575 |
public String getRechargeType() {
|
|
|
576 |
return rechargeType;
|
|
|
577 |
}
|
|
|
578 |
|
|
|
579 |
public void setRechargeType(String rechargeType) {
|
|
|
580 |
this.rechargeType = rechargeType;
|
|
|
581 |
}
|
|
|
582 |
|
| 6058 |
anupam.sin |
583 |
public String getUserId() {
|
| 6050 |
anupam.sin |
584 |
return userId;
|
|
|
585 |
}
|
|
|
586 |
|
| 6058 |
anupam.sin |
587 |
public void setUserId(String userId) {
|
|
|
588 |
this.userId = userId;
|
| 6050 |
anupam.sin |
589 |
}
|
|
|
590 |
|
| 6057 |
anupam.sin |
591 |
public boolean isLoggedIn() {
|
|
|
592 |
return userinfo.isLoggedIn();
|
|
|
593 |
}
|
|
|
594 |
|
|
|
595 |
public void setMessage(String message) {
|
|
|
596 |
this.message = message;
|
|
|
597 |
}
|
|
|
598 |
|
|
|
599 |
public String getMessage() {
|
|
|
600 |
return message;
|
|
|
601 |
}
|
|
|
602 |
|
|
|
603 |
public long getRechargeOrderId() {
|
|
|
604 |
return rechargeOrderId;
|
|
|
605 |
}
|
|
|
606 |
|
|
|
607 |
public void setRechargeOrderId(long l) {
|
|
|
608 |
this.rechargeOrderId = l;
|
|
|
609 |
}
|
| 6070 |
anupam.sin |
610 |
|
|
|
611 |
public String getTotalAmount() {
|
|
|
612 |
return totalAmount;
|
|
|
613 |
}
|
| 6249 |
anupam.sin |
614 |
|
|
|
615 |
public void setTotalAmount(String amount) {
|
|
|
616 |
this.totalAmount = amount;
|
|
|
617 |
|
|
|
618 |
}
|
| 6070 |
anupam.sin |
619 |
|
|
|
620 |
public String getWalletAmountUsed() {
|
|
|
621 |
return walletAmountUsed;
|
|
|
622 |
}
|
|
|
623 |
|
|
|
624 |
public void setWalletAmountUsed(String walletAmountUsed) {
|
|
|
625 |
this.walletAmountUsed = walletAmountUsed;
|
|
|
626 |
}
|
| 6178 |
anupam.sin |
627 |
|
|
|
628 |
public String getPlan() {
|
|
|
629 |
return plan;
|
|
|
630 |
}
|
|
|
631 |
|
|
|
632 |
public void setPlan(String plan) {
|
|
|
633 |
this.plan = plan;
|
|
|
634 |
}
|
| 6249 |
anupam.sin |
635 |
|
|
|
636 |
public String getErrorMessage() {
|
|
|
637 |
return errorMessage;
|
|
|
638 |
}
|
|
|
639 |
|
|
|
640 |
public void setErrorMessage(String errorMessage) {
|
|
|
641 |
this.errorMessage = errorMessage;
|
|
|
642 |
}
|
| 6307 |
anupam.sin |
643 |
|
|
|
644 |
public String getCircleCode() {
|
|
|
645 |
return circleCode;
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
public void setCircleCode(String circleCode) {
|
|
|
649 |
this.circleCode = circleCode;
|
|
|
650 |
}
|
| 6433 |
anupam.sin |
651 |
|
|
|
652 |
public void setDiscountCode(String discountCode) {
|
|
|
653 |
this.couponCode = discountCode;
|
|
|
654 |
}
|
| 6057 |
anupam.sin |
655 |
|
| 6433 |
anupam.sin |
656 |
public String getCouponCode() {
|
|
|
657 |
return couponCode;
|
|
|
658 |
}
|
|
|
659 |
|
|
|
660 |
public void setCouponCode(String couponCode) {
|
|
|
661 |
this.couponCode = couponCode;
|
|
|
662 |
}
|
|
|
663 |
|
|
|
664 |
public void setCouponAmount(long couponAmount) {
|
|
|
665 |
this.couponAmount = couponAmount;
|
|
|
666 |
}
|
|
|
667 |
|
|
|
668 |
public long getCouponAmount() {
|
|
|
669 |
return couponAmount;
|
|
|
670 |
}
|
|
|
671 |
|
|
|
672 |
public void setCouponMessage(String couponMessage) {
|
|
|
673 |
this.couponMessage = couponMessage;
|
|
|
674 |
}
|
|
|
675 |
|
|
|
676 |
public String getCouponMessage() {
|
|
|
677 |
return couponMessage;
|
|
|
678 |
}
|
|
|
679 |
|
| 6495 |
anupam.sin |
680 |
public void setHash(String hash) {
|
|
|
681 |
this.hiddenUserId = hash;
|
|
|
682 |
}
|
|
|
683 |
|
|
|
684 |
public String getHiddenUserId() {
|
|
|
685 |
return hiddenUserId;
|
|
|
686 |
}
|
| 6050 |
anupam.sin |
687 |
}
|