Subversion Repositories SmartDukaan

Rev

Rev 9338 | Rev 11526 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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