Subversion Repositories SmartDukaan

Rev

Rev 8940 | Rev 10968 | 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) {
250
                log.error("Unable to process payment through HDFC. Falling through to EBS.");
3616 chandransh 251
            } else {
6390 rajveer 252
                this.redirectURL = ((HdfcPaymentService)hdfcPaymentService).getRedirectUrl();
3616 chandransh 253
                log.info(this.redirectURL);
254
                return "success";
255
            }
6390 rajveer 256
        }
2199 chandransh 257
 
6390 rajveer 258
        if(paymentOption.equals(IPaymentService.HDFC_VISA))
259
            paymentOption = IPaymentService.EBS_VISA;
260
        else if(paymentOption.equals(IPaymentService.HDFC_MASTERCARD_DEBIT) || paymentOption.equals(IPaymentService.HDFC_MASTERCARD_CREDIT))
261
            paymentOption = IPaymentService.EBS_MASTERCARD;
262
        else if(paymentOption.equals(IPaymentService.HDFC_VISA_ELECTRON))
263
            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.
264
 
265
//        if(paymentOption.equals(IPaymentService.PAYU_CC)){
266
//        	paymentOption = IPaymentService.PAYU_CC;
267
//        	IPaymentService payuPaymentService = new PayuPaymentService();
268
//        	paymentId = payuPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, gatewayId);
269
//        	return "payu-pay-redirect";
270
//        }
271
 
272
        IPaymentService ebsPaymentService = new EbsPaymentService();
273
        paymentId = ebsPaymentService.createPayment(userinfo.getUserId(), txnId, paymentOption, 2);
274
        if(paymentId == IPaymentService.PAYMENT_NOT_CREATED){
275
            addActionError("We are experiencing some problems. Please try later.");
276
            log.error("Unable to process payment through EBS.");
277
            return "proceed-to-pay-redirect";
278
        } else {
279
            log.info("Successfully created payment for EBS to process. Redirecting to /ebs-pay/" + paymentId);
280
            return "ebs-pay-redirect";
281
        }    	    
282
	}
283
 
8428 rajveer 284
    private boolean isCouponValid(Cart cart) {
285
    	String couponCode = cart.getCouponCode();
286
    	double totalAmountD;
287
        if(couponCode == null || "".equals(couponCode))
288
        	totalAmountD = cart.getTotalPrice();
289
        else
290
            totalAmountD = cart.getDiscountedPrice();
291
        if(totalAmountD == 0) {
292
            return true;
293
        }else{
294
        	return false;
295
        }
296
    }
297
 
6390 rajveer 298
    private long findGatewayId(String paymentOption){
299
    	long gatewayId = 0;
300
    	gatewayId = ProceedToPayController.getGatewayId(Long.parseLong(paymentOption));
301
    	if(gatewayId==0){
302
    		if(paymentOption.equals(IPaymentService.COD)){
6419 rajveer 303
    			gatewayId = 4;
6390 rajveer 304
    		}
7862 anupam.sin 305
    		if(paymentOption.equals(IPaymentService.COUPON)){
8428 rajveer 306
                gatewayId = 17;
7862 anupam.sin 307
            }
3063 chandransh 308
    	}
6390 rajveer 309
    	return gatewayId;
572 chandransh 310
    }
6390 rajveer 311
 
3063 chandransh 312
    /**
313
     * Verifies if the recaptcha response matches the recaptcha challenge.
314
     * 
315
     * @return True if the captcha was valid, false otherwise.
316
     */
