| 419 |
rajveer |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
| 2263 |
vikas |
3 |
import in.shop2020.datalogger.EventType;
|
| 2183 |
vikas |
4 |
import in.shop2020.model.v1.order.Order;
|
| 4325 |
mandeep.dh |
5 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 3063 |
chandransh |
6 |
import in.shop2020.model.v1.user.Address;
|
| 8428 |
rajveer |
7 |
import in.shop2020.model.v1.user.Cart;
|
| 894 |
rajveer |
8 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| 2817 |
vikas |
9 |
import in.shop2020.serving.interceptors.TrackingInterceptor;
|
| 3063 |
chandransh |
10 |
import in.shop2020.serving.services.CodPaymentService;
|
|
|
11 |
import in.shop2020.serving.services.CommonPaymentService;
|
| 7862 |
anupam.sin |
12 |
import in.shop2020.serving.services.CouponPaymentService;
|
| 1905 |
chandransh |
13 |
import in.shop2020.serving.services.EbsPaymentService;
|
| 3616 |
chandransh |
14 |
import in.shop2020.serving.services.HdfcEmiPaymentService;
|
| 1318 |
rajveer |
15 |
import in.shop2020.serving.services.HdfcPaymentService;
|
| 1905 |
chandransh |
16 |
import in.shop2020.serving.services.IPaymentService;
|
| 6390 |
rajveer |
17 |
import in.shop2020.serving.services.InnovitiPaymentService;
|
|
|
18 |
//import in.shop2020.serving.services.PayuPaymentService;
|
| 6050 |
anupam.sin |
19 |
import in.shop2020.serving.utils.DesEncrypter;
|
| 3212 |
vikas |
20 |
import in.shop2020.serving.utils.Utils;
|
| 3126 |
rajveer |
21 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
22 |
import in.shop2020.thrift.clients.UserClient;
|
| 2511 |
vikas |
23 |
import in.shop2020.utils.DataLogger;
|
| 7954 |
manish.sha |
24 |
import in.shop2020.utils.FedExShipAccountInfo;
|
| 517 |
rajveer |
25 |
|
| 3394 |
vikas |
26 |
import java.util.ArrayList;
|
| 7001 |
rajveer |
27 |
import java.util.Arrays;
|
| 2419 |
vikas |
28 |
import java.util.List;
|
|
|
29 |
|
| 832 |
rajveer |
30 |
import org.apache.log4j.Logger;
|
| 822 |
vikas |
31 |
import org.apache.struts2.convention.annotation.InterceptorRef;
|
|
|
32 |
import org.apache.struts2.convention.annotation.InterceptorRefs;
|
| 419 |
rajveer |
33 |
import org.apache.struts2.convention.annotation.Result;
|
|
|
34 |
import org.apache.struts2.convention.annotation.Results;
|
| 517 |
rajveer |
35 |
import org.apache.thrift.TException;
|
| 4325 |
mandeep.dh |
36 |
import org.apache.thrift.transport.TTransportException;
|
| 7954 |
manish.sha |
37 |
|
|
|
38 |
import com.ShipWebServiceClient;
|
|
|
39 |
import com.fedex.ship.stub.CompletedPackageDetail;
|
|
|
40 |
import com.fedex.ship.stub.CompletedShipmentDetail;
|
|
|
41 |
import com.fedex.ship.stub.ProcessShipmentReply;
|
|
|
42 |
import com.fedex.ship.stub.TrackingId;
|
|
|
43 |
|
| 4609 |
phani.kuma |
44 |
import nl.captcha.Captcha;
|
| 419 |
rajveer |
45 |
|
| 2159 |
chandransh |
46 |
@SuppressWarnings("serial")
|
| 822 |
vikas |
47 |
@InterceptorRefs({
|
|
|
48 |
@InterceptorRef("myDefault"),
|
|
|
49 |
@InterceptorRef("login")
|
|
|
50 |
})
|
|
|
51 |
|
| 419 |
rajveer |
52 |
@Results({
|
| 3101 |
chandransh |
53 |
@Result(name="shipping-redirect", type="redirectAction", params = {"actionName" , "shipping"}),
|
| 5716 |
anupam.sin |
54 |
@Result(name="proceed-to-pay-redirect", type="redirectAction", params = {"actionName" , "proceed-to-pay", "deliveryLocation", "${deliveryLocation}"}),
|
| 3063 |
chandransh |
55 |
@Result(name="ebs-pay-redirect", type="redirect", location="/ebs-pay/${paymentId}"),
|
| 6060 |
rajveer |
56 |
@Result(name="payu-pay-redirect", type="redirect", location="/payu-pay/${paymentId}"),
|
| 6390 |
rajveer |
57 |
@Result(name="innoviti-pay-redirect", type="redirect", location="/innoviti-pay/${paymentId}"),
|
| 3063 |
chandransh |
58 |
@Result(name="cod-redirect", type="redirect", location="/pay-success?paymentId=${paymentId}")
|
| 419 |
rajveer |
59 |
})
|
| 650 |
rajveer |
60 |
public class OrderController extends BaseController {
|
| 419 |
rajveer |
61 |
|
| 1905 |
chandransh |
62 |
public long getPaymentId() {
|
|
|
63 |
return paymentId;
|
|
|
64 |
}
|
| 419 |
rajveer |
65 |
|
| 832 |
rajveer |
66 |
private static Logger log = Logger.getLogger(Class.class);
|
| 3063 |
chandransh |
67 |
|
| 507 |
rajveer |
68 |
private String id;
|
| 712 |
rajveer |
69 |
private long txnId = 0;
|
| 650 |
rajveer |
70 |
|
| 1905 |
chandransh |
71 |
private long paymentId;
|
|
|
72 |
|
| 1318 |
rajveer |
73 |
private String redirectURL;
|
| 5716 |
anupam.sin |
74 |
private String deliveryLocation = "";
|
| 681 |
rajveer |
75 |
|
| 419 |
rajveer |
76 |
public OrderController(){
|
| 507 |
rajveer |
77 |
super();
|
| 419 |
rajveer |
78 |
}
|
|
|
79 |
|
| 507 |
rajveer |
80 |
// GET /order/ orderid
|
|
|
81 |
public String show() {
|
|
|
82 |
log.info("id=" + id);
|
| 822 |
vikas |
83 |
htmlSnippets.put("MYACCOUNT_HEADER", pageLoader.getMyaccountHeaderHtml());
|
| 4815 |
phani.kuma |
84 |
htmlSnippets.put("ORDER_DETAILS", pageLoader.getOrderDetailsHtml(Long.parseLong(id), userinfo));
|
| 507 |
rajveer |
85 |
return "show";
|
| 419 |
rajveer |
86 |
}
|
| 517 |
rajveer |
87 |
|
| 572 |
chandransh |
88 |
// POST /order/
|
|
|
89 |
public String create(){
|
| 786 |
rajveer |
90 |
String addressIdString = this.request.getParameter("addressid");
|
|
|
91 |
if(addressIdString == null){
|
| 894 |
rajveer |
92 |
addActionError("Please specify shipping address to continue.");
|
| 3101 |
chandransh |
93 |
return "proceed-to-pay-redirect";
|
| 786 |
rajveer |
94 |
}
|
| 2159 |
chandransh |
95 |
|
|
|
96 |
String paymentOption = request.getParameter("payment_option");
|
|
|
97 |
log.info("Payment Option Selected: " + paymentOption);
|
|
|
98 |
if(paymentOption == null || paymentOption.equals("")){
|
|
|
99 |
addActionError("Please select a payment method to continue.");
|
| 3101 |
chandransh |
100 |
return "proceed-to-pay-redirect";
|
| 2159 |
chandransh |
101 |
}
|
|
|
102 |
|
|
|
103 |
|
| 3101 |
chandransh |
104 |
long addressId;
|
|
|
105 |
try {
|
|
|
106 |
addressId = Long.parseLong(addressIdString);
|
|
|
107 |
} catch(NumberFormatException nfe){
|
|
|
108 |
log.error("Unable to get address id", nfe);
|
|
|
109 |
addActionError("Invalid address. Please add an address to the cart.");
|
|
|
110 |
return "shipping-redirect";
|
|
|
111 |
}
|
|
|
112 |
|
| 572 |
chandransh |
113 |
long currentCartId = userinfo.getCartId();
|
| 5326 |
rajveer |
114 |
long currentUserId = userinfo.getUserId();
|
| 3063 |
chandransh |
115 |
|
|
|
116 |
if(paymentOption.equals(IPaymentService.COD)){
|
|
|
117 |
if(!verifyCaptcha()){
|
|
|
118 |
addActionError("Invalid captcha");
|
| 4815 |
phani.kuma |
119 |
log.info("Invalid captcha error msg has been added");
|
| 3101 |
chandransh |
120 |
return "proceed-to-pay-redirect";
|
| 3063 |
chandransh |
121 |
}
|
|
|
122 |
|
| 6353 |
rajveer |
123 |
//Check that this address is eligible for COD shipping.
|
|
|
124 |
UserClient userServiceClient = null;
|
|
|
125 |
try {
|
|
|
126 |
userServiceClient = new UserClient();
|
|
|
127 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
|
|
|
128 |
Address address = userClient.getAddressById(addressId);
|
|
|
129 |
|
|
|
130 |
if(!userClient.showCODOption(currentCartId, sourceId, address.getPin())){
|
|
|
131 |
addActionError("Cash on Delivery is currently not available for this pincode. Please choose a different payment option.");
|
|
|
132 |
return "proceed-to-pay-redirect";
|
|
|
133 |
}
|
|
|
134 |
} catch (Exception e) {
|
|
|
135 |
log.error("Unable to talk to the user context service.", e);
|
|
|
136 |
addActionError("We are experiencing some problems. Please try later.");
|
|
|
137 |
return "proceed-to-pay-redirect";
|
|
|
138 |
}
|
| 3063 |
chandransh |
139 |
}
|
|
|
140 |
|
| 7862 |
anupam.sin |
141 |
if(paymentOption.equals(IPaymentService.COUPON)) {
|
|
|
142 |
if(!verifyCaptcha()){
|
|
|
143 |
addActionError("Invalid captcha");
|
|
|
144 |
log.info("Invalid captcha error msg has been added");
|
|
|
145 |
return "proceed-to-pay-redirect";
|
|
|
146 |
}
|
| 8428 |
rajveer |
147 |
UserClient userServiceClient = null;
|
|
|
148 |
try {
|
|
|
149 |
userServiceClient = new UserClient();
|
|
|
150 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
|
|
|
151 |
Cart cart = userClient.getCart(currentCartId);
|
|
|
152 |
if(!isCouponValid(cart)){
|
|
|
153 |
addActionError("Cart amount is not zero.");
|
|
|
154 |
log.info("Cart amount is not zero.");
|
|
|
155 |
return "proceed-to-pay-redirect";
|
|
|
156 |
}
|
|
|
157 |
} catch (Exception e) {
|
|
|
158 |
log.error("Unable to talk to the user context service.", e);
|
|
|
159 |
addActionError("We are experiencing some problems. Please try later.");
|
|
|
160 |
return "proceed-to-pay-redirect";
|
|
|
161 |
}
|
| 7862 |
anupam.sin |
162 |
}
|
|
|
163 |
|
| 3063 |
chandransh |
164 |
try {
|
| 6390 |
rajveer |
165 |
if(!createOrders(addressId, currentCartId, currentUserId, Long.parseLong(paymentOption))) {
|
| 1128 |
rajveer |
166 |
addActionError("We are experiencing some problems. Please try later.");
|
| 3101 |
chandransh |
167 |
return "proceed-to-pay-redirect";
|
| 894 |
rajveer |
168 |
}
|
| 3063 |
chandransh |
169 |
} catch (Exception e) {
|
| 1128 |
rajveer |
170 |
addActionError("We are experiencing some problems. Please try later.");
|
| 2296 |
chandransh |
171 |
log.error("Exception in createOrders function. Something went wrong.", e);
|
| 3101 |
chandransh |
172 |
return "proceed-to-pay-redirect";
|
| 693 |
rajveer |
173 |
}
|
| 2159 |
chandransh |
174 |
|
| 6390 |
rajveer |
175 |
int gatewayId = (int)findGatewayId(paymentOption);
|
|
|
176 |
switch (gatewayId) {
|
| 6419 |
rajveer |
177 |
case 4:
|
|
|
178 |
IPaymentService codPaymentService = new CodPaymentService();
|
|
|
179 |
paymentId = codPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, 4);
|
|
|
180 |
if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
|
|
|
181 |
//Very unlikely. The only possible reason can be that the payment service is down.
|
|
|
182 |
log.error("Unable to process the COD payment.");
|
|
|
183 |
addActionError("We are experiencing some problems. Please try later.");
|
|
|
184 |
return "proceed-to-pay-redirect";
|
|
|
185 |
} else {
|
|
|
186 |
CommonPaymentService.processCodTxn(txnId);
|
|
|
187 |
return "cod-redirect";
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
case 5:
|
| 6390 |
rajveer |
191 |
case 10:
|
|
|
192 |
case 11:
|
|
|
193 |
case 12:
|
| 7001 |
rajveer |
194 |
case 14:
|
| 6390 |
rajveer |
195 |
IPaymentService hdfcEmiPaymentService = new HdfcEmiPaymentService();
|
|
|
196 |
paymentId = hdfcEmiPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, gatewayId);
|
|
|
197 |
if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
|
|
|
198 |
addActionError("We are experiencing some problems. Please try later.");
|
|
|
199 |
log.error("Unable to process payment through HDFC EMI.");
|
|
|
200 |
return "proceed-to-pay-redirect";
|
|
|
201 |
} else {
|
|
|
202 |
this.redirectURL = ((HdfcEmiPaymentService)hdfcEmiPaymentService).getRedirectUrl();
|
|
|
203 |
log.info(this.redirectURL);
|
|
|
204 |
return "success";
|
|
|
205 |
}
|
| 6419 |
rajveer |
206 |
|
|
|
207 |
case 13:
|
|
|
208 |
IPaymentService innovitiPaymentService = new InnovitiPaymentService();
|
|
|
209 |
paymentId = innovitiPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, gatewayId);
|
|
|
210 |
if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
|
|
|
211 |
//Very unlikely. The only possible reason can be that the payment service is down.
|
|
|
212 |
log.error("Unable to process the COD payment.");
|
|
|
213 |
addActionError("We are experiencing some problems. Please try later.");
|
|
|
214 |
return "proceed-to-pay-redirect";
|
|
|
215 |
} else {
|
|
|
216 |
log.info("Successfully created payment for Innoviti to process. Redirecting to /innoviti-pay/" + paymentId);
|
|
|
217 |
return "innoviti-pay-redirect";
|
|
|
218 |
}
|
|
|
219 |
|
| 8428 |
rajveer |
220 |
case 17:
|
| 7862 |
anupam.sin |
221 |
IPaymentService couponPaymentService = new CouponPaymentService();
|
| 8428 |
rajveer |
222 |
paymentId = couponPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, 17);
|
| 7862 |
anupam.sin |
223 |
if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
|
|
|
224 |
//Very unlikely. The only possible reason can be that the payment service is down.
|
|
|
225 |
log.error("Unable to process the Coupon payment.");
|
|
|
226 |
addActionError("We are experiencing some problems. Please try later.");
|
|
|
227 |
return "proceed-to-pay-redirect";
|
|
|
228 |
} else {
|
|
|
229 |
CommonPaymentService.processCouponTxn(txnId);
|
|
|
230 |
return "cod-redirect";
|
|
|
231 |
}
|
| 6390 |
rajveer |
232 |
default:
|
|
|
233 |
break;
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
if(paymentOption.equals(IPaymentService.HDFC_MASTERCARD_CREDIT) || paymentOption.equals(IPaymentService.HDFC_MASTERCARD_DEBIT) ||
|
|
|
238 |
paymentOption.equals(IPaymentService.HDFC_VISA) || paymentOption.equals(IPaymentService.HDFC_VISA_ELECTRON)) {
|
|
|
239 |
// User has selected Visa or MasterCard
|
|
|
240 |
IPaymentService hdfcPaymentService = new HdfcPaymentService();
|
|
|
241 |
paymentId = hdfcPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, 1);
|
|
|
242 |
if (paymentId == IPaymentService.PAYMENT_NOT_CREATED) {
|
|
|
243 |
log.error("Unable to process payment through HDFC. Falling through to EBS.");
|
| 3616 |
chandransh |
244 |
} else {
|
| 6390 |
rajveer |
245 |
this.redirectURL = ((HdfcPaymentService)hdfcPaymentService).getRedirectUrl();
|
| 3616 |
chandransh |
246 |
log.info(this.redirectURL);
|
|
|
247 |
return "success";
|
|
|
248 |
}
|
| 6390 |
rajveer |
249 |
}
|
| 2199 |
chandransh |
250 |
|
| 6390 |
rajveer |
251 |
if(paymentOption.equals(IPaymentService.HDFC_VISA))
|
|
|
252 |
paymentOption = IPaymentService.EBS_VISA;
|
|
|
253 |
else if(paymentOption.equals(IPaymentService.HDFC_MASTERCARD_DEBIT) || paymentOption.equals(IPaymentService.HDFC_MASTERCARD_CREDIT))
|
|
|
254 |
paymentOption = IPaymentService.EBS_MASTERCARD;
|
|
|
255 |
else if(paymentOption.equals(IPaymentService.HDFC_VISA_ELECTRON))
|
|
|
256 |
paymentOption = null; //Since we don't know the bank's name in this case, we'll let the user select the bank on the EBS page.
|
|
|
257 |
|
|
|
258 |
// if(paymentOption.equals(IPaymentService.PAYU_CC)){
|
|
|
259 |
// paymentOption = IPaymentService.PAYU_CC;
|
|
|
260 |
// IPaymentService payuPaymentService = new PayuPaymentService();
|
|
|
261 |
// paymentId = payuPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, gatewayId);
|
|
|
262 |
// return "payu-pay-redirect";
|
|
|
263 |
// }
|
|
|
264 |
|
|
|
265 |
IPaymentService ebsPaymentService = new EbsPaymentService();
|
|
|
266 |
paymentId = ebsPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, 2);
|
|
|
267 |
if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
|
|
|
268 |
addActionError("We are experiencing some problems. Please try later.");
|
|
|
269 |
log.error("Unable to process payment through EBS.");
|
|
|
270 |
return "proceed-to-pay-redirect";
|
|
|
271 |
} else {
|
|
|
272 |
log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
|
|
|
273 |
return "ebs-pay-redirect";
|
|
|
274 |
}
|
|
|
275 |
}
|
|
|
276 |
|
| 8428 |
rajveer |
277 |
private boolean isCouponValid(Cart cart) {
|
|
|
278 |
String couponCode = cart.getCouponCode();
|
|
|
279 |
double totalAmountD;
|
|
|
280 |
if(couponCode == null || "".equals(couponCode))
|
|
|
281 |
totalAmountD = cart.getTotalPrice();
|
|
|
282 |
else
|
|
|
283 |
totalAmountD = cart.getDiscountedPrice();
|
|
|
284 |
if(totalAmountD == 0) {
|
|
|
285 |
return true;
|
|
|
286 |
}else{
|
|
|
287 |
return false;
|
|
|
288 |
}
|
|
|
289 |
}
|
|
|
290 |
|
| 6390 |
rajveer |
291 |
private long findGatewayId(String paymentOption){
|
|
|
292 |
long gatewayId = 0;
|
|
|
293 |
gatewayId = ProceedToPayController.getGatewayId(Long.parseLong(paymentOption));
|
|
|
294 |
if(gatewayId==0){
|
|
|
295 |
if(paymentOption.equals(IPaymentService.COD)){
|
| 6419 |
rajveer |
296 |
gatewayId = 4;
|
| 6390 |
rajveer |
297 |
}
|
| 7862 |
anupam.sin |
298 |
if(paymentOption.equals(IPaymentService.COUPON)){
|
| 8428 |
rajveer |
299 |
gatewayId = 17;
|
| 7862 |
anupam.sin |
300 |
}
|
| 3063 |
chandransh |
301 |
}
|
| 6390 |
rajveer |
302 |
return gatewayId;
|
| 572 |
chandransh |
303 |
}
|
| 6390 |
rajveer |
304 |
|
| 3063 |
chandransh |
305 |
/**
|
|
|
306 |
* Verifies if the recaptcha response matches the recaptcha challenge.
|
|
|
307 |
*
|
|
|
308 |
* @return True if the captcha was valid, false otherwise.
|
|
|
309 |
*/
|
|
|
310 |
private boolean verifyCaptcha() {
|
| 4609 |
phani.kuma |
311 |
String cookieCaptchaAnswer = getCookie(Captcha.NAME, true, "saholic");
|
|
|
312 |
String captchaReceived = (String) request.getParameter("captcha_response_field");
|
|
|
313 |
|
|
|
314 |
if (captchaReceived.equalsIgnoreCase(cookieCaptchaAnswer)) {
|
|
|
315 |
try {
|
|
|
316 |
DataLogger.logData(EventType.CAPTCHA_SUCCESS, getSessionId(), userinfo.getUserId(), userinfo.getEmail());
|
|
|
317 |
} catch (Exception e1) {
|
|
|
318 |
log.warn("Unable to log orders through the datalogger", e1);
|
|
|
319 |
}
|
|
|
320 |
return true;
|
|
|
321 |
}
|
|
|
322 |
else {
|
|
|
323 |
try {
|
|
|
324 |
DataLogger.logData(EventType.CAPTCHA_FAILED, getSessionId(), userinfo.getUserId(), userinfo.getEmail());
|
|
|
325 |
} catch (Exception e1) {
|
|
|
326 |
log.warn("Unable to log orders through the datalogger", e1);
|
|
|
327 |
}
|
|
|
328 |
return false;
|
|
|
329 |
}
|
| 3063 |
chandransh |
330 |
}
|
| 572 |
chandransh |
331 |
|
| 507 |
rajveer |
332 |
public String getId(){
|
|
|
333 |
return id;
|
|
|
334 |
}
|
| 419 |
rajveer |
335 |
|
| 507 |
rajveer |
336 |
public void setId(String id){
|
|
|
337 |
this.id = id;
|
|
|
338 |
}
|
| 419 |
rajveer |
339 |
|
| 507 |
rajveer |
340 |
public String getMyaccountHeaderSnippet(){
|
|
|
341 |
return htmlSnippets.get("MYACCOUNT_HEADER");
|
|
|
342 |
}
|
|
|
343 |
|
|
|
344 |
public String getOrderDetailsSnippet(){
|
|
|
345 |
return htmlSnippets.get("ORDER_DETAILS");
|
|
|
346 |
}
|
|
|
347 |
|
| 712 |
rajveer |
348 |
public long getTxn(){
|
|
|
349 |
return this.txnId;
|
| 517 |
rajveer |
350 |
}
|
| 894 |
rajveer |
351 |
|
|
|
352 |
/**
|
|
|
353 |
*
|
|
|
354 |
* @param addressId
|
|
|
355 |
* @param currentCartId
|
|
|
356 |
* @return
|
|
|
357 |
*/
|
| 6390 |
rajveer |
358 |
private boolean createOrders(long addressId, long currentCartId, long currentUserId, long emiSchemeId){
|
| 3126 |
rajveer |
359 |
UserClient userServiceClient = null;
|
| 894 |
rajveer |
360 |
try {
|
| 3126 |
rajveer |
361 |
userServiceClient = new UserClient();
|
| 894 |
rajveer |
362 |
} catch (Exception e) {
|
| 2296 |
chandransh |
363 |
log.error("Unable to talk to the user context service.", e);
|
| 894 |
rajveer |
364 |
return false;
|
|
|
365 |
}
|
|
|
366 |
|
|
|
367 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
|
|
|
368 |
try {
|
|
|
369 |
userClient.addAddressToCart(currentCartId, addressId);
|
|
|
370 |
} catch (ShoppingCartException e1) {
|
| 2296 |
chandransh |
371 |
log.error("Not able to set address in the cart.", e1);
|
| 894 |
rajveer |
372 |
return false;
|
|
|
373 |
} catch (TException e1) {
|
| 2296 |
chandransh |
374 |
log.error("Thrift exception while setting address in cart.", e1);
|
| 894 |
rajveer |
375 |
return false;
|
|
|
376 |
}
|
|
|
377 |
|
|
|
378 |
|
|
|
379 |
try {
|
| 6736 |
amit.gupta |
380 |
String errorMsg = userClient.validateCart(currentCartId, sourceId).get(0);
|
| 1466 |
ankur.sing |
381 |
if(!errorMsg.isEmpty()){
|
|
|
382 |
addActionError(errorMsg);
|
| 894 |
rajveer |
383 |
return false;
|
|
|
384 |
}
|
|
|
385 |
} catch (ShoppingCartException e1) {
|
| 2296 |
chandransh |
386 |
log.error("Error while validating shopping cart.", e1);
|
| 894 |
rajveer |
387 |
return false;
|
|
|
388 |
} catch (TException e) {
|
| 2296 |
chandransh |
389 |
log.error("Thrift exception while validating cart.", e);
|
| 894 |
rajveer |
390 |
return false;
|
|
|
391 |
}
|
|
|
392 |
|
|
|
393 |
|
|
|
394 |
try {
|
| 3859 |
vikas |
395 |
String sessionSrc = getCookie(TrackingInterceptor.SESSION_SRC_COOKIE, true, TrackingInterceptor.ENCRIPTION_STRING);
|
|
|
396 |
String firstSrc = getCookie(TrackingInterceptor.SRC_COOKIE, true, TrackingInterceptor.ENCRIPTION_STRING);
|
| 2817 |
vikas |
397 |
|
| 3859 |
vikas |
398 |
long sessionTime = 0;
|
|
|
399 |
try {
|
|
|
400 |
sessionTime = Long.parseLong(getCookie(TrackingInterceptor.SESSION_SRC_TIME_COOKIE, false, null));
|
|
|
401 |
} catch (Exception e) {
|
|
|
402 |
log.warn("Unable to parse session src time cookie.", e);
|
| 2817 |
vikas |
403 |
}
|
| 3859 |
vikas |
404 |
long firstSrcTime = 0;
|
|
|
405 |
try {
|
|
|
406 |
firstSrcTime = Long.parseLong(getCookie(TrackingInterceptor.SRC_TIME_COOKIE, false, null));
|
|
|
407 |
} catch (Exception e) {
|
|
|
408 |
log.warn("Unable to parse session src time cookie.", e);
|
|
|
409 |
}
|
| 6390 |
rajveer |
410 |
txnId = userClient.createOrders(currentCartId, sessionSrc, sessionTime, firstSrc, firstSrcTime, currentUserId, emiSchemeId);
|
| 894 |
rajveer |
411 |
} catch (ShoppingCartException e1) {
|
| 2296 |
chandransh |
412 |
log.error("Error while creating orders from cart.", e1);
|
| 894 |
rajveer |
413 |
return false;
|
|
|
414 |
} catch (TException e) {
|
| 2296 |
chandransh |
415 |
log.error("Thrift exception while creating orders from cart.", e);
|
| 894 |
rajveer |
416 |
return false;
|
|
|
417 |
}
|
|
|
418 |
|
| 3126 |
rajveer |
419 |
TransactionClient transactionServiceClient = null;
|
| 4325 |
mandeep.dh |
420 |
|
| 2183 |
vikas |
421 |
try {
|
| 3126 |
rajveer |
422 |
transactionServiceClient = new TransactionClient();
|
| 2183 |
vikas |
423 |
List<Order> orders = transactionServiceClient.getClient().getOrdersForTransaction(txnId, userinfo.getUserId());
|
|
|
424 |
for (Order order : orders) {
|
| 3394 |
vikas |
425 |
List<Order> tmpOrders = new ArrayList<Order>();
|
|
|
426 |
tmpOrders.add(order);
|
|
|
427 |
String itemIdString = Utils.getItemIdStringFromOrders(tmpOrders);
|
| 3209 |
vikas |
428 |
DataLogger.logData(EventType.ORDER_CREATION, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
|
| 3212 |
vikas |
429 |
Long.toString(order.getId()), Long.toString(currentCartId), itemIdString);
|
| 2183 |
vikas |
430 |
}
|
|
|
431 |
} catch (Exception e1) {
|
| 2296 |
chandransh |
432 |
log.warn("Unable to log orders through the datalogger", e1);
|
| 2183 |
vikas |
433 |
}
|
| 894 |
rajveer |
434 |
|
|
|
435 |
return true;
|
|
|
436 |
}
|
| 4325 |
mandeep.dh |
437 |
|
|
|
438 |
/**
|
|
|
439 |
* This method updates address of a given order.
|
|
|
440 |
*
|
|
|
441 |
* @return
|
|
|
442 |
*/
|
|
|
443 |
public String modifyAddress() {
|
|
|
444 |
long orderId = Long.parseLong(request.getParameter("orderId"));
|
|
|
445 |
long addressId = Long.valueOf(request.getParameter("addressId"));
|
|
|
446 |
|
|
|
447 |
try {
|
|
|
448 |
TransactionClient transactionServiceClient = new TransactionClient();
|
|
|
449 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient
|
|
|
450 |
= transactionServiceClient.getClient();
|
|
|
451 |
transactionClient.updateShipmentAddress(orderId, addressId);
|
| 7954 |
manish.sha |
452 |
in.shop2020.model.v1.order.Order t_order = transactionClient.getOrder(orderId);
|
|
|
453 |
if(t_order.getLogistics_provider_id()==7L){
|
|
|
454 |
FedExShipAccountInfo fedexAccountInfo = FedExShipAccountInfo.getFedExInfo();
|
|
|
455 |
ProcessShipmentReply processShipmentReply = ShipWebServiceClient.getShipmentCreationReply(t_order,fedexAccountInfo.getClientDetail(),fedexAccountInfo.getWad(),fedexAccountInfo.getEndPointAddress());
|
|
|
456 |
CompletedShipmentDetail completedShipmentDetails = processShipmentReply.getCompletedShipmentDetail();
|
|
|
457 |
CompletedPackageDetail completedPackageDetails = completedShipmentDetails.getCompletedPackageDetails(0);
|
|
|
458 |
TrackingId trackId= completedPackageDetails.getTrackingIds(0);
|
|
|
459 |
t_order = transactionClient.updateOrderAWB(t_order.getId(), trackId.getTrackingNumber());
|
|
|
460 |
}
|
| 4325 |
mandeep.dh |
461 |
} catch (TTransportException e) {
|
|
|
462 |
log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
|
|
|
463 |
} catch (NumberFormatException e) {
|
|
|
464 |
log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
|
|
|
465 |
} catch (TransactionServiceException e) {
|
|
|
466 |
log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
|
|
|
467 |
} catch (TException e) {
|
|
|
468 |
log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
|
|
|
469 |
}
|
|
|
470 |
|
|
|
471 |
return "index";
|
|
|
472 |
}
|
|
|
473 |
|
| 1318 |
rajveer |
474 |
public String getRedirectURL(){
|
|
|
475 |
return this.redirectURL;
|
|
|
476 |
}
|
| 5716 |
anupam.sin |
477 |
|
|
|
478 |
public String getDeliveryLocation() {
|
|
|
479 |
return deliveryLocation;
|
|
|
480 |
}
|
|
|
481 |
|
|
|
482 |
public void setDeliveryLocation(String deliveryLocation) {
|
|
|
483 |
this.deliveryLocation = deliveryLocation;
|
|
|
484 |
}
|
| 6050 |
anupam.sin |
485 |
|
|
|
486 |
public static void main(String[] args) {
|
|
|
487 |
DesEncrypter d = new DesEncrypter("shop2020");
|
|
|
488 |
System.out.println(d.decrypt("pmkcWEzhf4IFRLyHce89Cg"));
|
| 7001 |
rajveer |
489 |
long[] HDFC_EMI_GATEWAY_IDS = {5,10,11,12};
|
|
|
490 |
List<Long> stooges = Arrays.asList(5L,10L,11L,12L);
|
|
|
491 |
List<Long> lista = new ArrayList<Long>();
|
|
|
492 |
lista.add(5L);
|
|
|
493 |
lista.add(10L);
|
|
|
494 |
lista.add(11L);
|
|
|
495 |
lista.add(12L);
|
|
|
496 |
long gatewayId = 10;
|
|
|
497 |
if(stooges.contains(gatewayId)){
|
|
|
498 |
System.out.println("true");
|
|
|
499 |
}else{
|
|
|
500 |
System.out.println("false");
|
|
|
501 |
}
|
| 6050 |
anupam.sin |
502 |
}
|
| 419 |
rajveer |
503 |
}
|