question

$$anonymous$$ avatar image
0 Likes"
$$anonymous$$ Suspended asked

Calculated Shipping costs with Ebay Java API

Hey all,

 

I am actually having an unusually hard time with using the eBay Java API and finding/retrieving the Calculated Shipping Cost of an item. I am trying to get the Shipping Cost of an item when the ShippingTypeCode has been set to "CALCULATED". For all other shipping options, I am able to retrieve the value cost of that shipping method via getting the value of:

 

ShippingOptions.getShippingServiceCost()

 

Unfortunately, when items have been marked as "Calculated", the shippingServiceCost() is set to "null" -- which I am guess is null initially because the destination postal code has not been set (prior to the auction ending). However, after the auction has ended and the item has been sold, I would assume I should be able to return the Calculated Shipping Cost for an item to the user.

 

Can someone inform me on how to properly get the Shipping Cost for an item set as "CALCULATED"?

 

Thanks in advance,

 

 

ebay-apicommerce-ecommerce-java-e
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

zhuowei.developersupport@ebay.com avatar image
0 Likes"
zhuowei.developersupport@ebay.com answered

Hi bino360, 

   Not sure what API call you used when you say  shippingServiceCost() is set to null when items are listed as "Calculated"  but with Trading.GetItemShipping API,  I am able to get the shipping cost information for item that uses calculated shipping . Below is my sample code snippet.  If you need further assistance, please file a support request with the detailed information so that we can help you on one to one base.

 public static void main(String[] args) {
     
        ApiContext apiContext = new ApiContext();
            GetItemShippingCall apiCall = new GetItemShippingCall(apiContext);
        apiContext.setApiServerUrl(APISERVERURL);
        apiContext.getApiCredential().seteBayToken(TOKEN);
        DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[]{
            DetailLevelCodeType.RETURN_ALL
        };

        apiCall.setItemID("YOUR ITEMID");
        apiCall.setDestinationCountryCode(CountryCodeType.US);
        apiCall.setDestinationPostalCode("YOUR US ZIPCODE");
        apiCall.setQuantitySold(1);

          ShippingDetailsType shippingDetails = null;
        try {
            System.out.println("ItemShipping for Item :" + apiCall.getItemID());
            shippingDetails = apiCall.getItemShipping();
        } catch (Exception e) {
       /// handle exception here
            
        }
          if (apiCall.hasError()) {
            ErrorType[] errors = apiCall.getApiException().getErrors();
            for (ErrorType err : errors) {
                System.out.println(" The call is blocked by the following error : { { { ");
                System.out.println(" >>> Error Type:" + err.getErrorClassification().value().toString());
                System.out.println(" >>> ShortErrorMsg : " + err.getShortMessage());
                System.out.println(" >>> LongErrorMsg : " + err.getLongMessage());
                System.out.println(" >>> SeverityCode: " + err.getSeverityCode());
                System.out.println(" >>> ErrorCode : " + err.getErrorCode());
                System.out.println(" }}}} ");
            }
          }else {
            if (shippingDetails != null) {
                System.out.println("ShippingType : " + shippingDetails.getShippingType().name());
                ShippingServiceOptionsType[] options = shippingDetails.getShippingServiceOptions();
                if (options != null && options.length > 0) {
                    for (ShippingServiceOptionsType sso : options) {
                        System.out.println("ShippingService : " + sso.getShippingService());
                        System.out.println("ShippingServiceCost : " + sso.getShippingServiceCost().getValue() + " " +     sso.getShippingServiceCost().getCurrencyID());
                    }
                }
            }
        }
    }

 

Best Regards,

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

midnighttech avatar image
0 Likes"
midnighttech answered

Can one use this API to get the Actual Shipping Costs for an item?  It appears that one needs to get the item ID and then know where the item is to be shipped to in order to get the shipping cost:

         apiCall.setItemID("YOUR ITEMID");
        apiCall.setDestinationCountryCode(CountryCodeType.US);  << HERE
        apiCall.setDestinationPostalCode("YOUR US ZIPCODE"); << HERE
        apiCall.setQuantitySold(1);  << AS Well you need to know the quantity sold

 

So if one retrieved the transaction then one could fill these fields in and get the estimated shipping cost the seller would charge.  But isn't the shipping charged already in the fields returned from GetTransaction or would the GetItemShippingCall return information not included in the GetTransaction Call?

 

M-

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.