317
    private boolean verifyCaptcha() {
4609 phani.kuma 318
        String cookieCaptchaAnswer = getCookie(Captcha.NAME, true, "saholic");
319
    	String captchaReceived = (String) request.getParameter("captcha_response_field");
320
 
321
    	if (captchaReceived.equalsIgnoreCase(cookieCaptchaAnswer)) {
322
			try {
323
				DataLogger.logData(EventType.CAPTCHA_SUCCESS, getSessionId(), userinfo.getUserId(), userinfo.getEmail());
324
			} catch (Exception e1) {
325
	        	log.warn("Unable to log orders through the datalogger", e1);
326
	        }
327
			return true;
328
		} 
329
		else {
330
			try {
331
				DataLogger.logData(EventType.CAPTCHA_FAILED, getSessionId(), userinfo.getUserId(), userinfo.getEmail());
332
			} catch (Exception e1) {
333
	        	log.warn("Unable to log orders through the datalogger", e1);
334
	        }
335
			return false;
336
		}
3063 chandransh 337
    }
572 chandransh 338
 
507 rajveer 339
	public String getId(){
340
		return id;
341
	}
419 rajveer 342
 
507 rajveer 343
	public void setId(String id){
344
		this.id = id;
345
	}
419 rajveer 346
 
507 rajveer 347
	public String getMyaccountHeaderSnippet(){
348
		return htmlSnippets.get("MYACCOUNT_HEADER");
349
	}
350
 
351
	public String getOrderDetailsSnippet(){
352
		return htmlSnippets.get("ORDER_DETAILS");
353
	}
354
 
712 rajveer 355
	public long getTxn(){
356
		return this.txnId;
517 rajveer 357
	}
894 rajveer 358
 
359
	/**
360
	 * 
361
	 * @param addressId
362
	 * @param currentCartId
363
	 * @return
364
	 */
6390 rajveer 365
	private boolean createOrders(long addressId, long currentCartId, long currentUserId, long emiSchemeId){
3126 rajveer 366
		UserClient userServiceClient = null;
894 rajveer 367
		try {
3126 rajveer 368
			userServiceClient = new UserClient();
894 rajveer 369
		} catch (Exception e) {
2296 chandransh 370
			log.error("Unable to talk to the user context service.", e);
894 rajveer 371
			return false;
372
		}
373
 
374
		in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
375
		try {
376
			userClient.addAddressToCart(currentCartId, addressId);
377
		} catch (ShoppingCartException e1) {
2296 chandransh 378
			log.error("Not able to set address in the cart.", e1);
894 rajveer 379
			return false;
380
		} catch (TException e1) {
2296 chandransh 381
			log.error("Thrift exception while setting address in cart.", e1);
894 rajveer 382
			return false;
383
		}
384
 
385
 
386
		try {
6736 amit.gupta 387
			String errorMsg = userClient.validateCart(currentCartId, sourceId).get(0); 
1466 ankur.sing 388
			if(!errorMsg.isEmpty()){
389
				addActionError(errorMsg);
894 rajveer 390
				return false;
391
			}
392
		} catch (ShoppingCartException e1) {
2296 chandransh 393
			log.error("Error while validating shopping cart.", e1);
894 rajveer 394
			return false;
395
		} catch (TException e) {
2296 chandransh 396
			log.error("Thrift exception while validating cart.", e);
894 rajveer 397
			return false;
398
		}
399
 
400
 
401
		try {
3859 vikas 402
		    String sessionSrc = getCookie(TrackingInterceptor.SESSION_SRC_COOKIE, true, TrackingInterceptor.ENCRIPTION_STRING);
403
		    String firstSrc = getCookie(TrackingInterceptor.SRC_COOKIE, true, TrackingInterceptor.ENCRIPTION_STRING);
2817 vikas 404
 
3859 vikas 405
		    long sessionTime = 0;
406
            try {
407
                sessionTime = Long.parseLong(getCookie(TrackingInterceptor.SESSION_SRC_TIME_COOKIE, false, null));
408
            } catch (Exception e) {
409
                log.warn("Unable to parse session src time cookie.", e);
2817 vikas 410
            }
3859 vikas 411
            long firstSrcTime = 0;
412
            try {
413
                firstSrcTime = Long.parseLong(getCookie(TrackingInterceptor.SRC_TIME_COOKIE, false, null));
414
            } catch (Exception e) {
415
                log.warn("Unable to parse session src time cookie.", e);
416
            }
6390 rajveer 417
            txnId = userClient.createOrders(currentCartId, sessionSrc, sessionTime, firstSrc, firstSrcTime, currentUserId, emiSchemeId);
894 rajveer 418
		} catch (ShoppingCartException e1) {
2296 chandransh 419
			log.error("Error while creating orders from cart.", e1);
894 rajveer 420
			return false;
421
		} catch (TException e) {
2296 chandransh 422
			log.error("Thrift exception while creating orders from cart.", e);
894 rajveer 423
			return false;
424
		}
425
 
3126 rajveer 426
		TransactionClient transactionServiceClient = null;
4325 mandeep.dh 427
 
2183 vikas 428
        try {
3126 rajveer 429
            transactionServiceClient = new TransactionClient();
2183 vikas 430
            List<Order> orders = transactionServiceClient.getClient().getOrdersForTransaction(txnId, userinfo.getUserId());
431
            for (Order order : orders) {
3394 vikas 432
                List<Order> tmpOrders = new ArrayList<Order>();
433
                tmpOrders.add(order);
434
                String itemIdString = Utils.getItemIdStringFromOrders(tmpOrders);
3209 vikas 435
                DataLogger.logData(EventType.ORDER_CREATION, getSessionId(), userinfo.getUserId(), userinfo.getEmail(), 
3212 vikas 436
                        Long.toString(order.getId()), Long.toString(currentCartId), itemIdString);
2183 vikas 437
            }
438
        } catch (Exception e1) {
2296 chandransh 439
        	log.warn("Unable to log orders through the datalogger", e1);
2183 vikas 440
        }
894 rajveer 441
 
442
		return true;
443
	}
