Voiding a Shipment¶
Although most carriers don’t charge your account until the package has actually been delivered, you have the option to void a shipment.
To void a shipment use the Void class and voidShipment() method with the first argument set to the shipment identification number. This is usually the tracking number of the first package. If there is only one package it will be the same.
The following carriers are currently capable of voiding labels:
- USPS (through Stamps.com)
- Canada Post
Carriers Not Supported¶
Not all carriers have the ability to void labels.
- DHL does not have a void API. Labels cannot be voided
- USPS cannot create postage paid labels so there is no void method
<?php $void = new \RocketShipIt\Void('UPS'); $response = $void->voidShipment('1Z12345E0390856432');
You can also void multiple packages in a shipment. Where the first argument is the shipment ID and the second argument is an array with the package ids you want to void:
<?php $void = new \RocketShipIt\Void('UPS'); $response = $void->voidPackage('1Z12345E1234567890', array( '1Z12345E8635481269', '1Z12345E1593518308' ) );
You can also void a single package by setting the second argument as a string.
Shipping and Tracking Numbers for Testing¶
|1ZISDE016691676846||A successful response will be returned for a shipment level void request.|
|1Z2220060290602143||A successful response will be returned for a shipment level void request.|
|1Z2220060294314162, 1Z2220060291994175||The request will void the package in the shipment.|
|1Z2220060292690189, 1Z2220060292002190||The request will void the package in the shipment.|
|1Z2220060290530202, 1Z2220060293874210, 1Z2220060292634221||The request will void package 1Z2220060293874210 but package 1Z2220060292634221 cannot be voided.|
<?php $v = new \RocketShipIt\Void('fedex'); $v->setParameter('trackingIdType','GROUND'); $response = $v->voidShipment($shipmentId); print_r($response);
You must create a shipment and then void that shipment for testing. FedEx does not have a sample shipment to void.
To void a paid USPS label simply pass the Stamps.com transaction id to the voidShipment() function:
<?php $v = new \RocketShipIt\Void('STAMPS'); $response = $v->voidShipment('c605aec1-322e-48d5-bf81-b0bb820f9c22'); print_r($response);
DHL actually has no method for voiding labels. DHL has confirmed that labels don’t need to be voided as they are only charged when used.
<?php $v = new \RocketShipIt\Void('canada'); $v->setParameter('shipEmail', 'email@example.com'); // email to send refund receipt to $response = $v->voidShipment('340531309186521749'); print_r($response);