Question

I'm trying to get the total shipping cost for an order via the eBay GetOrders call in the API. I have created a test order that has 1 item with free postage, one item with a calculated shipping cost, and one item with a flat shipping cost (to cover all scenario's).

I've tried getting the shipping cost for each item using TransactionArray/Transaction/ActualShippingCost and then adding the total. Ive also tried ShippingDetails/ShippingServiceOptions/ShippingServiceCost but I can't seem to figure it out.

Here is the latest code I could come up with but it keeps reporting the error: "Object reference not set to an instance of an object"

double ShippingCost = 0.00;
foreach (TransactionType transaction in orderTrans)
{

    ShippingCost += transaction.ActualShippingCost.Value; //this line causes error
}
MessageBox.Show("Total Shipping Cost is: " + ShippingCost.ToString());
Was it helpful?

Solution

Try reading shipping cost from order:

if (order.ShippingServiceSelected.ShippingServiceCost != null)
{
    ShippingCost = order.ShippingServiceSelected.ShippingServiceCost.Value
}

we use this method in our code and it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top