// // http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/AddOrder.html // Only incomplete transactions can be combined, otherwise there will be error message: // "Some transactions have already been completed, you can only combine incomplete transactions". // public static bool MergeOrders(List <String> transactionIds) { if (transactionIds.Count < 2) { return(false); } // Verify that all transactions are between same buyer and seller. String buyer = ""; String seller = ""; Double total = 0.0; foreach (String tranId in transactionIds) { EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId); if (trans == null) { return(false); } if (buyer != "" && buyer != trans.BuyerName) { return(false); } if (seller != "" && seller != trans.SellerName) { return(false); } buyer = trans.BuyerName; seller = trans.SellerName; total += trans.ItemPrice * trans.SaleQuantity; } AccountType account = AccountUtil.GetAccount(seller); if (account == null) { return(false); } AddOrderCall addOrderCall = new AddOrderCall(account.SellerApiContext); OrderType orderType = new eBay.Service.Core.Soap.OrderType(); orderType = new eBay.Service.Core.Soap.OrderType(); orderType.CreatingUserRole = TradingRoleCodeType.Seller; orderType.PaymentMethods = new eBay.Service.Core.Soap.BuyerPaymentMethodCodeTypeCollection(); orderType.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal); orderType.Total = new eBay.Service.Core.Soap.AmountType(); orderType.Total.Value = total; orderType.Total.currencyID = CurrencyCodeType.USD; orderType.TransactionArray = new eBay.Service.Core.Soap.TransactionTypeCollection(); foreach (String tranId in transactionIds) { EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId); if (trans == null) { return(false); } TransactionType tranType = new TransactionType(); tranType.Item = new ItemType(); tranType.Item.ItemID = trans.ItemId; tranType.TransactionID = trans.EbayTransactionId; orderType.TransactionArray.Add(tranType); } String orderId = addOrderCall.AddOrder(orderType); return(true); }
// // http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/AddOrder.html // Only incomplete transactions can be combined, otherwise there will be error message: // "Some transactions have already been completed, you can only combine incomplete transactions". // public static bool MergeOrders(List<String> transactionIds) { if (transactionIds.Count < 2) return false; // Verify that all transactions are between same buyer and seller. String buyer = ""; String seller = ""; Double total = 0.0; foreach (String tranId in transactionIds) { EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId); if (trans == null) return false; if (buyer != "" && buyer != trans.BuyerName) return false; if (seller != "" && seller != trans.SellerName) return false; buyer = trans.BuyerName; seller = trans.SellerName; total += trans.ItemPrice * trans.SaleQuantity; } AccountType account = AccountUtil.GetAccount(seller); if (account == null) return false; AddOrderCall addOrderCall = new AddOrderCall(account.SellerApiContext); OrderType orderType = new eBay.Service.Core.Soap.OrderType(); orderType = new eBay.Service.Core.Soap.OrderType(); orderType.CreatingUserRole = TradingRoleCodeType.Seller; orderType.PaymentMethods = new eBay.Service.Core.Soap.BuyerPaymentMethodCodeTypeCollection(); orderType.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal); orderType.Total = new eBay.Service.Core.Soap.AmountType(); orderType.Total.Value = total; orderType.Total.currencyID = CurrencyCodeType.USD; orderType.TransactionArray = new eBay.Service.Core.Soap.TransactionTypeCollection(); foreach (String tranId in transactionIds) { EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId); if (trans == null) return false; TransactionType tranType = new TransactionType(); tranType.Item = new ItemType(); tranType.Item.ItemID = trans.ItemId; tranType.TransactionID = trans.EbayTransactionId; orderType.TransactionArray.Add(tranType); } String orderId = addOrderCall.AddOrder(orderType); return true; }