++ed by:

1 PAUSE user
3 non-PAUSE users.

Andrew Baerg




version 3.01


  use Shipment::UPS;
  use Shipment::Address;
  use Shipment::Package;

  my $shipment = Shipment::UPS->new(
    from_address => Shipment::Address->new( ... ),
    to_address => Shipment::Address->new( ... ),
    packages => [ Shipment::Package->new( ... ), ],

  foreach my $service ( $shipment->all_services ) {
    print $service->id . " (" . $service->cost . ")\n";

  $shipment->rate( 'express' );
  print $shipment->service->cost . "\n";

  $shipment->ship( 'ground' );


Shipment::UPS - Interface to UPS Shipping Web Services


This class provides an interface to the UPS Online Tools.

For code examples, see https://github.com/pullingshots/Shipment/tree/master/eg

You must sign up for a developer access key in order to make use of this module.


See related modules for documentation on options and how to access rates and labels:

Shipment::Base - common attributes and methods for all interfaces

Shipment::Address - define an from or to address

Shipment::Package - define package details, weight, dimensions, etc

Shipment::Service - access information about a service, rate, etd, etc

Shipment::Label - access the label file

It makes extensive use of SOAP::WSDL in order to create/decode xml requests and responses. The Shipment::UPS::WSDL interface was created primarily using the wsdl2perl.pl script from SOAP::WSDL.

Class Attributes

username, password, key

Credentials required to access UPS Online Tools.


This determines whether you will use the UPS Customer Integration Environment (for development) or the production (live) environment * wwwcie.ups.com (development) * onlinetools.ups.com (production)


Turn negotiated rates on or off.

The Shipper Account/UserID used must be qualified to receive negotiated rates. You will most likely need to contact UPS to have set this up.

If the Shipper Account/UserID is not qualified, the published rates will be used instead and a notice set.

Default is off.


Flag the ship to address as residential.

Default is false.


Turn address validation on or off. When on, ship will fail if the address does not pass UPS address validation

Default is on.


The label height. Can be either 6" or 8". The label width is fixed at 4".


In certain cases (i.e. for shipments with declared value over $999), UPS will return a control log receipt which must be printed off along with the label.

type: Shipment::Label


Set the Carbon Neutral Indicator - http://www.ups.com/content/us/en/resources/ship/carbonneutral/shipping.html

type: Bool

Type Maps


UPS returns service codes without descriptions. This is mapped here so that we can display 'UPS Ground' instead of '03'.

Shipment::Base type maps

Shipment::Base provides abstract types which need to be mapped to UPS codes (i.e. bill_type of "sender" maps to UPS "BillShipper")

custom package types

UPS provides package types in addition to the defaults in Shipment::Base * 25kg_box * 10kg_box * pallet * small_express_box * medium_express_box * large_express_box

custom printer types

UPS does not offer a pdf option for labels, so the default printer type is image (gif).

UPS does offer additional thermal options: * ZPL * SPL * STARPL

default currency

The default currency is USD


Enable UPS SurePost This includes surepost 1 lb or Greater and Surepost less than 1 lb Note: for less than 1 lb (service id 92) weight must be in ounces specified as oz


Enable UPS SurePost BPM Bound printed matter parcels


Enable UPS SurePost media Media parcesl with weight 1 lb to 70 lbs

Class Methods


This calls ProcessRate from the Rating API with RequestOption => 'Shop'

Each RatedShipment that is returned is added to services

The following service mapping is used: * ground => 03 (UPS Ground) or 11 (UPS Standard) * express => 02 (UPS Second Day Air) * priority => 01 (UPS Next Day Air)


This calls ProcessRate from the Rating API with RequestOption => 'Rate'


This method calls ProcessShipment from the Shipping API


This method calls ProcessShipment from the Shipping API with ReturnService => Code => $return_code $return_code can be either 9, 8 or 2.

9 provides a return label to be printed off. 8 causes UPS to email a return label to $self->from_address->email 2 causes UPS to mail a return label to $self->from_address

defaults to 9 (print return label)

This method has only been implemented for the purpose of obtaining certification with UPS. It has not been fully tested and does not offer some core options.

It assumes that you are first creating an outgoing shipment and creating the return shipment at the same time. Because of this, it uses the "to_address" as the origin and the "from_address" as the destination.


This method calls ProcessVoid from the Shipping API

It uses $self->tracking_id for the shipment identification number in order to void a single package shipment.

It will use all package tracking id's to void one or more packages within a multi-package shipment.

returns "Voided" if successful


UPS Address validation

This method calls ProcessXAV from the Shipping API request_option defaults to 1 1 address validation 2 address classification 3 address validation and classification


Andrew Baerg @ <andrew at pullingshots dot ca>


William Taylor @ <williamt at sonic dot net>


Issues can be submitted at https://github.com/pullingshots/Shipment/issues


Copyright (C) 2016 Andrew J Baerg, All Rights Reserved


Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Andrew Baerg <baergaj@cpan.org>


This software is copyright (c) 2018 by Andrew Baerg.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.