active_shipping: shipping labels

268 views
Skip to first unread message

Donald Ball

unread,
Mar 31, 2009, 2:15:56 PM3/31/09
to activem...@googlegroups.com
We're planning on using active_shipping in a project, but require
carrier shipping labels, which are not supported. Putting thought to
deed, I've begun work on supporting UPS shipping labels in the
following fork:

http://github.com/deepsalt/active_shipping/tree/master

The good stuff is in the ups carrier and its remote test.

Having spiked a solution for UPS, I'm now working on supporting USPS
labels and then factoring out the commonalities. Fedex support would
of course be nice but is not something for which I have an immediate
need.

Supporting UPS and USPS with a common API presents a challenge right
off the bat, of course. UPS has a two-stage shipping label purchase
process, where you must accept a quoted shipment rate before getting
the label. USPS does it all it one pass. I was thinking that a common
interface might look like:

carrier.buy_shipping_labels(shipper, origin, destination, packages, options)

origin and destination would be locations, packages would be packages
shipper would be a new Shipper object which would have at least a name
and an account number
options might consist of:

expected_price: the expected cost of the shipment, presumably based on
a rate quoted by the rate request api (default: the confirmation is
automatically accepted)
price_epsilon: the amount by which the shipment quote may exceed the
expected price without automatically refusing the confirmation
(default: 0)
payer: a shipper or a creditcard (default: the given shipper)

The return value would probably be a new Shipment object which would
have a Label for each Package.

Any comments? In particular, if anyone with Fedex shipping label
experience can note if the proposed API would cover their case, that'd
be super.

- donald

Cody Fauser

unread,
Apr 2, 2009, 12:40:24 PM4/2/09
to activem...@googlegroups.com
Donald,

That looks like a great common API for ActiveShipping. How do the APIs
handle the printing of the labels themselves?
--
Cody Fauser
http://shopify.com - e-commerce done right
http://www.codyfauser.com - blog
http://peepcode.com/products/activemerchant-pdf - ActiveMerchant PeepCode
http://www.oreilly.com/catalog/rjsrails - RJS Templates for Rails

Donald Ball

unread,
Apr 2, 2009, 3:15:59 PM4/2/09
to activem...@googlegroups.com
The APIs for UPS and USPS return base64 encoded images which contain
the printable labels. It's all fairly straightforward.

I'm actually working on a revised active_shipping API, at least
internally. I've introduced a Shipment object which has all of the
relevant attributes you might expect (destination, packages, labels,
tracking number, etc.) and am using that as a message object; it's
helped clarify the code substantially. I'm tinkering around with the
notion of allowing the public API to operate on shipment objects,
e.g.:

rates = carrier.get_rates(shipment)
...
shipment.service = rates.first.service_code
carrier.buy_shipping_labels(shipment)
shipment.labels.each do |label|
...
end
...
carrier.find_tracking_info(shipment)

That might be gilding the lily, I'm not sure, but I think it's more
convenient than passing around a disparate collection of addresses and
packages. Any thoughts on that?

- donald

Reply all
Reply to author
Forward
0 new messages