Skip to main content
Published: March 23 2007, 3:36:00 PMUpdated: November 28 2020, 3:33:19 PM

I am using JAVA SDK, how can I specify Shipping Cost as free in my AddItem request ?

Summary

  If you need to set the Shipping Cost as Free for your listing, you just define the ShippingServiceCost to 0 in your ShippingDetails container.

 This sample project is written with eBay JAVA SDK framework, and it lists an Chinese auction item that will ship the item with zero charge using Standard Flat Rate Shipping Service. 


Detailed Description

Here are the major methods of the sample project. The full source code can be downloaded below.

public static void  main(String[] args){
        AppAddItem aai = new AppAddItem();
       
        try {
            ItemType item = aai.buildItem();
            FeesType fees;
            AddItemCall request = new AddItemCall(aai.apiContext);
            request.setItem(item);
            fees = request.addItem();
        }catch(Exception e){
            e.printStackTrace();
        }
    }


    private ItemType buildItem() throws Exception{
        String t;
        ItemType item = new ItemType();
        item.setSite(SiteCodeType.US);
        item.setCurrency(CurrencyCodeType.USD);
       
        t = "eBay SDK Test. DO NOT BID!";
        item.setTitle(t);
        item.setDescription("This is a test item created by eBay SDK Test.");
        item.setStartPrice(new AmountType(10.00));
        item.setListingDuration(ListingDurationCodeType.Days_7.getValue());
        item.setLocation("San Jose, CA");
        item.setCountry(CountryCodeType.US);
   
        CategoryType cat = new CategoryType();
        cat.setCategoryID("14111");
        item.setPrimaryCategory(cat);
       
        item.setQuantity(new Integer(1));
        // payment method
        BuyerPaymentMethodCodeType[] arrPaymentMethods =
                new BuyerPaymentMethodCodeType[] {BuyerPaymentMethodCodeType.PaymentSeeDescription};
        item.setPaymentMethods(arrPaymentMethods);
        item.setShippingDetails(getShippingDetails());
       
        return item;
    }
    

    private  ShippingDetailsType getShippingDetails(){
        // construct shipping details container
        ShippingDetailsType sd = new ShippingDetailsType();
        sd.setShippingType(ShippingTypeCodeType.Flat);
        ShippingServiceOptionsType st1 = new ShippingServiceOptionsType();
        st1.setShippingService(ShippingServiceCodeType.ShippingMethodStandard.getValue());

        // set ShppingServiceCost =  0
        st1.setShippingServiceCost(new AmountType(0));
        st1.setShippingServicePriority(new Integer(1));
        sd.setShippingServiceOptions(new ShippingServiceOptionsType[]{st1});
       
        return sd;
    }


    public static UUIDType newUUID() {
        String uuid = org.apache.axis.components.uuid.UUIDGenFactory.getUUIDGen(null).nextUUID();
        StringBuffer goodUuid = new StringBuffer();
        for(int i = 0; i < uuid.length(); i ++){
            char c = uuid.charAt(i);
            if( c != '-' )
                goodUuid.append(c);
        }
        return new UUIDType(goodUuid.toString()) ;
    }


 Version Info

The code example above was based on the versions specified below:

API Schema Version503
Java SDK Versionjavasdk v503.0 Point Release  

 

 

How well did this answer your question?
Answers others found helpful