Skip to main content
Published: August 31 2010, 11:09:00 PMUpdated: November 28 2020, 8:44:54 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. It has been written using Java SDK v673

 

Below is the code. Corresponding SOAP request is attached with this article.

Note: If an item has to be shipped in multiple shipments/packages use multiple <ShipmentTrackingDetails> container to specifty the tracking details.

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

package com.ebay.sample;

import com.ebay.sdk.ApiContext;
import com.ebay.sdk.ApiCredential;
import com.ebay.sdk.ApiException;
import com.ebay.sdk.SdkException;
import com.ebay.sdk.call.CompleteSaleCall;
import com.ebay.soap.eBLBaseComponents.ShipmentTrackingDetailsType;
import com.ebay.soap.eBLBaseComponents.ShipmentType;
import com.ebay.soap.eBLBaseComponents.SiteCodeType;

/**
*
* 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
*            ItemID
*           TransactionID
*           Shipping Details
* 5. Complete the sale by calling CompleteSaleCall#completeSale()     
*
*/
public class CompleteSale {
     
     public static void completeSale(){
          ApiContext apiContext = new ApiContext();
          // set API Token to access eBay API Server
          ApiCredential cred = apiContext.getApiCredential();
          //Set Auth Token
          //cred.seteBayToken("YourToken");
          cred.seteBayToken("YourToken");
     
          apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");// Pointing to sandbox for testing.          
          
          apiContext.getApiLogging().setLogSOAPMessages(true);// This will log SOAP requests and responses

          apiContext.setSite(SiteCodeType.UK); // Set site to UK
          
          CompleteSaleCall completeSaleApi = new CompleteSaleCall(apiContext);
          
          completeSaleApi.setItemID("110049243019");
          completeSaleApi.setTransactionID("25291804001");
          completeSaleApi.setShipped(true);
          
          ShipmentType shipType = new ShipmentType();
          
          ShipmentTrackingDetailsType shpmnt = new ShipmentTrackingDetailsType();
          shpmnt.setShipmentTrackingNumber("VZ9478668");
          shpmnt.setShippingCarrierUsed("YourCarrier");
          
          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