These docs are for v1.1. Click to read the latest docs for v1.2.

You may configure EasyShip to execute callback functions on the success or failure of a shipment label's generation. As each shipment label is submitted for purchase on your page, a poller will monitor the statuses for all pending labels until generation has completed.

A successful label generation will trigger the .success() callback function and, likewise, a failure to generate a label will trigger the .failure() function.

Example configuration

To enable this feature, you must set a polling interval in milliseconds, with a minimum of 500ms.

<script
  src="https://app.shippingeasy.com/easyship.js"
  data-partner-key="XXX"
  data-polling-interval=1000 
  data-token="dc02eec82448924a6a8d0ad4a1174af41e342fc2d45962e702ac137bd">
</script>

By default the success and failure functions do nothing, so you will need to customize them. A JSON object representing the shipment will be passed into the callback functions and is identical to the payload sent via the EasyShip webhooks.

<script>
  EasyShip.success = function (shipment) {
	  console.log("Success: " + shipment.tracking_number);
  }

  EasyShip.failure = function (shipment) {
	  console.log("Failure: " + shipment.order_number);
  }
</script>

Example JSON payload

{  
   "order_number":"w123456xxZs77",
   "refund_url":"http://127.0.0.1:5000/easyship/shipments/22d1483733a4ec3211028fe3307e2a7c4c0a3466a6adf1032095d717b558906cfebc5b3ca3853f6406e96bda5a89b290d46d2b7aaf0a3fa77f996e2acbed6cff/cancellations",
   "tracking_url":"https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=0405510200830101052348",
   "tracking_number":"0405510200830101052348",
   "ship_date":"2015-05-12",
   "carrier":"USPS",
   "status":"purchased",
   "carrier_service":"Priority Mail (2-3 days)",
   "shipper":{  
      "external_identifier":"9283788",
      "name":"EasyShip Test Customer",
      "email":"[email protected]"
   }
}