Skip to main content
Published: March 17 2011, 4:40:00 PMUpdated: November 28 2020, 1:55:04 PM

It is always a good idea to keep the buyer posted about the order shipping status. Use the CompleteSale call mark an item as shipped. You can also upload a shipment tracking number so that the buyer can track the order.

This is a sample that demonstrates how to mark an item as shipped and upload the tracking number.

/*
© 2011-2013 eBay Inc., All Rights Reserved
Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php
*/

import com.ebay.sdk.*;
import com.ebay.sdk.call.*;
import com.ebay.soap.eBLBaseComponents.*;


/**
*
* Sample code to relist an item (with minor modifications) using the RelistFixedPriceItem call
*
* The following steps outline what needs to be done for a successfull GetTransactions and GetOrders call
*
* 1. Create an ApiContext Object
* 2. Set the auth token and target api url (Webservice endpoint)
* 3. Create an object of CompleteSaleCall.
* 4. Set the following values to the object
*            OrderLineItemID
*            Shipment Details
* 5. Complete the sale by calling CompleteSaleCall#completeSale()      
*
*/
public class CompleteSale {

    public static void completeSale() {

        ApiContext apiContext = new ApiContext();
        ApiLogging apiLogging = new ApiLogging();
        apiContext.setApiLogging(apiLogging);

       // set the server url and credentials for Sandbox
        apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");
        ApiCredential cred = apiContext.getApiCredential();
        cred.seteBayToken("YOUR TOKEN");
        apiContext.setApiCredential(cred);

        // If you are makding the call for UK sellers
        // Set site to UK  as apiContext.setSite(SiteCodeType.UK)
        apiContext.setSite(SiteCodeType.US); // Set site to US
        
        
        CompleteSaleCall completeSaleApi = new CompleteSaleCall(apiContext);
        String OrderLineItemID = "150571802827-0";
        String shippingCarrier ="YOUR CARRIER";
        String trackingNumber = "YOUR TRACKING NUMBER";
             

        completeSaleApi.setOrderLineItemID(OrderLineItemID);
        completeSaleApi.setShipped(true);
        ShipmentType shipType = new ShipmentType();

        ShipmentTrackingDetailsType shpmnt = new ShipmentTrackingDetailsType();
        shpmnt.setShipmentTrackingNumber(trackingNumber);
        shpmnt.setShippingCarrierUsed(shippingCarrier);
        shipType.setShipmentTrackingDetails(new ShipmentTrackingDetailsType[]{shpmnt});

        completeSaleApi.setShipment(shipType);

        try {
            completeSaleApi.completeSale();
        } catch (ApiException e) {
            e.printStackTrace();
        } catch (SdkException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static void main(String[] args) {
        completeSale();
    }

}

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