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