Subversion Repositories SmartDukaan

Rev

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

Rev 8804 Rev 8806
Line 340... Line 340...
340
			} catch (TException e) {
340
			} catch (TException e) {
341
				logger.error("Problem with transaction service while creating transaction", e);
341
				logger.error("Problem with transaction service while creating transaction", e);
342
				sb.append(order.getSuborderId() + " Transaction Service Exception could not create transaction" +"\n");
342
				sb.append(order.getSuborderId() + " Transaction Service Exception could not create transaction" +"\n");
343
				continue;
343
				continue;
344
			}
344
			}
-
 
345
			try{
345
			createPayment(user, (new Long(subOrderId)).toString(),lineItem.getTotal_price());
346
				createPayment(user, (new Long(subOrderId)).toString(),lineItem.getTotal_price());
-
 
347
			}
-
 
348
			catch (NumberFormatException e) {
-
 
349
				logger.error("Could not create payment",e);
-
 
350
				sb.append(order.getSuborderId() + " Could not create payment");
-
 
351
				e.printStackTrace();
-
 
352
				continue;
-
 
353
			} catch (PaymentException e) {
-
 
354
				logger.error("Could not create payment payment exception",e);
-
 
355
				sb.append(order.getSuborderId() + " Could not create payment Payment exception");
-
 
356
				e.printStackTrace();
-
 
357
				continue;
-
 
358
			} catch (TException e) {
-
 
359
				logger.error("Could not create payment thrift exception",e);
-
 
360
				sb.append(order.getSuborderId() + " Could not create payment Thrift exception");
-
 
361
				e.printStackTrace();
-
 
362
				continue;
-
 
363
			}
346
			Transaction transaction = null;
364
			Transaction transaction = null;
347
			try {
365
			try {
348
				transaction = transaction_client.getTransaction(Long.parseLong(transactionId));
366
				transaction = transaction_client.getTransaction(Long.parseLong(transactionId));
349
			} catch (NumberFormatException e) {
367
			} catch (NumberFormatException e) {
350
				logger.error("Problem parsing transaction id " + transactionId);
368
				logger.error("Problem parsing transaction id " + transactionId);
Line 396... Line 414...
396
		String emailFromAddress = "build@shop2020.in";
414
		String emailFromAddress = "build@shop2020.in";
397
		String password = "cafe@nes";
415
		String password = "cafe@nes";
398
		GmailUtils mailer = new GmailUtils();
416
		GmailUtils mailer = new GmailUtils();
399
		String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
417
		String sendTo[] = new String[]{"vikram.raghav@shop2020.in"};
400
		//String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in","khushal.bhatia@shop2020.in","rajveer.singh@saholic.com","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com"};
418
		//String sendTo[] = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in","khushal.bhatia@shop2020.in","rajveer.singh@saholic.com","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com"};
401
		
419
 
402
		try {
420
		try {
403
			if(new_orders==processed_orders && new_orders > 0){
421
			if(new_orders==processed_orders && new_orders > 0){
404
				String emailSubjectTxt = "Snapdeal Orders Created Successfully "+sdf.format(cal.getTime());
422
				String emailSubjectTxt = "Snapdeal Orders Created Successfully "+sdf.format(cal.getTime());
405
				String text = "Total Orders Received : " + ( new_orders + duplicate_orders ) + "\n" + 
423
				String text = "Total Orders Received : " + ( new_orders + duplicate_orders ) + "\n" + 
406
				"Orders Already Existing : " + duplicate_orders + "\n" +
424
				"Orders Already Existing : " + duplicate_orders + "\n" +
Line 434... Line 452...
434
 
452
 
435
 
453
 
436
 
454
 
437
	}
455
	}
438
 
456
 
439
	public static void createPayment(User user, String subOrderId, double amount) {
457
	public static void createPayment(User user, String subOrderId, double amount) throws NumberFormatException, PaymentException, TException {
440
		in.shop2020.payments.PaymentService.Client client = null;
458
	    in.shop2020.payments.PaymentService.Client client = new PaymentClient().getClient();
441
		try {
-
 
442
			client = new PaymentClient().getClient();
-
 
443
		} catch (TTransportException e) {
-
 
444
			logger.error("Could not connect to payment service ");
-
 
445
			e.printStackTrace();
-
 
446
		}
-
 
447
		long paymentId = 0;
-
 
448
		try {
-
 
449
			paymentId = client.createPayment(user.getUserId(), amount, SNAPDEAL_GATEWAY_ID, Long.valueOf(transactionId), false);
459
        long paymentId = client.createPayment(user.getUserId(), amount, SNAPDEAL_GATEWAY_ID, Long.valueOf(transactionId), false);
450
		} catch (NumberFormatException e) {
-
 
451
			logger.error("Could not create payment");
-
 
452
			e.printStackTrace();
-
 
453
		} catch (PaymentException e) {
-
 
454
			logger.error("Could not create payment payment exception");
-
 
455
			e.printStackTrace();
-
 
456
		} catch (TException e) {
-
 
457
			logger.error("Could not create payment thrift exception");
-
 
458
			e.printStackTrace();
-
 
459
		}
-
 
460
		try {
-
 
461
			client.updatePaymentDetails(paymentId, null, null, null, null, null, null, subOrderId, null, PaymentStatus.AUTHORIZED, null, null);
460
        client.updatePaymentDetails(paymentId, null, null, null, null, null, null, subOrderId, null, PaymentStatus.AUTHORIZED, null, null);
462
		} catch (PaymentException e) {
-
 
463
			logger.error("Could not update payment to order");
-
 
464
			e.printStackTrace();
-
 
465
		} catch (TException e) {
-
 
466
			logger.error("Could not update payment thrift exception");
-
 
467
			e.printStackTrace();
-
 
468
		}
-
 
469
	}   
461
	}   
470
 
462
 
471
	public static LineItem createLineItem(long itemId, double amount) throws CatalogServiceException, TException {
463
	public static LineItem createLineItem(long itemId, double amount) throws CatalogServiceException, TException {
472
		LineItem lineItem = new LineItem();
464
		LineItem lineItem = new LineItem();
473
		CatalogService.Client catalogClient = new CatalogClient().getClient();
465
		CatalogService.Client catalogClient = new CatalogClient().getClient();