public void SendInvoice()
		{
			Assert.IsNotNull(TestData.NewItem, "Failed because no item available -- requires successful AddItem test");
			//
			SendInvoiceCall api = new SendInvoiceCall(this.apiContext);
			SendInvoiceRequestType req = new SendInvoiceRequestType();
			api.CheckoutInstructions = "SDK checkout instruction.";
			api.EmailCopyToSeller = true; req.EmailCopyToSellerSpecified = true;
			api.InsuranceFee = new AmountType(); api.InsuranceFee.Value = 2.0; api.InsuranceFee.currencyID = CurrencyCodeType.USD;
			api.InsuranceOption = InsuranceOptionCodeType.Required;
			api.ItemID = TestData.NewItem.ItemID;
			api.PayPalEmailAddress = "*****@*****.**";
			api.TransactionID = "0";

			// Make API call.
			ApiException gotException = null;
			try
			{
			api.Execute();
			}
			catch(ApiException ex)
			{
				gotException = ex;
			}
			Assert.IsNotNull(gotException);
			
		}
Exemplo n.º 2
0
		private void BtnSendInvoice_Click(object sender, System.EventArgs e)
		{
			try
			{
				SendInvoiceCall apicall = new SendInvoiceCall(Context);

				TxtStatus.Text = "";
				string ItemID = TxtItemId.Text;
				string TransactionID = TxtTransactionId.Text;

				ShippingServiceOptionsType ShippingServiceOption = new ShippingServiceOptionsType();
				
				ShippingServiceOption.ShippingInsuranceCost = new AmountType();
				ShippingServiceOption.ShippingInsuranceCost.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
				ShippingServiceOption.ShippingInsuranceCost.Value = Convert.ToDouble(TxtShippingInsuranceCost.Text);
					
				ShippingServiceOption.ShippingService = CboShippingService.SelectedItem.ToString();

				ShippingServiceOption.ShippingServiceCost = new AmountType();
				ShippingServiceOption.ShippingServiceCost.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
				ShippingServiceOption.ShippingServiceCost.Value=Convert.ToDouble(TxtShippingServiceCost.Text);

				
				ShippingServiceOption.ShippingServiceAdditionalCost = new AmountType();

				ShippingServiceOption.ShippingServiceAdditionalCost.Value=Convert.ToDouble(TxtShippingServiceAdditionalCost.Text);
				ShippingServiceOption.ShippingServiceAdditionalCost.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
				ShippingServiceOption.ShippingServicePriority = Int32.Parse(TxtShippingServicePriority.Text);

				//SaleTaxType related
				apicall.SalesTax = new SalesTaxType();
				apicall.SalesTax.SalesTaxPercent = (float)Convert.ToDouble(TxtSalesTaxPercent.Text);
				apicall.SalesTax.SalesTaxState = TxtSalesTaxState.Text;
				apicall.SalesTax.ShippingIncludedInTax = ChkShippingIncludedInTax.Checked;

				apicall.SalesTax.SalesTaxAmount = new AmountType();
				apicall.SalesTax.SalesTaxAmount.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
				apicall.SalesTax.SalesTaxAmount.Value = Convert.ToDouble(TxtSalesTaxAmount.Text);
				
        
				apicall.InsuranceOption = (InsuranceOptionCodeType)Enum.Parse(typeof(InsuranceOptionCodeType), CboInsuranceOption.SelectedItem.ToString());
				
				apicall.InsuranceFee = new AmountType();
				apicall.InsuranceFee.currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);
				apicall.InsuranceFee.Value = Convert.ToDouble(TxtInsuranceFee.Text);

				apicall.PaymentMethodsList = new BuyerPaymentMethodCodeTypeCollection();
				apicall.PaymentMethodsList.Add((BuyerPaymentMethodCodeType)Enum.Parse(typeof(BuyerPaymentMethodCodeType), CboPaymentMethod.SelectedItem.ToString()));
				
				apicall.PayPalEmailAddress = TxtPayPalEmailAddress.Text;
				apicall.CheckoutInstructions = TxtCheckoutInstructions.Text;
				apicall.EmailCopyToSeller = ChkEmailCopyToSeller.Checked;

				ShippingServiceOptionsTypeCollection ShippingServiceOptionsList= new ShippingServiceOptionsTypeCollection();
				ShippingServiceOptionsList.Add(ShippingServiceOption);

				apicall.SendInvoice(ItemID, TransactionID, ShippingServiceOptionsList);
				TxtStatus.Text = apicall.ApiResponse.Ack.ToString();
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}