public static void SetShipmentTrackingInfo( String ebayOrderLineItemId, Boolean isPaid, String trackingNumber, ShippingMethods shippingMethod, DateTime dateOfShipping) { try { CompleteSaleRequestType request = new CompleteSaleRequestType(); request.OrderLineItemID = ebayOrderLineItemId; request.Paid = isPaid; request.Shipped = true; request.Shipment = new ShipmentType(); request.Shipment.ShippedTime = dateOfShipping; request.Shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsTypeCollection(); request.Shipment.ShipmentTrackingDetails.Add(new ShipmentTrackingDetailsType() { ShipmentTrackingNumber = trackingNumber, ShippingCarrierUsed = shippingMethod.ToString() }); CompleteSaleCall call = new CompleteSaleCall(EbayController.GetApiContext()); call.ExecuteRequest(request); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(String.Format("TrackingNumber can't be set. Ebay says: {0}", ex.Message)); } }
/// <summary> /// CompleteSaleRequestType Extension, to be submitted to UpdateOrder command /// </summary> /// <param name="itemId"></param> /// <param name="shipped"></param> public EbayListingUpdateRequest(string itemId, bool shipped) { RequestType = new CompleteSaleRequestType { ItemID = itemId }; MarkAsShipped(shipped); }
public void UpdateeBayShipment(IList <ShipmentDetail> shipmentDetails) { try { CompleteSaleRequestType completeSaleRequest; var apiContext = _eBayApiContextProvider.GetAPIContext(); var completeSaleCall = new CompleteSaleCall(apiContext); foreach (var shipmentDetail in shipmentDetails) { try { if (string.IsNullOrEmpty(shipmentDetail.OrderLineItemID)) { continue; } completeSaleRequest = new CompleteSaleRequestType(); completeSaleRequest.OrderLineItemID = shipmentDetail.OrderLineItemID; if (!string.IsNullOrEmpty(shipmentDetail.ShipmentTrackingNumber) && !string.IsNullOrEmpty(shipmentDetail.ShippingCarrierUsed)) { completeSaleRequest.Shipment = new ShipmentType(); completeSaleRequest.Shipment.ShipmentTrackingNumber = shipmentDetail.ShipmentTrackingNumber; completeSaleRequest.Shipment.ShippingCarrierUsed = shipmentDetail.ShippingCarrierUsed; } completeSaleRequest.Shipped = true; var completeSaleResponse = completeSaleCall.ExecuteRequest(completeSaleRequest) as CompleteSaleResponseType; if (completeSaleResponse.Ack == AckCodeType.Failure || completeSaleResponse.Ack == AckCodeType.PartialFailure) { LogManager.Instance.Error("Update eBay Shipment Failed for Order " + shipmentDetail.OrderLineItemID + Environment.NewLine); if (completeSaleResponse.Errors != null && completeSaleResponse.Errors.Count > 0) { LogManager.Instance.Error("Error Detail:" + shipmentDetail.OrderLineItemID + " " + completeSaleResponse.Errors[0].LongMessage + Environment.NewLine); } } } catch (Exception ex) { LogManager.Instance.Error("Update eBay Shipment Failed for Order " + shipmentDetail.OrderLineItemID + Environment.NewLine + ex.Message); //throw ex; } } } catch (Exception ex) { LogManager.Instance.Error(ex.Message); } }
public CompleteSaleResponseType UpdateShippingInfo(string itemID, string transactionID, string trackingNumber, string userToken) { string callname = "CompleteSale"; #region Initialise Needed Variables //Get the Server to use (Sandbox or Production) string serverUrl = ConfigurationManager.AppSettings["TradingService"]; //SiteID = 0 (US) - UK = 3, Canada = 2, Australia = 15, .... string siteID = "0"; eBayAPIInterfaceService service = new eBayAPIInterfaceService(); string requestURL = serverUrl + "?callname=" + callname + "&siteid=" + siteID + "&appid=" + AppID + "&version=" + version + "&routing=default"; service.Url = requestURL; // Set credentials service.RequesterCredentials = new CustomSecurityHeaderType(); service.RequesterCredentials.Credentials = new UserIdPasswordType(); service.RequesterCredentials.Credentials.AppId = AppID; service.RequesterCredentials.Credentials.DevId = DevID; service.RequesterCredentials.Credentials.AuthCert = CertID; service.RequesterCredentials.eBayAuthToken = userToken; #endregion CompleteSaleRequestType request = new CompleteSaleRequestType(); request.WarningLevel = WarningLevelCodeType.High; request.ItemID = itemID; request.TransactionID = transactionID; ShipmentType shipment = new ShipmentType(); ShipmentTrackingDetailsType shipmentDetails = new ShipmentTrackingDetailsType(); shipmentDetails.ShipmentTrackingNumber = trackingNumber; shipmentDetails.ShippingCarrierUsed = ConfigurationManager.AppSettings["ShippingCarrier"]; shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsType[] { shipmentDetails }; request.Shipment = shipment; request.Version = version; try { CompleteSaleResponseType response = service.CompleteSale(request); return response; } catch (Exception ex) { if (ex.Message.ToLower().Contains("auth token")) throw new InvalidEbayCredentialsException(); else throw ex; } }
/// <summary> /// /// </summary> /// <param name="ApiContext">The <see cref="ApiCall.ApiContext"/> for this API Call of type <see cref="ApiContext"/>.</param> public CompleteSaleCall(ApiContext ApiContext) { ApiRequest = new CompleteSaleRequestType(); this.ApiContext = ApiContext; }
/// <summary> /// /// </summary> public CompleteSaleCall() { ApiRequest = new CompleteSaleRequestType(); }
/// <summary> /// CompleteSaleRequestType Extension, to be submitted to UpdateOrder command /// </summary> /// <param name="itemId"></param> /// <param name="shipped"></param> public EbayListingUpdateRequest(string itemId, bool shipped) { RequestType = new CompleteSaleRequestType {ItemID = itemId}; MarkAsShipped(shipped); }
/// <summary> /// CompleteSaleRequestType Extension, to be submitted to UpdateOrder command /// </summary> /// <param name="itemId">Item to update</param> public EbayListingUpdateRequest(string itemId) { RequestType = new CompleteSaleRequestType {ItemID = itemId}; }
public bool UpdateeBayShipment(IList <ShipmentDetail> shipmentDetails) { try { CompleteSaleCall completeSaleCall; CompleteSaleRequestType completeSaleRequest; var apiContexts = _eBayAPIContextProvider.GetAPIContext(); var shipmentDetailGroup = shipmentDetails.GroupBy(i => i.SellerID); foreach (var shipmentDetailGroupItem in shipmentDetailGroup) { var apiContext = apiContexts.Where(c => c.ApiCredential.eBayAccount.UserName.ToLower().Equals(shipmentDetailGroupItem.Key.ToLower())).FirstOrDefault(); if (apiContext != null) { completeSaleCall = new CompleteSaleCall(apiContext); foreach (var shipmentDetail in shipmentDetailGroupItem) { if (string.IsNullOrEmpty(shipmentDetail.OrderLineItemID)) { continue; } completeSaleRequest = new CompleteSaleRequestType(); if (isOrderLineItemID(shipmentDetail.OrderLineItemID)) { completeSaleRequest.OrderLineItemID = shipmentDetail.OrderLineItemID; } else { completeSaleRequest.OrderID = shipmentDetail.OrderLineItemID; } if (!string.IsNullOrEmpty(shipmentDetail.ShipmentTrackingNumber) && !string.IsNullOrEmpty(shipmentDetail.ShipmentTrackingNumber)) { completeSaleRequest.Shipment = new ShipmentType(); completeSaleRequest.Shipment.ShipmentTrackingNumber = shipmentDetail.ShipmentTrackingNumber; completeSaleRequest.Shipment.ShippingCarrierUsed = shipmentDetail.ShippingCarrierUsed; } completeSaleRequest.Shipped = true; var completeSaleResponse = completeSaleCall.ExecuteRequest(completeSaleRequest) as CompleteSaleResponseType; if (completeSaleResponse.Ack == AckCodeType.Failure || completeSaleResponse.Ack == AckCodeType.PartialFailure) { LogManager.Instance.Error("Update eBay Shipment Failed for Order " + shipmentDetail.OrderLineItemID + Environment.NewLine); if (completeSaleResponse.Errors != null && completeSaleResponse.Errors.Count > 0) { LogManager.Instance.Error("Error Detail:" + shipmentDetail.OrderLineItemID + " " + completeSaleResponse.Errors[0].LongMessage + Environment.NewLine); } } } } } return(true); } catch (Exception ex) { throw ex; return(false); } }
/// <summary> /// CompleteSaleRequestType Extension, to be submitted to UpdateOrder command /// </summary> /// <param name="itemId">Item to update</param> public EbayListingUpdateRequest(string itemId) { RequestType = new CompleteSaleRequestType { ItemID = itemId }; }