public static List<EbayTransactionType> GetAllOrders(AccountType account, TimeFilter timeFilter, StringCollection orderIds) { List<EbayTransactionType> transList = new List<EbayTransactionType>(); GetOrdersCall getOrdersApiCall = new GetOrdersCall(account.SellerApiContext); getOrdersApiCall.IncludeFinalValueFee = true; DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; getOrdersApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); if (orderIds != null) getOrdersApiCall.OrderIDList = orderIds; try { OrderTypeCollection orders = getOrdersApiCall.GetOrders(timeFilter, TradingRoleCodeType.Seller, OrderStatusCodeType.All); foreach (OrderType order in orders) { AddressType addressType = order.ShippingAddress; String shippingAddress = GetShippingAddressString(addressType); String shippingAddressCompact = GetShippingAddressCompactString(addressType); bool completed = order.OrderStatus == OrderStatusCodeType.Completed; foreach (TransactionType trans in order.TransactionArray) { #region Process each ebay transaction // Check if this transaction has already be recorded in system. String transId = trans.TransactionID; if (transId == null || transId == "") { Logger.WriteSystemLog("GetAllOrders: Invalid transaction id, skip and continue."); continue; } EbayTransactionType ebayTrans = new EbayTransactionType(); ebayTrans.SellerName = account.ebayAccount; ebayTrans.OrderId = order.OrderID; ebayTrans.OrderLineItemId = trans.OrderLineItemID; ebayTrans.EbayTransactionId = trans.TransactionID; ebayTrans.EbayRecordId = order.ShippingDetails.SellingManagerSalesRecordNumberSpecified ? order.ShippingDetails.SellingManagerSalesRecordNumber : -1; ebayTrans.BuyerId = order.BuyerUserID; GetUserCall getUserApiCall = new GetUserCall(account.SellerApiContext); getUserApiCall.UserID = order.BuyerUserID; UserType user = getUserApiCall.GetUser(); // BuyerRating if (user.FeedbackScoreSpecified) ebayTrans.BuyerRating = user.FeedbackScore; else ebayTrans.BuyerRating = -1; // BuyerCountryEbayCode ebayTrans.BuyerCountryEbayCode = addressType.Country.ToString(); // BuyerCountry4PXCode ebayTrans.BuyerCountry4PXCode = ""; // BuyerCountry ebayTrans.BuyerCountry = addressType.CountryName; // BuyerCompanyName ebayTrans.BuyerCompanyName = StringUtil.GetSafeString(addressType.CompanyName); // BuyerName ebayTrans.BuyerName = addressType.Name; // BuyerStateOrProvince ebayTrans.BuyerStateOrProvince = addressType.StateOrProvince; // BuyerCity ebayTrans.BuyerCity = addressType.CityName; // BuyerTel ebayTrans.BuyerTel = addressType.Phone; // BuyerMail ebayTrans.BuyerMail = trans.Buyer.Email; // BuyerPostalCode ebayTrans.BuyerPostalCode = addressType.PostalCode; // BuyerAddress ebayTrans.BuyerAddress = shippingAddress; // BuyerAddressCompact ebayTrans.BuyerAddressCompact = shippingAddressCompact; // BuyerAddressLine1 ebayTrans.BuyerAddressLine1 = addressType.Street1; // BuyerAddressLine2 ebayTrans.BuyerAddressLine2 = addressType.Street2; // BuyerPayPal ebayTrans.BuyerPayPal = trans.Buyer.Email; // ItemId ebayTrans.ItemId = trans.Item.ItemID; // What is the valid way to determine if there is a variation. if (trans.Variation != null && trans.Variation.VariationTitle != null && trans.Variation.VariationTitle.Trim() != "") { // ItemTitle ebayTrans.ItemTitle = trans.Variation.VariationTitle; // ItemSKU ebayTrans.ItemSKU = trans.Variation.SKU; } else { // ItemTitle ebayTrans.ItemTitle = trans.Item.Title; // ItemSKU ebayTrans.ItemSKU = trans.Item.SKU; } // ItemPrice if (trans.TransactionPrice != null) ebayTrans.ItemPrice = trans.TransactionPrice.Value; // SaleQuantity ebayTrans.SaleQuantity = trans.QuantityPurchased; if (trans.TransactionPrice != null) { // SalePrice ebayTrans.SalePrice = trans.TransactionPrice.Value * trans.QuantityPurchased; // TotalPrice ebayTrans.TotalPrice = trans.TransactionPrice.Value * trans.QuantityPurchased; } // TODO: there may be multiple transactions in one order. if (order.Total != null) { ebayTrans.TotalPrice = order.Total.Value; ebayTrans.CurrencyId = order.Total.currencyID.ToString(); } else { // Set a default value. ebayTrans.TotalPrice = 0.0; ebayTrans.CurrencyId = ""; } // SaleDate ebayTrans.SaleDate = order.CreatedTime; // SaleDateCN ebayTrans.SaleDateCN = order.CreatedTime.ToLocalTime(); // IsPaid ebayTrans.IsPaid = order.PaidTimeSpecified; // order.AmountPaid // order.CheckoutStatus // ebayPaymentStatus // Status // orderStatus if (ebayTrans.IsPaid == false) { // Some payment is paid using credit card, and while PayPal is processing the payment, // the transaction is marked as unpaid. we should view it as paid. if (order.OrderStatusSpecified && order.OrderStatus == OrderStatusCodeType.Completed) ebayTrans.IsPaid = true; } if (ebayTrans.IsPaid == false) { if (order.CheckoutStatus.StatusSpecified && order.CheckoutStatus.Status == CompleteStatusCodeType.Complete) ebayTrans.IsPaid = true; } // PaidDate ebayTrans.PaidDate = StringUtil.GetSafeDateTime(order.PaidTime); // IsShipped ebayTrans.IsShipped = order.ShippedTimeSpecified; if (order.ShippedTimeSpecified) ebayTrans.ShippedDate = StringUtil.GetSafeDateTime(order.ShippedTime); else ebayTrans.ShippedDate = DateTime.Now.AddYears(-10); // Store the shippedDate as the local date time. ebayTrans.ShippedDate = ebayTrans.ShippedDate.ToLocalTime(); // ShippingServiceCode ebayTrans.ShippingServiceCode = ""; // ShippingService ebayTrans.ShippingService = ""; // ShippingTrackingNo ebayTrans.ShippingTrackingNo = ""; // ShippingCost ebayTrans.ShippingCost = 0.0; // FinalValueFee if (trans.FinalValueFee != null) ebayTrans.FinalValueFee = trans.FinalValueFee.Value; else ebayTrans.FinalValueFee = 0.0; // PayPalFee ebayTrans.PayPalFee = 0.034 * ebayTrans.TotalPrice + 0.3; // IsReceived ebayTrans.IsReceived = false; ebayTrans.IsBuyerLeftFeedback = false; ebayTrans.IsSellerLeftFeedback = false; ebayTrans.IsNeedAttention = false; ebayTrans.MessageStatus = TransactionMessageStatus.NoMessage; ebayTrans.IsContactedBuyer = false; ebayTrans.LastContactedBuyerDate = DateTime.Now.AddYears(-10); ebayTrans.IsResendReplacement = false; ebayTrans.UserComment = ""; GetFeedbackCall getFeedbackApiCall = new GetFeedbackCall(account.SellerApiContext); //DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; getFeedbackApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); getFeedbackApiCall.OrderLineItemID = trans.OrderLineItemID; FeedbackDetailTypeCollection feedbacks = getFeedbackApiCall.GetFeedback(); foreach (FeedbackDetailType feedback in feedbacks) { if (feedback.CommentingUser == account.ebayAccount) ebayTrans.IsSellerLeftFeedback = true; if (feedback.CommentingUser == ebayTrans.BuyerId) ebayTrans.IsBuyerLeftFeedback = true; } if (trans.ShippingDetails != null) { if (trans.ShippingDetails.ShipmentTrackingDetails.Count == 1) { ShipmentTrackingDetailsType shipmentDetails = trans.ShippingDetails.ShipmentTrackingDetails[0]; ebayTrans.ShippingTrackingNo = shipmentDetails.ShipmentTrackingNumber; } } transList.Add(ebayTrans); #endregion } } } catch (Exception ex) { Logger.WriteSystemLog(string.Format("Unexpected expection : {0}", ex.Message)); } return transList; }
public void GetFeedback() { GetFeedbackCall api = new GetFeedbackCall(this.apiContext); // Pagination PaginationType pt = new PaginationType(); pt.EntriesPerPage = 100; pt.EntriesPerPageSpecified = true; pt.PageNumber = 1; pt.PageNumberSpecified = true; api.Pagination = pt; api.UserID = TestData.ApiUserID; // Make API call. FeedbackDetailTypeCollection feedbacks = api.GetFeedback(); }
private void BtnGetFeedback_Click(object sender, System.EventArgs e) { try { TxtPositive.Text = ""; TxtNegative.Text = ""; TxtScore.Text = ""; LstComments.Items.Clear(); GetFeedbackCall apicall = new GetFeedbackCall(Context); apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); FeedbackDetailTypeCollection feedbacks = apicall.GetFeedback(TxtUserId.Text); if (apicall.FeedbackSummary != null) { TxtPositive.Text = apicall.FeedbackSummary.UniquePositiveFeedbackCount.ToString(); TxtNegative.Text =apicall.FeedbackSummary.UniqueNegativeFeedbackCount.ToString(); TxtScore.Text = apicall.FeedbackScore.ToString(); } foreach (FeedbackDetailType feedback in feedbacks) { string[] listparams = new string[7]; listparams[0] = feedback.CommentingUser; listparams[1] = feedback.CommentingUserScore.ToString(); listparams[2] = feedback.ItemID; listparams[3] = feedback.CommentType.ToString(); listparams[4] = feedback.CommentText; listparams[5] = feedback.Role.ToString(); listparams[6] = feedback.CommentTime.ToString(); ListViewItem vi = new ListViewItem(listparams); LstComments.Items.Add(vi); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static bool GetBuyerFeedbackLeft(AccountType account, String buyerId, String orderId) { //bool sellerLeftFeedback = false; //bool buyerLeftFeedback = false; GetFeedbackCall getFeedbackApiCall = new GetFeedbackCall(account.SellerApiContext); DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; getFeedbackApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); getFeedbackApiCall.OrderLineItemID = orderId; try { FeedbackDetailTypeCollection feedbacks = getFeedbackApiCall.GetFeedback(); foreach (FeedbackDetailType feedback in feedbacks) { //if (feedback.CommentingUser == account.ebayAccount) // sellerLeftFeedback = true; if (feedback.CommentingUser == buyerId) { return true; } } } catch (System.Exception ex) { Logger.WriteSystemLog(String.Format("GetFeedback failed with error msg={0}", ex.Message)); Logger.WriteSystemLog(String.Format("Transaction with BuyerId={0} maybe happened more than 90 days.", buyerId)); return true; } return false; }