| Line 63... |
Line 63... |
| 63 |
private static final long FLIPKART_SOURCE_ID = 8;
|
63 |
private static final long FLIPKART_SOURCE_ID = 8;
|
| 64 |
private static final int FLIPKART_GATEWAY_ID = 17;
|
64 |
private static final int FLIPKART_GATEWAY_ID = 17;
|
| 65 |
private static final int FLIPKART_LOGISTICS_ID = 19;
|
65 |
private static final int FLIPKART_LOGISTICS_ID = 19;
|
| 66 |
private static String transactionId;
|
66 |
private static String transactionId;
|
| 67 |
|
67 |
|
| 68 |
private static Logger logger = LoggerFactory.getLogger(FetchNewFlipCartOrders .class);
|
68 |
private static Logger logger = LoggerFactory.getLogger(FetchNewFlipCartOrders .class);
|
| - |
|
69 |
private static long paymentId;
|
| 69 |
public static void main(String[] args) throws CatalogServiceException, TException, IOException {
|
70 |
public static void main(String[] args) throws CatalogServiceException, TException, IOException {
|
| 70 |
HttpClient client = new DefaultHttpClient();
|
71 |
HttpClient client = new DefaultHttpClient();
|
| 71 |
HttpPost post = new HttpPost("https://seller.flipkart.com/login");
|
72 |
HttpPost post = new HttpPost("https://seller.flipkart.com/login");
|
| 72 |
BufferedReader rd= null;
|
73 |
BufferedReader rd= null;
|
| 73 |
try {
|
74 |
try {
|
| Line 547... |
Line 548... |
| 547 |
logger.info(orderId+" "+subOrderId + " Transaction Service Exception could not create transaction" +"\n" , e);
|
548 |
logger.info(orderId+" "+subOrderId + " Transaction Service Exception could not create transaction" +"\n" , e);
|
| 548 |
continue;
|
549 |
continue;
|
| 549 |
}
|
550 |
}
|
| 550 |
try{
|
551 |
try{
|
| 551 |
logger.info("Creating payment for suborder id " + subOrderId +" ");
|
552 |
logger.info("Creating payment for suborder id " + subOrderId +" ");
|
| 552 |
createPayment(user,subOrderId,total_price);
|
553 |
paymentId = createPayment(user,subOrderId,total_price);
|
| 553 |
}
|
554 |
}
|
| 554 |
catch (NumberFormatException e) {
|
555 |
catch (NumberFormatException e) {
|
| 555 |
logger.error("Could not create payment",e);
|
556 |
logger.error("Could not create payment",e);
|
| 556 |
sb.append(orderId+" "+subOrderId + " Could not create payment");
|
557 |
sb.append(orderId+" "+subOrderId + " Could not create payment");
|
| 557 |
e.printStackTrace();
|
558 |
e.printStackTrace();
|
| Line 608... |
Line 609... |
| 608 |
if(transaction_client == null){
|
609 |
if(transaction_client == null){
|
| 609 |
transaction_client = new TransactionClient().getClient();
|
610 |
transaction_client = new TransactionClient().getClient();
|
| 610 |
}
|
611 |
}
|
| 611 |
transaction_client.createFlipkartOrder(flipkartOrder);
|
612 |
transaction_client.createFlipkartOrder(flipkartOrder);
|
| 612 |
transaction_client.setOrderAttributes(flipkartOrder.getOrderId(),attributeList);
|
613 |
transaction_client.setOrderAttributes(flipkartOrder.getOrderId(),attributeList);
|
| - |
|
614 |
logger.info("transaction id : " + Long.valueOf(transactionId) + " Payment id : " + paymentId);
|
| - |
|
615 |
new PaymentClient().getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, subOrderId, null, PaymentStatus.SUCCESS, null, null);
|
| 613 |
orders_processed++;
|
616 |
orders_processed++;
|
| 614 |
} catch (TException e) {
|
617 |
} catch (TException e) {
|
| 615 |
logger.error("Could not create flipkart order ",e);
|
618 |
logger.error("Could not create flipkart order ",e);
|
| 616 |
sb.append(orderId+" "+subOrderId + " Could not create flipkart order"+"\n");
|
619 |
sb.append(orderId+" "+subOrderId + " Could not create flipkart order"+"\n");
|
| 617 |
continue;
|
620 |
continue;
|
| - |
|
621 |
} catch (PaymentException e) {
|
| - |
|
622 |
logger.error("Could not update flipkart order payment ",e);
|
| - |
|
623 |
sb.append(orderId+" "+subOrderId + " Could not update flipkart order payment"+"\n");
|
| - |
|
624 |
continue;
|
| 618 |
}
|
625 |
}
|
| 619 |
|
626 |
|
| 620 |
} catch (InventoryServiceException e1) {
|
627 |
} catch (InventoryServiceException e1) {
|
| 621 |
logger.error("Problem while reserving item in inventory service" + flipkartorder.getId() + " ",e1);
|
628 |
logger.error("Problem while reserving item in inventory service" + flipkartorder.getId() + " ",e1);
|
| 622 |
sb.append(orderId+" "+subOrderId + " Could not reserve inventory for sku "+ sku +"\n");
|
629 |
sb.append(orderId+" "+subOrderId + " Could not reserve inventory for sku "+ sku +"\n");
|
| Line 705... |
Line 712... |
| 705 |
} else {
|
712 |
} else {
|
| 706 |
lineItem.setColor(item.getColor());
|
713 |
lineItem.setColor(item.getColor());
|
| 707 |
}
|
714 |
}
|
| 708 |
return lineItem;
|
715 |
return lineItem;
|
| 709 |
}
|
716 |
}
|
| 710 |
public static void createPayment(User user, String subOrderId, double amount) throws PaymentException, TException {
|
717 |
public static long createPayment(User user, String subOrderId, double amount) throws PaymentException, TException {
|
| 711 |
in.shop2020.payments.PaymentService.Client client = new PaymentClient().getClient();
|
718 |
in.shop2020.payments.PaymentService.Client client = new PaymentClient().getClient();
|
| 712 |
logger.info("Creating payment for user id " + user.getUserId() + " Gateway id " + FLIPKART_GATEWAY_ID);
|
719 |
logger.info("Creating payment for user id " + user.getUserId() + " Gateway id " + FLIPKART_GATEWAY_ID);
|
| 713 |
logger.info("Long value of transaction id : " + Long.valueOf(transactionId));
|
720 |
logger.info("Long value of transaction id : " + Long.valueOf(transactionId));
|
| 714 |
long paymentId = client.createPayment(user.getUserId(), amount, FLIPKART_GATEWAY_ID, Long.valueOf(transactionId), false);
|
721 |
long paymentId = client.createPayment(user.getUserId(), amount, FLIPKART_GATEWAY_ID, Long.valueOf(transactionId), false);
|
| 715 |
logger.info("transaction id : " + Long.valueOf(transactionId) + " Payment id : " + paymentId);
|
722 |
return paymentId;
|
| 716 |
client.updatePaymentDetails(paymentId, null, null, null, null, null, null, subOrderId, null, PaymentStatus.AUTHORIZED, null, null);
|
- |
|
| 717 |
}
|
723 |
}
|
| 718 |
|
724 |
|
| 719 |
|
725 |
|
| 720 |
|
726 |
|
| 721 |
}
|
727 |
}
|
| 722 |
|
728 |
|