Subversion Repositories SmartDukaan

Rev

Rev 9148 | Rev 9187 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9148 Rev 9151
Line 78... Line 78...
78
	private static final String QUANTIUM = "Quantium Solutions";
78
	private static final String QUANTIUM = "Quantium Solutions";
79
	private static final String GATI_AIR = "GATI AIR";
79
	private static final String GATI_AIR = "GATI AIR";
80
	private static final String VDELIVER = "VDELIVER";
80
	private static final String VDELIVER = "VDELIVER";
81
	private static final String OVERNITE_EXP = "Overnite Express";
81
	private static final String OVERNITE_EXP = "Overnite Express";
82
	private static String transactionId;
82
	private static String transactionId;
-
 
83
	private static long paymentId;
83
	private static final int SNAPDEAL_GATEWAY_ID = 18;
84
	private static final int SNAPDEAL_GATEWAY_ID = 18;
84
	private static Logger logger;
85
	private static Logger logger;
85
 
86
 
86
	public static void processSnapdealOrders(File file) throws JAXBException{
87
	public static void processSnapdealOrders(File file) throws JAXBException{
87
		logger = LoggerFactory.getLogger(ProcessSnapdealOrder.class);
88
		logger = LoggerFactory.getLogger(ProcessSnapdealOrder.class);
Line 372... Line 373...
372
				logger.error("Problem with transaction service while creating transaction", e);
373
				logger.error("Problem with transaction service while creating transaction", e);
373
				sb.append(order.getSuborderId() + " Transaction Service Exception could not create transaction" +"\n");
374
				sb.append(order.getSuborderId() + " Transaction Service Exception could not create transaction" +"\n");
374
				continue;
375
				continue;
375
			}
376
			}
376
			try{
377
			try{
377
				createPayment(user, (new Long(subOrderId)).toString(),lineItem.getTotal_price());
378
				paymentId = createPayment(user, (new Long(subOrderId)).toString(),lineItem.getTotal_price());
378
			}
379
			}
379
			catch (NumberFormatException e) {
380
			catch (NumberFormatException e) {
380
				logger.error("Could not create payment",e);
381
				logger.error("Could not create payment",e);
381
				sb.append(order.getSuborderId() + " Could not create payment");
382
				sb.append(order.getSuborderId() + " Could not create payment");
382
				e.printStackTrace();
383
				e.printStackTrace();
Line 431... Line 432...
431
			snapdealOrder.setProductName(productName);
432
			snapdealOrder.setProductName(productName);
432
			snapdealOrder.setSnapdealTxnDate(snapdealTxnDate.getTime());
433
			snapdealOrder.setSnapdealTxnDate(snapdealTxnDate.getTime());
433
			snapdealOrder.setListingPrice(order.getSellingPricePerItem());
434
			snapdealOrder.setListingPrice(order.getSellingPricePerItem());
434
			try {
435
			try {
435
				transaction_client.createSnapdealOrder(snapdealOrder);
436
				transaction_client.createSnapdealOrder(snapdealOrder);
-
 
437
				new PaymentClient().getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, Long.toString(subOrderId), null, PaymentStatus.SUCCESS, null, null);
-
 
438
				
436
			} catch (TException e) {
439
			} catch (TException e) {
437
				logger.error("Could not create Snapdeal Order");
440
				logger.error("Could not create Snapdeal Order");
438
				sb.append(order.getSuborderId() + " Could not create snapdeal order"+"\n");
441
				sb.append(order.getSuborderId() + " Could not create snapdeal order"+"\n");
-
 
442
			} catch (PaymentException e) {
-
 
443
				logger.error("Could not update payment for Snapdeal Order");
-
 
444
				sb.append(order.getSuborderId() + " Could not update payment for snapdeal order"+"\n");
439
			}
445
			}
440
			processed_orders++;
446
			processed_orders++;
441
 
447
 
442
		}
448
		}
443
		java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
449
		java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
Line 489... Line 495...
489
 
495
 
490
 
496
 
491
 
497
 
492
	}
498
	}
493
 
499
 
494
	public static void createPayment(User user, String subOrderId, double amount) throws NumberFormatException, PaymentException, TException {
500
	public static long createPayment(User user, String subOrderId, double amount) throws NumberFormatException, PaymentException, TException {
495
	    in.shop2020.payments.PaymentService.Client client = new PaymentClient().getClient();
501
	    in.shop2020.payments.PaymentService.Client client = new PaymentClient().getClient();
496
        long paymentId = client.createPayment(user.getUserId(), amount, SNAPDEAL_GATEWAY_ID, Long.valueOf(transactionId), false);
502
        return client.createPayment(user.getUserId(), amount, SNAPDEAL_GATEWAY_ID, Long.valueOf(transactionId), false);
497
        client.updatePaymentDetails(paymentId, null, null, null, null, null, null, subOrderId, null, PaymentStatus.AUTHORIZED, null, null);
-
 
-
 
503
        
498
	}   
504
	}   
499
 
505
 
500
	public static LineItem createLineItem(long itemId, double amount) throws CatalogServiceException, TException {
506
	public static LineItem createLineItem(long itemId, double amount) throws CatalogServiceException, TException {
501
		LineItem lineItem = new LineItem();
507
		LineItem lineItem = new LineItem();
502
		CatalogService.Client catalogClient = new CatalogClient().getClient();
508
		CatalogService.Client catalogClient = new CatalogClient().getClient();