4325 mandeep.dh 444
 
445
	/**
446
	 * This method updates address of a given order.
447
	 *
448
	 * @return
449
	 */
450
	public String modifyAddress() {
451
        long orderId   = Long.parseLong(request.getParameter("orderId"));
452
        long addressId = Long.valueOf(request.getParameter("addressId"));
453
 
454
		try {
455
		    TransactionClient transactionServiceClient = new TransactionClient();
456
			in.shop2020.model.v1.order.TransactionService.Client transactionClient
457
			    = transactionServiceClient.getClient();			
458
			transactionClient.updateShipmentAddress(orderId, addressId);
7954 manish.sha 459
			in.shop2020.model.v1.order.Order t_order = transactionClient.getOrder(orderId);
9338 manish.sha 460
			Warehouse warehouse = null;
461
			try{
462
	    		InventoryClient isc = new InventoryClient();
463
	    		warehouse = isc.getClient().getWarehouse(t_order.getWarehouse_id());
464
			} catch(Exception e) {
465
			    log.error("Unable to get warehouse for id : " + t_order.getWarehouse_id(), e);
466
			    //TODO throw e;
467
			}
7954 manish.sha 468
			if(t_order.getLogistics_provider_id()==7L){
9338 manish.sha 469
				FedExShipAccountInfo fedexAccountInfo = FedExShipAccountInfo.getFedExInfo(warehouse.getLogisticsLocation());
7954 manish.sha 470
				ProcessShipmentReply  processShipmentReply = ShipWebServiceClient.getShipmentCreationReply(t_order,fedexAccountInfo.getClientDetail(),fedexAccountInfo.getWad(),fedexAccountInfo.getEndPointAddress());
471
				CompletedShipmentDetail completedShipmentDetails = processShipmentReply.getCompletedShipmentDetail();
472
				CompletedPackageDetail completedPackageDetails =  completedShipmentDetails.getCompletedPackageDetails(0);
473
				TrackingId  trackId= completedPackageDetails.getTrackingIds(0);
474
				t_order = transactionClient.updateOrderAWB(t_order.getId(), trackId.getTrackingNumber());
8940 manish.sha 475
				//Start:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
476
				CompletedPackageDetail[] cpd= completedShipmentDetails.getCompletedPackageDetails();
477
				AssociatedShipmentDetail[] asdetails = completedShipmentDetails.getAssociatedShipments();
478
				List<Attribute> attrList = new ArrayList<Attribute>();
479
				if(t_order.isCod()){
480
					if(asdetails!=null){
481
						for(AssociatedShipmentDetail as : asdetails){
482
							if(as.getType().getValue().equalsIgnoreCase("COD_RETURN")){
483
								PackageOperationalDetail pod = as.getPackageOperationalDetail();
484
								StringBarcode[] barcodes = pod.getBarcodes().getStringBarcodes();
485
								for(StringBarcode bc : barcodes){
486
									Attribute attr3 = new Attribute();
487
									attr3.setName("FedEx_COD_Return_BarCode");
488
									attr3.setValue(bc.getValue());
489
									attrList.add(attr3);
490
								}
491
 
492
								String codReturnTrackingNo= as.getTrackingId().getTrackingNumber();
493
								Attribute attr4 = new Attribute();
494
								attr4.setName("FedEx_COD_Return_Tracking_No");
495
								attr4.setValue(codReturnTrackingNo);
496
								attrList.add(attr4);
497
							}
498
						}
499
					}
500
				}
501
				for(CompletedPackageDetail cd : cpd){
502
					PackageOperationalDetail pod = cd.getOperationalDetail();
503
					StringBarcode[] barcodes = pod.getBarcodes().getStringBarcodes();
504
					for(StringBarcode bc : barcodes){
505
						Attribute attr1 = new Attribute();
506
						attr1.setName("FedEx_Package_BarCode");
507
						attr1.setValue(bc.getValue());
508
						attrList.add(attr1);
509
					}
510
					OperationalInstruction[] ois = pod.getOperationalInstructions();
511
					Attribute attr2 = new Attribute();
512
					for(OperationalInstruction oi : ois){
513
						if(oi.getNumber().intValue()==5){
514
							attr2.setName("FedEx_Location_Code");
515
							attr2.setValue(oi.getContent());
516
							attrList.add(attr2);
517
						}
518
					}						
519
				}
520
				transactionClient.setOrderAttributes(t_order.getId(), attrList);
521
				//End:-Added By Manish Sharma for FedEx Integration - Shipment Creation on 21-Aug-2013
522
 
7954 manish.sha 523
			}
4325 mandeep.dh 524
		} catch (TTransportException e) {
525
		    log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
526
		} catch (NumberFormatException e) {
527
		    log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
528
		} catch (TransactionServiceException e) {
529
		    log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
530
		} catch (TException e) {
531
		    log.error("Could not update address: " + addressId + " for orderId: " + orderId, e);
532
		}			
533
 
534
		return "index";
535
	}
536
 
1318 rajveer 537
	public String getRedirectURL(){
538
		return this.redirectURL;
539
	}
5716 anupam.sin 540
 
541
    public String getDeliveryLocation() {
542
        return deliveryLocation;
543
    }
544
 
545
    public void setDeliveryLocation(String deliveryLocation) {
546
        this.deliveryLocation = deliveryLocation;
547
    }
6050 anupam.sin 548
 
549
    public static void main(String[] args) {
550
        DesEncrypter d = new DesEncrypter("shop2020");
551
        System.out.println(d.decrypt("pmkcWEzhf4IFRLyHce89Cg"));
7001 rajveer 552
    	long[] HDFC_EMI_GATEWAY_IDS = {5,10,11,12};
553
    	List<Long> stooges = Arrays.asList(5L,10L,11L,12L);
554
    	List<Long> lista = new ArrayList<Long>();
555
    	lista.add(5L);
556
    	lista.add(10L);
557
    	lista.add(11L);
558
    	lista.add(12L);
559
    	long gatewayId = 10;
560
    	if(stooges.contains(gatewayId)){
561
    		System.out.println("true");
562
    	}else{
563
    		System.out.println("false");
564
    	}
6050 anupam.sin 565
    }
419 rajveer 566
}