OrderArrayType orderArr = resp.getOrderArray();
OrderType[] orderTypeList = orderArr.getOrder();
for (OrderType order : orderTypeList) {
String orderID = order.getOrderID();
if (orderID.equals(externalId)) {
AddOrderCall addOrderCall = new AddOrderCall(apiContext);
AddOrderRequestType addReq = new AddOrderRequestType();
AddOrderResponseType addResp = null;
OrderType newOrder = new OrderType();
ShippingDetailsType shippingDetail = (ShippingDetailsType) order.getShippingDetails();
if (trackingOrders.size() > 0) {
ShipmentTrackingDetailsType[] trackDetails = new ShipmentTrackingDetailsType[trackingOrders.size()];
for (int i = 0; i < trackDetails.length; i++) {
ShipmentTrackingDetailsType track = new ShipmentTrackingDetailsType();
track.setShipmentTrackingNumber(trackingOrders.get(i).get("trackingCodeId").toString());
trackDetails[i] = track;
}
shippingDetail.setShipmentTrackingDetails(trackDetails);
newOrder.setShippingDetails(shippingDetail);
}
newOrder.setOrderID(order.getOrderID());
newOrder.setOrderStatus(order.getOrderStatus());
newOrder.setAdjustmentAmount(order.getAdjustmentAmount());
newOrder.setAmountSaved(order.getAmountSaved());
newOrder.setCheckoutStatus(order.getCheckoutStatus());
newOrder.setShippingDetails(order.getShippingDetails());
newOrder.setCreatingUserRole(order.getCreatingUserRole());
newOrder.setCreatedTime(order.getCreatedTime());
newOrder.setPaymentMethods(order.getPaymentMethods());
newOrder.setShippingAddress(order.getShippingAddress());
newOrder.setSubtotal(order.getSubtotal());
newOrder.setTotal(order.getTotal());
newOrder.setTransactionArray(order.getTransactionArray());
newOrder.setBuyerUserID(order.getBuyerUserID());
newOrder.setPaidTime(order.getPaidTime());
newOrder.setShippedTime(order.getShippedTime());
newOrder.setIntegratedMerchantCreditCardEnabled(order.isIntegratedMerchantCreditCardEnabled());
addReq.setOrder(newOrder);
addResp = (AddOrderResponseType) addOrderCall.execute(addReq);
if (addResp != null && "SUCCESS".equals(addResp.getAck().toString())) {
Debug.logInfo("Upload tracking code to eBay success...", module);
} else {
createErrorLogMessage(userLogin, dctx.getDispatcher(), productStoreId, addResp.getAck().toString(), "Update order : uploadTrackingInfoBackToEbay", addResp.getErrors(0).getLongMessage());
}