I am trying to add Tax Code for SalesItemLineDetail inside Invoice of Quickbooks online api, but it is not setting tax code correctly when checking it in Online Quickbooks.
Here is my C# Code, which I am using to create Line Item
Line = new Intuit.Ipp.Data.Line();
InvoiceLine = new Intuit.Ipp.Data.SalesItemLineDetail();
InvoiceLine.ItemRef = new Intuit.Ipp.Data.ReferenceType
{
Value = GetItem.Id, // this is inventory Item Id
name = GetItem.Name // inventory item name
};
Line.DetailTypeSpecified = true;
Line.DetailType = Intuit.Ipp.Data.LineDetailTypeEnum.SalesItemLineDetail;
Line.Description = inv.Description;
Line.Amount = (inv.Price == null || inv.Price == 0.0) ? (decimal)0.00 : (decimal)inv.Price;
Line.AmountSpecified = true;
InvoiceLine.Qty = decimal.Parse(inv.Quantity.Value.ToString());
InvoiceLine.QtySpecified = true;
InvoiceLine.AnyIntuitObject = (inv.Price == null || inv.Price == 0.0) ? (decimal)0.00 : (decimal)(Math.Round(inv.Price.Value, 2) / inv.Quantity.Value);
InvoiceLine.ItemElementName = Intuit.Ipp.Data.ItemChoiceType.UnitPrice;
// this line is not settings tax code properly
InvoiceLine.TaxCodeRef = new Intuit.Ipp.Data.ReferenceType
{
name = taxName,
Value = TaxId
};
//Line Sales Item Line Detail - ServiceDate
InvoiceLine.ServiceDate = DateTime.Now.Date;
InvoiceLine.ServiceDateSpecified = true;
//Assign Sales Item Line Detail to Line Item
Line.AnyIntuitObject = InvoiceLine;
lines.Add(Line);
Intuit.Ipp.Data.Invoice invoice = new Intuit.Ipp.Data.Invoice();
// SalesOrder is a database table object, and OrderNumber is auto generated number
invoice.DocNumber = SalesOrder.OrderNumber.ToString();
//TxnDate
invoice.TxnDate = DateTime.Now.Date;
invoice.TxnDateSpecified = true;
invoice.CustomerRef = new Intuit.Ipp.Data.ReferenceType
{
Value = CompanyId
};
//convert list to array for Intuit Line
invoice.Line = lines.ToArray();
//TxnTaxDetail
Intuit.Ipp.Data.Line taxLine = new Intuit.Ipp.Data.Line();
Intuit.Ipp.Data.TxnTaxDetail txnTaxDetail = new Intuit.Ipp.Data.TxnTaxDetail();
Intuit.Ipp.Data.TaxLineDetail taxLineDetail = new Intuit.Ipp.Data.TaxLineDetail(); ;
//txnTaxDetail.TotalTaxSpecified = true;
//txnTaxDetail.TotalTax = decimal.Parse("2");
var MainTaxValue = "";
txnTaxDetail.TxnTaxCodeRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = TaxId,
name = SalesOrder.TaxCode.TaxCodeName
};
foreach (var TAXName in TaxObject.TaxRateDetail)
{
if(TAXName.TaxRateRef.name.Contains(SalesOrder.TaxCode.TaxCodeName))
{
MainTaxValue = TAXName.TaxRateRef.value;
}
}
taxLineDetail.TaxRateRef = new Intuit.Ipp.Data.ReferenceType
{
Value = MainTaxValue
};
taxLine.AnyIntuitObject = taxLineDetail;
txnTaxDetail.TaxLine = new Intuit.Ipp.Data.Line[] { taxLine };
//DueDate
invoice.DueDate = SalesOrder.InvoiceDueDate != null ? SalesOrder.InvoiceDueDate.Value : DateTime.Now.AddDays(30).Date;
invoice.DueDateSpecified = true;
invoice.TxnTaxDetail = txnTaxDetail;
I have tried these reference links, but it is not working for me
https://gist.github.com/IntuitDeveloperRelations/6500373
How to export Line items with Tax Code and Value in QBO Canada
https://developer.intuit.com/app/developer/qbo/docs/develop/tutorials/manage-sales-tax-for-non-us-locales
Using above links, I can see we can create Tax Code ref using this line of code, for Each Invoice Line item, but it is not setting value correctly.
InvoiceLine.TaxCodeRef = new Intuit.Ipp.Data.ReferenceType
{
name = taxName,
Value = TaxId
};
But it is not working.
Note: this is non-US company, so I have to specify tax code ref for each Invoice Line.
Edit 1:
Attaching Image of Postman API request, which I sent to Quickbooks for creating invoice.
try by removing the name field I think it might not be required
InvoiceLine.TaxCodeRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = TaxId
};
The main difference between our versions is that I let QB calculate the tax.
I commented out the Tax detail line, and told QB that tax amount wasn't included.
// //TxnTaxDetail
// TxnTaxDetail txnTaxDetail = new TxnTaxDetail();
// Line taxLine = new Line();
// taxLine.DetailType = LineDetailTypeEnum.TaxLineDetail;
// TaxLineDetail taxLineDetail = new TaxLineDetail();
// taxLineDetail.TaxRateRef = stateTaxCode.SalesTaxRateList.TaxRateDetail[0].TaxRateRef;
// txnTaxDetail.TxnTaxCodeRef = new ReferenceType
// {
// name = stateTaxCode.Name,
// Value = stateTaxCode.Id
// };
// if (customer.DefaultTaxCodeRef != null)
// {
// txnTaxDetail.TxnTaxCodeRef = customer.DefaultTaxCodeRef;
// taxLineDetail.TaxRateRef = customer.DefaultTaxCodeRef;
// }
// //Assigning the first Tax Rate in this Tax Code
// taxLine.AnyIntuitObject = taxLineDetail;
// txnTaxDetail.TaxLine = new[] { taxLine };
// invoice.TxnTaxDetail = txnTaxDetail;
invoice.GlobalTaxCalculationSpecified = true;
invoice.GlobalTaxCalculation = GlobalTaxCalculationEnum.TaxExcluded;
Here is my code for doing this, and it definitely works. I can't see a difference between the two though.This calculates VAT in Europe and puts in the Tax Code.
Hope this helps.
var invlines = new List<Line>();
foreach (var lineitem in inv.Lines)
{
//Line
Line invoiceLine = new Line();
//Line Description
invoiceLine.Description = (((lineitem.PublicationName == "N/A" || lineitem.PublicationName == "-") ? "" : lineitem.PublicationName) + " " + lineitem.Description).Trim();
//Line Detail Type
invoiceLine.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
invoiceLine.DetailTypeSpecified = true;
//Line Sales Item Line Detail
SalesItemLineDetail lineSalesItemLineDetail = new SalesItemLineDetail();
//Line Sales Item Line Detail - ItemRef
if (!string.IsNullOrEmpty(lineitem.ItemCode))
{
lineSalesItemLineDetail.ItemRef = new ReferenceType()
{
Value = lineitem.ItemCode
};
}
else if (item != null)
{
lineSalesItemLineDetail.ItemRef = new ReferenceType
{
name = item.Name,
Value = item.Id
};
}
//Line Sales Item Line Detail - UnitPrice
//Line Sales Item Line Detail - Qty
lineSalesItemLineDetail.Qty = 1;
lineSalesItemLineDetail.QtySpecified = true;
if (inv.DiscountPercent > 0)
{
invoiceLine.Amount = (decimal)lineitem.PriceBeforeDiscount;
invoiceLine.AmountSpecified = true;
lineSalesItemLineDetail.ItemElementName = ItemChoiceType.UnitPrice;
}
else
{
invoiceLine.Amount = (decimal)lineitem.Price;
invoiceLine.AmountSpecified = true;
lineSalesItemLineDetail.AnyIntuitObject = lineitem.Price;
lineSalesItemLineDetail.ItemElementName = ItemChoiceType.UnitPrice;
}
//Line Sales Item Line Detail - TaxCodeRef
//For US companies, this can be 'TAX' or 'NON'
var taxref = lineitem.TaxAmount == null || lineitem.TaxAmount == 0 ? nonvatid.ToString() : vatid.ToString();
if (country == "US")
{
taxref = lineitem.TaxAmount == null || lineitem.TaxAmount == 0 ? "NON" : "TAX";
}
lineSalesItemLineDetail.TaxCodeRef = new ReferenceType
{
Value = taxref
};
//Line Sales Item Line Detail - ServiceDate
lineSalesItemLineDetail.ServiceDate = DateTimeService.Now.Date;
lineSalesItemLineDetail.ServiceDateSpecified = true;
//Assign Sales Item Line Detail to Line Item
invoiceLine.AnyIntuitObject = lineSalesItemLineDetail;
//Assign Line Item to Invoice
invlines.Add(invoiceLine);
}
if (inv.DiscountPercent > 0)
{
Line invoiceLine = new Line();
DiscountLineDetail discLine = new DiscountLineDetail();
discLine.PercentBased = true;
discLine.DiscountPercent = (decimal)inv.DiscountPercent;
discLine.DiscountPercentSpecified = true;
discLine.PercentBased = true;
discLine.PercentBasedSpecified = true;
invoiceLine.DetailType = LineDetailTypeEnum.DiscountLineDetail;
invoiceLine.DetailTypeSpecified = true;
invoiceLine.AnyIntuitObject = discLine;
invlines.Add(invoiceLine);
invoice.DiscountRate = (decimal) (inv.DiscountPercent);
invoice.DiscountRateSpecified = true;
}
invoice.Line = invlines.ToArray();
Finally was able to find the correct solution.
My Above code is right, there is no issue in it and #sheavens code is also right.
Actual problem was, I was assigning "default Tax code" to a selected company, which we cannot override while passing tax code reference in Invoice Line item.
To Check if there is any default code for company, navigate to Companies list in quickbooks online website , Select your desired Company from the list, click "Edit", then in the "Tax Info" tab, uncheck "Assign Default tax code" to pass tax code using Invoice Line item.
Hope this helps other developers, with same problem.
Related
I tried to get the item on stacklayout into an SQLite Database, but it just won't carry any data with.
private void MainCategory_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var carier = e.SelectedItem as Item;
var cart_Itemsx = new List<cart_Items>();
cart_Itemsx.Add(new Models.cart_Items { cartid = 1, Id = carier.itid, image = carier.image, name = carier.title, price = carier.price1, quantity = "1", type = "Wash and Iron" });
cart_Itemsx.Add(new Models.cart_Items { cartid = 2, Id = carier.itid, image = carier.image, name = carier.title, price = carier.price2, quantity = "1", type = "Iron Only" });
SubCategory.ItemsSource = cart_Itemsx.ToList();
}
private void SubCategory_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var dbcontet = e.SelectedItem as cart_Items;
_dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), "WashPro.db3");
var db = new SQLiteConnection(_dbPath);
db.CreateTable<cart_Items>();
var MaximumPrimaryKey = db.Table<cart_Items>().OrderByDescending(zt => zt.cartid).FirstOrDefault();
var waltani = new cart_Items()
{
cartid = (MaximumPrimaryKey == null ? 1 : MaximumPrimaryKey.cartid + 1),
Id = dbcontet.Id,
image = dbcontet.image,
name = dbcontet.name,
price = dbcontet.price,
quantity = dbcontet.quantity,
type = dbcontet.quantity
};
if (MaximumPrimaryKey == null)
{
db.Insert(waltani);
}
else if (MaximumPrimaryKey != null)
{
var MaximumQuantityKey = db.Table<cart_Items>().Where(m => m.cartid.Equals(dbcontet.cartid) && m.type.Equals(dbcontet.type)).FirstOrDefault();
if (MaximumQuantityKey != null)
{
waltani.price = dbcontet.price = 1;
db.Update(waltani);
}
}
SubCategory.SelectedItem = null;
}
image of the null error I got
I cannot even begin to understand the problem. The way I found around the problem will make my already dirty code way dirtier.
I have the damaging method I tried was using the selected context of the main stack panel to influence the second stack pannel.
I have even made the primary key of the cart_item model null.
Your selected element is null or database table does not contain any elements you are looking for in query, which is more likely because you are trying to initialize your database on SubCategory_ItemSelected. This is wrong approach.
Try to check if database item exist first.
var exist = db.Table<cart_Items>().OrderByDescending(zt => zt.cartid).Any();
if (exist)
{
var MaximumPrimaryKey = db.Table<cart_Items>().OrderByDescending(zt => zt.cartid).FirstOrDefault();
var waltani = new cart_Items()
{
cartid = (MaximumPrimaryKey == null ? 1 : MaximumPrimaryKey.cartid + 1),
Id = dbcontet.Id,
image = dbcontet.image,
name = dbcontet.name,
price = dbcontet.price,
quantity = dbcontet.quantity,
type = dbcontet.quantity
};
}
The problem lies at the last line of code.
SubListview.SelectedItem = null;
This somehow makes the casting not see the e.selected items.
I am trying to create Quickbooks Online(QBO) Invoices. I am able to create the invoice in QBO, however the Amounts and Balances are set to 0.00. I have confirmed that the invoice(QBOInvoice) that I am passing to QBO contains the correct information, however, the invoice(resultInvoice) I receive in return does not have the prescribed Amounts and Balances.
Any guidance or suggestions? Thanks.
Invoice QBOinvoice = new Invoice();
QBOinvoice.DocNumber = Guid.NewGuid().ToString("N").Substring(0, 10);
QBOinvoice.Deposit = new Decimal(0.00);
QBOinvoice.DepositSpecified = true;
QBOinvoice.AllowIPNPayment = false;
QBOinvoice.AllowIPNPaymentSpecified = true;
QBOinvoice.BillAddr = customer.BillAddr;
QBOinvoice.ShipAddr = customer.ShipAddr;
QBOinvoice.CustomerRef = new ReferenceType()
{
name = customer.DisplayName,
Value = customer.Id
};
QBOinvoice.DueDate = DateTime.UtcNow.Date;
QBOinvoice.DueDateSpecified = true;
QBOinvoice.PrintStatus = PrintStatusEnum.NotSet;
QBOinvoice.PrintStatusSpecified = true;
QBOinvoice.EmailStatus = EmailStatusEnum.NotSet;
QBOinvoice.EmailStatusSpecified = true;
var serviceRecord = db.t_CleaningRecords.Where(p => p.ID == MOSESInvoice.ServiceRecordID).Single();
QBOinvoice.ShipDate = serviceRecord.ServiceDate ?? DateTime.Parse("01/01/1900"); // Used to address the fact that the DB column allows for nulls;
QBOinvoice.ARAccountRef = new ReferenceType()
{
type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
name = "Account Receivable",
Value = "QB:37"
};
QBOinvoice.Balance = MOSESInvoice.InvoiceAmount;
QBOinvoice.BalanceSpecified = true;
QBOinvoice.TotalAmt = MOSESInvoice.InvoiceAmount;
QBOinvoice.TotalAmtSpecified = true;
// Create Sales Line Item
Line invoiceline = new Line();
invoiceline.Id = "1";
//invoiceline.LineNum = "1";
invoiceline.Description = servloc.StreetAddress.ToString() + " :: " + MOSESInvoice.ServiceDescription;
//invoiceline.Description = servloc.StreetAddress.ToString() + " :: " + servdef.ServiceDefinitionName.ToString(); // This maps to Sales Definition Name & Street Address.
invoiceline.Amount = Convert.ToDecimal(MOSESInvoice.InvoiceAmount);
invoiceline.AmountSpecified = true;
invoiceline.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
invoiceline.DetailTypeSpecified = true;
SalesItemLineDetail slidetails = new SalesItemLineDetail();
slidetails.ItemRef = new ReferenceType() { name = "B2C - Every 1 Week" }; // Product/Service column on Line Item Detail. 1 = Services. 2 = Hours.
slidetails.ServiceDate = serviceRecord.ServiceDate ?? DateTime.Parse("01/01/1900");
invoiceline.AnyIntuitObject = slidetails;
QBOinvoice.Line = new Line[] { invoiceline };
Invoice resultInvoice = serviceme.Add(QBOinvoice) as Invoice;
db.SaveChanges();
return QBOinvoice;
I figured out what the problem was. I was passing a SalesItemLineDetail value that did not exist in my QBO company. So fail on my part for not sending the correct value. But...
The API simply and quietly changed the invoice balance and total amounts, then accepted the new invoice.
It seems to me that the QBO API should have blocked the action, issued a warning, or not overridden the invoice balance and total amount as provided.
I logged a support ticket with Intuit and provided this issue and resolution.
Below is the code I'm working with to pass multiple line items to create sales order through GP Web service. I can pass single Line Item without any problem , but when I pass multiple Items it is only taking the last one. The array has around 5 Item ID and I'm passing fixed Quantity as 15, Need to make both dynamic. But for the testing purpose I'm trying like this. I know the problem with the creation/initialization of some web service objects. As novice to the entire set of things I couldn't find the exact problem.
C# Code
CompanyKey companyKey;
Context context;
SalesOrder salesOrder;
SalesDocumentTypeKey salesOrderType;
CustomerKey customerKey;
BatchKey batchKey;
// SalesOrderLine salesOrderLine;
ItemKey orderedItem;
Quantity orderedAmount;
Policy salesOrderCreatePolicy;
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.UserName = "Admin";
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Password = "pass";
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Domain = "Gp";
System.ServiceModel.WSHttpBinding binding;
binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None);
context = new Context();
companyKey = new CompanyKey();
companyKey.Id = (1);
context.OrganizationKey = (OrganizationKey)companyKey;
salesOrder = new SalesOrder();
salesOrderType = new SalesDocumentTypeKey();
salesOrderType.Type = SalesDocumentType.Order;
salesOrder.DocumentTypeKey = salesOrderType;
customerKey = new CustomerKey();
customerKey.Id = "121001";
salesOrder.CustomerKey = customerKey;
batchKey = new BatchKey();
batchKey.Id = "RMS";
salesOrder.BatchKey = batchKey;
// SalesOrderLine[] orders = new SalesOrderLine[6];
SalesOrderLine[] lines = { };
for (int i = 1; i < 5; i++)
{
SalesOrderLine salesOrderLine = new SalesOrderLine();
orderedItem = new ItemKey();
orderedItem.Id = Arr[i].ToString();
salesOrderLine.ItemKey = orderedItem;
orderedAmount = new Quantity();
orderedAmount.Value = 15;
salesOrderLine.Quantity = orderedAmount;
lines = new SalesOrderLine[] { salesOrderLine };
MessageBox.Show(lines.Count().ToString());
}
salesOrder.Lines = lines;
//salesOrder.Lines = orders;
salesOrderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesOrder", context);
wsDynamicsGP.CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy);
if (wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
MessageBox.Show("Success");
lines = new SalesOrderLine[] { salesOrderLine }; will recreate the lines array object each time meaning you loose any previously added objects. Effectively only the final object in the loop is actually added.
Try using a List<T> like so:
SalesOrderLine[] lines = { }; Becomes List<SalesOrderLine> lines = new List<SalesOrderLine>();
lines = new SalesOrderLine[] { salesOrderLine }; Becomes: lines.Add(salesOrderLine);
If its important you end up with an array as the input:
salesOrder.Lines = lines; Becomes: salesOrder.Lines = lines.ToArray();
I am using SuiteTalk web services (v. 2013_2) . I am trying to create an ItemFulfillment where the items in it were related to items that had a lot or serial number.
When I try to save this item fulfillment into NetSuite I get an error of :
Please commit inventorydetail on this line.
I was attempting to set the itemFulfillment.serialNumbers and itemFulfillment.binNumbers when I create the itemFulfillmentItem.
For example I set
nsIfItem.serialNumbers = "SNum(5)"
nsIfItem.binNumbers = "BNum(5)"
based on those properties being- A comma delimited list of serial or LOT numbers. If entering serial numbers there must be a number for each item.
Lot numbers must be entered in a format of LOT#(Quantity).
For example, to enter a quantity of 100 items as Lot number ABC1234, enter ABC1234(100).
Do I also need to set something else on the itemFulfillment or how do I get rid of that error.
I'm not sure if this question is still active, but I had the same issue and iI couldn't find much help on it. I solved this issue by creating the inventory assignment objects and adding to the transaction.
First, create the initialize ref for Item Fulfillment and assign the returned record to a variable:
InitializeRecord ir = new InitializeRecord();
ir.type = InitializeType.itemFulfillment;
InitializeRef iref = new InitializeRef();
iref.typeSpecified = true;
iref.type = InitializeRefType.salesOrder;
iref.internalId = 'Sales Order internalID';
ir.reference = iref;
ReadResponse getInitResp = _service.initialize(ir);
ItemFulfillment ifrec = (ItemFulfillment)getInitResp.record;
Get the list of items on the initialized transaction:
ItemFulfillmentItemList ifitemlist = ifrec.itemList;
Create a list to which to add each unique item being fulfilled:
List<ItemFulfillmentItem> ifitems = new List<ItemFulfillmentItem>();
Run the following code for each item in initialized transaction's item list:
If the current line item has already been added to the ifitems list, add the current Fulfillment line as an assignment to that item:
InventoryAssignment assignment = new InventoryAssignment
{
issueInventoryNumber = new RecordRef { internalId = 'internalID',
type = 'RecordType',
typeSpecified = true
}
};
List<InventoryAssignment> list = new List<InventoryAssignment>();
list.Add(assignment);
ifitemlist.item[b].inventoryDetail = new InventoryDetail
{
inventoryAssignmentList = new InventoryAssignmentList
{
inventoryAssignment = list.ToArray()
}
};
ifitemlist.item[b].quantity += 'quantity shipped';
If the line item has not yet been added, create new line item:
ItemFulfillmentItem ffItem = new ItemFulfillmentItem();
ffItem.item = ifitemlist.item[b].item;
ffItem.itemReceive = true;
ffItem.itemReceiveSpecified = true;
ffItem.itemIsFulfilled = true;
itemIsFulfilled = true;
ffItem.itemIsFulfilledSpecified = true;
ffItem.orderLineSpecified = true;
ffItem.orderLine = ifitemlist.item[b].orderLine;
//Check if serialized
if (Your fulfillment item contains serialized data)
{
ffItem.serialNumbers = 'Serial numbers';
InventoryAssignment assignment = new InventoryAssignment
{
issueInventoryNumber = new RecordRef {
internalId = 'Inventory internal ID',
type = RecordType,
typeSpecified = true
}
};
ffItem.inventoryDetail = new InventoryDetail
{
inventoryAssignmentList = new InventoryAssignmentList
{
inventoryAssignment = new InventoryAssignment[]
{
assignment
},
replaceAll = false
},
nullFieldList = new string[] { },
customForm = new RecordRef { }
};
}
ffItem.quantity = 'QUANTITY SHIPPED';
ffItem.quantitySpecified = true;
ifitems.Add(ffItem);
Finally, add your "ifitems" list to your Item Fulfillment and add this to NetSuite:
ItemFulfillmentItemList ifitemlistToFulfill = new ItemFulfillmentItemList();
ifitemlistToFulfill.replaceAll = false;
ifitemlistToFulfill.item = ifitems.ToArray();
ItemFulfillment newItemFulfill = new ItemFulfillment();
newItemFulfill.itemList = ifitemlistToFulfill;
_service.add(newItemFulfill);
My goal here so to make the listing say "Free International Shipping". Trying to set up international options and it said I need to set ShipToLocation I tried the line below:
internationalShippingOptions.ShipToLocation.Add("Worldwide");
But when the program hits it I get this error:
"Object reference not set to an instance of an object"
If you would like to see the full method it is:
static ShippingDetailsType BuildShippingDetails()
{
ShippingDetailsType sd = new ShippingDetailsType();
sd.ApplyShippingDiscount = false;
sd.ShippingType = ShippingTypeCodeType.Flat;
AmountType amount = new AmountType();
amount.Value = 0;
amount.currencyID = CurrencyCodeType.USD;
ShippingServiceOptionsTypeCollection shippingOptions = new ShippingServiceOptionsTypeCollection();
ShippingServiceOptionsType domesticShippingOptions = new ShippingServiceOptionsType();
domesticShippingOptions.ShippingService = ShippingServiceCodeType.EconomyShippingFromOutsideUS.ToString();
domesticShippingOptions.FreeShipping = true;
domesticShippingOptions.ShippingServiceCost = amount;
domesticShippingOptions.ShippingServicePriority = 1;
shippingOptions.Add(domesticShippingOptions);
ShippingServiceOptionsType internationalShippingOptions = new ShippingServiceOptionsType();
InternationalShippingServiceOptionsType internationalShippingOptions = new InternationalShippingServiceOptionsType();
internationalShippingOptions.ShippingService = ShippingServiceCodeType.StandardInternational.ToString();
internationalShippingOptions.ShipToLocation.Add("Worldwide");
internationalShippingOptions.FreeShipping = true;
sd.InternationalShippingServiceOption = new InternationalShippingServiceOptionsTypeCollection(new InternationalShippingServiceOptionsType[] { internationalShippingOptions });
sd.ShippingServiceOptions = shippingOptions;
return sd;
}
Here is the code to make it say "Free Standard Intl Shipping". At first in the sandbox it says "Free Standard Shipping" but if you change the shipping destination in the sandbox it will say "Free Standard Intl Shipping".
static ShippingDetailsType BuildShippingDetails()
{
// Shipping details
ShippingDetailsType sd = new ShippingDetailsType();
sd.ApplyShippingDiscount = true;
sd.PaymentInstructions = "eBay .Net SDK test instruction.";
sd.ShippingRateType = ShippingRateTypeCodeType.StandardList;
// Shipping type and shipping service options
//adding international shipping
InternationalShippingServiceOptionsType internationalShipping1 = new InternationalShippingServiceOptionsType();
internationalShipping1.ShippingService = ShippingServiceCodeType.StandardInternational.ToString();
internationalShipping1.ShippingServiceCost = new AmountType { Value = 0, currencyID = CurrencyCodeType.USD };
internationalShipping1.ShippingServicePriority = 1;
internationalShipping1.ShipToLocation = new StringCollection(new[] { "Worldwide" });
sd.ShippingServiceUsed = ShippingServiceCodeType.StandardInternational.ToString();
sd.InternationalShippingServiceOption = new InternationalShippingServiceOptionsTypeCollection(new[] { internationalShipping1 });
//adding domestic shipping
ShippingServiceOptionsType domesticShipping1 = new ShippingServiceOptionsType();
domesticShipping1.ShippingService = ShippingServiceCodeType.ShippingMethodStandard.ToString();
domesticShipping1.ShippingServiceCost = new AmountType { Value = 0, currencyID = CurrencyCodeType.USD };
domesticShipping1.ShippingInsuranceCost = new AmountType { Value = 0, currencyID = CurrencyCodeType.USD };
domesticShipping1.ShippingServicePriority = 4;
domesticShipping1.LocalPickup = true;
domesticShipping1.FreeShipping = true;
sd.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection(new[] { domesticShipping1 });
sd.ShippingType = ShippingTypeCodeType.Flat;
return sd;
To call the method:
item.ShippingDetails = BuildShippingDetails();