Web Shipping Javascript SDK by ShipRush

Web Shipping SDK is a cloud service for developers. It is packaged as CSS/Javascript library that can be dropped into any existing site. Yes, you can print shipping labels from your website by adding 20 lines of javascript.

Reference Docs

Demo

Open web shipping in new browser window
Use My.ShipRush sandbox
Require signature
Set declared value to $150
Make return shipment

Sample

JS/CSS references. Note that you should remove jQuery/JSON if you already reference them in your project.

<!-- External dependencies. Remove these lines if you already use jQuery and JSON.js on your site -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/json2/20130526/json2.min.js"></script>

<!-- ShipRush Web Shipping references -->    
<link href="/static.shiprush.com/ship.app/api/webshipping.integration.client.css" rel='stylesheet' type='text/css' />
<script src="/static.shiprush.com/ship.app/api/webshipping.integration.client.js"></script>

Javascript code that you need to add to "onClick" event to open web shipping.

var shipment = {
    ShipTo : {
        Name: "John Smith",
        Company: "Acme Widgets",
        Address1: "5th ave S",
        Address2: "#101",
        City: "Seattle",
        State: "WA",
        PostalCode: "98118",
        Country: "US",
        Phone: "(206)332-2233"
    },
    CarrierTypeName: "FedEx",
    ServiceTypeName: "Ground",
    Packages: [{
        Weight: "2"
    }]
}

shipRushClient.Open(
{
    Shipment: shipment,
    OnShipmentCompleted: function (data) {
        alert(data.Shipment.TrackingNumber);
        // Return "true" to close shipping form
        return true;
    }
});

Callback events

There are several callback events that you can use: OnShipmentCompleted(data), OnClose() and OnAction(event_name, data). "data.Shipment" has shipment updated with tracking number, shipping charges and ShipmentId.

"OnAction" that has 2 parameters (event_name, data), where "event_name" could be any system event (currently "shipment_completed", "void", "reprint" and "close". Most likely that we will add more events in the future).

Note that after printing shipping label BOTH "OnShipmentCompleted" and "OnAction" will be called ("OnShipmentCompleted" first).

Opening existing shipment

Set a callback to "OnShipmentCompleted" event. Inside this event capture "data.Shipment.ShipmentId" and save it somewhere on your system. When you you want to open this shipment again - set "Shipment.ShipmentId" property to the saved value when calling "shipRushClient.Open()". In this case all other shipment properties will be ignored (and we will not create a new shipment on our side). We will just open a form with a saved shipment.

Alternative way of getting tracking numbers to your system

You can subscribe to shipping notifications by providing a notification URL (on your server) via Shipment.PostbackUrl. This is simple and automatic. Send in a url, receive back the shipment info.

My.ShipRush will do an HTTP post to the provided URL with the full Shipment/Order data. We recommend using online HTTP-post catching service like http://requestb.in/ for testing PostbackUrl functionality.

You can control the postback format via Shipment.PostbackContentType ("ShipmentView" or "TRequest"). Here is an online example using legacy XML format ("TRequest").

Make sure to pad PostbackUrl with some kind of authentication token to prevent someone else posting invalid data to your system. We strongly suggest that this be a dynamic, changing token. NOT a global token. The max length for a PostBackURL is 55 characters.

More Samples

How to set various Shipment and Package options (Residential, Email, Dims, Signature, etc.)

How to make multiparcel shipment

How to ship international and set commodities

How to set shipment currency

How to use our legacy 'TRequest' shipment structure

How to integrate with desktop app via URL

How to convert custom shipment service requested with eCommerce order

How to parse unstructured address block

Interactive Javascript playroom (like JSFiddle for WebShipping API)

Visual Options (show/hide buttons and panels)

Open existing shipment + callback events

Non visual operations (rate/rate shopping)