Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
String productStoreId = (String) context.get("productStoreId");
String orderId = (String) context.get("orderId");
GetOrdersRequestType req = new GetOrdersRequestType();
GetOrdersResponseType resp = null;
try {
GenericValue orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
if (UtilValidate.isNotEmpty(orderHeader)) {
String externalId = orderHeader.getString("externalId").toString();
List<GenericValue> orderShipment = orderHeader.getRelated("OrderShipment");
if (orderShipment.size() > 0) {
List<GenericValue> trackingOrders = orderHeader.getRelated("TrackingCodeOrder");
ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
GetOrdersCall ordersCall = new GetOrdersCall(apiContext);
OrderIDArrayType orderIdArr = new OrderIDArrayType();
String[] orderIdStr = {""+externalId};
orderIdArr.setOrderID(orderIdStr);
req.setOrderIDArray(orderIdArr);
Calendar orderFrom = Calendar.getInstance();
orderFrom.setTime(UtilDateTime.toDate("01/01/2001 00:00:00"));
req.setCreateTimeFrom(orderFrom);
Calendar orderTo = Calendar.getInstance();
orderTo.setTime(UtilDateTime.nowDate());
req.setCreateTimeTo(orderTo);
req.setOrderStatus(OrderStatusCodeType.SHIPPED);
req.setOrderRole(TradingRoleCodeType.SELLER);
resp = (GetOrdersResponseType) ordersCall.execute(req);
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
OrderArrayType orderArr = resp.getOrderArray();
OrderType[] orderTypeList = orderArr.getOrder();
for (OrderType order : orderTypeList) {