private void BtnAddOrder_Click(object sender, System.EventArgs e) { try { TxtOrderId.Text = ""; AddOrderCall apicall = new AddOrderCall(Context); OrderType order = new OrderType(); order.TransactionArray = new TransactionTypeCollection(); order.ShippingDetails = new ShippingDetailsType(); order.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection(); TransactionType tr1 = new TransactionType(); tr1.Item = new ItemType(); tr1.Item.ItemID = TxtItemIdOne.Text; tr1.TransactionID = TxtTransactionIdOne.Text; order.TransactionArray.Add(tr1); TransactionType tr2 = new TransactionType(); tr2.Item = new ItemType(); tr2.Item.ItemID = TxtItemIdTwo.Text; tr2.TransactionID = TxtTransactionIdTwo.Text; order.TransactionArray.Add(tr2); order.ShippingDetails.PaymentInstructions = TxtPaymentInstructions.Text; ShippingServiceOptionsType shpopt = new ShippingServiceOptionsType(); shpopt.ShippingService = CboShipSvc.SelectedItem.ToString(); shpopt.ShippingServicePriority = 1; order.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection(); shpopt.ShippingServiceCost = new AmountType(); shpopt.ShippingServiceCost.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site); if (TxtShipCost.Text.Length > 0) { shpopt.ShippingServiceCost.Value = Convert.ToDouble(TxtShipCost.Text); } order.ShippingDetails.ShippingServiceOptions.Add(shpopt); order.Total = new AmountType(); order.Total.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site); if (TxtTotal.Text.Length > 0) order.Total.Value = Convert.ToDouble(TxtTotal.Text); order.CreatingUserRole = (TradingRoleCodeType) Enum.Parse(typeof(TradingRoleCodeType), CboRole.SelectedItem.ToString()); order.PaymentMethods.AddRange(new BuyerPaymentMethodCodeType[] {BuyerPaymentMethodCodeType.PaymentSeeDescription}); string orderid = apicall.AddOrder(order); TxtOrderId.Text = orderid; } catch(Exception ex) { MessageBox.Show(ex.Message); } }
// // 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; }