Subversion Repositories SmartDukaan

Rev

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