Git Product home page Git Product logo

active_shipping's Introduction

ActiveShipping Build status

This library interfaces with the web services of various shipping carriers. The goal is to abstract the features that are most frequently used into a pleasant and consistent Ruby API:

  • Finding shipping rates
  • Registering shipments
  • Tracking shipments
  • Purchasing shipping labels

Supported Shipping Carriers

Versions

Note: 2.x contains breaking changes, please see the changelog. Shopify will not be actively contributing to the 2.x version of this gem and is looking for maintainers.

See our releases for past versions.

Installation

Using bundler, add to the Gemfile:

gem 'active_shipping'

Or stand alone:

$ gem install active_shipping

Sample Usage

Compare rates from different carriers

require 'active_shipping'

# Package up a poster and a Wii for your nephew.
packages = [
  ActiveShipping::Package.new(100,               # 100 grams
                              [93,10],           # 93 cm long, 10 cm diameter
                              cylinder: true),   # cylinders have different volume calculations

  ActiveShipping::Package.new(7.5 * 16,          # 7.5 lbs, times 16 oz/lb.
                              [15, 10, 4.5],     # 15x10x4.5 inches
                              units: :imperial)  # not grams, not centimetres
 ]

 # You live in Beverly Hills, he lives in Ottawa
 origin = ActiveShipping::Location.new(country: 'US',
                                       state: 'CA',
                                       city: 'Beverly Hills',
                                       zip: '90210')

 destination = ActiveShipping::Location.new(country: 'CA',
                                            province: 'ON',
                                            city: 'Ottawa',
                                            postal_code: 'K1P 1J1')

 # Find out how much it'll be.
 usps = ActiveShipping::USPS.new(login: 'developer-key')
 response = usps.find_rates(origin, destination, packages)

 usps_rates = response.rates.sort_by(&:price).collect {|rate| [rate.service_name, rate.price]}
 # => [["USPS Priority Mail International", 4110],
 #     ["USPS Express Mail International (EMS)", 5750],
 #     ["USPS Global Express Guaranteed Non-Document Non-Rectangular", 9400],
 #     ["USPS GXG Envelopes", 9400],
 #     ["USPS Global Express Guaranteed Non-Document Rectangular", 9400],
 #     ["USPS Global Express Guaranteed", 9400]]

Dimensions for packages are in Height x Width x Length order.

Track a FedEx package

fedex = ActiveShipping::FedEx.new(login: '999999999', password: '7777777', key: '1BXXXXXXXXXxrcB', account: '51XXXXX20')
tracking_info = fedex.find_tracking_info('tracking-number', carrier_code: 'fedex_ground') # Ground package

tracking_info.shipment_events.each do |event|
  puts "#{event.name} at #{event.location.city}, #{event.location.state} on #{event.time}. #{event.message}"
end
# => Package information transmitted to FedEx at NASHVILLE LOCAL, TN on Thu Oct 23 00:00:00 UTC 2008.
# Picked up by FedEx at NASHVILLE LOCAL, TN on Thu Oct 23 17:30:00 UTC 2008.
# Scanned at FedEx sort facility at NASHVILLE, TN on Thu Oct 23 18:50:00 UTC 2008.
# Departed FedEx sort facility at NASHVILLE, TN on Thu Oct 23 22:33:00 UTC 2008.
# Arrived at FedEx sort facility at KNOXVILLE, TN on Fri Oct 24 02:45:00 UTC 2008.
# Scanned at FedEx sort facility at KNOXVILLE, TN on Fri Oct 24 05:56:00 UTC 2008.
# Delivered at Knoxville, TN on Fri Oct 24 16:45:00 UTC 2008. Signed for by: T.BAKER

Carrier specific notes

FedEx connection

The :login key passed to ActiveShipping::FedEx.new() is really the FedEx meter number, not the FedEx login.

When developing with test credentials, be sure to pass test: true to ActiveShipping::FedEx.new().

Tests

You can run the unit tests with:

bundle exec rake test:unit

and the remote tests with:

bundle exec rake test:remote

The unit tests mock out requests and responses so that everything runs locally, while the remote tests actually hit the carrier servers. For the remote tests, you'll need valid test credentials for any carriers' tests you want to run. The credentials should go in ~/.active_shipping/credentials.yml. For some carriers, we have public credentials you can use for testing in .travis.yml. Remote tests missing credentials will be skipped.

Contributing

See CONTRIBUTING.md.

We love getting pull requests! Anything from new features to documentation clean up.

If you're building a new carrier, a good place to start is in the Carrier base class.

It would also be good to familiarize yourself with Location, Package, and Response.

You can use the test/console.rb to do some local testing against real endpoints.

To log requests and responses, just set the logger on your Carrier class to some kind of Logger object:

ActiveShipping::USPS.logger = Logger.new(STDOUT)

Anatomy of a pull request

Any new features or carriers should have passing unit and remote tests. Look at some existing carriers as examples.

When opening a pull request, include description of the feature, why it exists, and any supporting documentation to explain interaction with carriers.

How to contribute

  1. Fork it ( https://github.com/Shopify/active_shipping/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

active_shipping's People

Contributors

adacosta avatar ajsharma avatar akeem avatar aliwu23 avatar blakemesdag avatar christianblais avatar cyu avatar dkubb avatar eboswort avatar garethson avatar jamesmacaulay avatar jbrowning avatar jiblits avatar jnormore avatar kmcphillips avatar kristianpd avatar lucasuyezu avatar maartenvg avatar malazalamir avatar michaelsunglee avatar nigelramsay avatar pborel avatar robfoster avatar scottlangendyk avatar se3000 avatar smartacus avatar soleone avatar tobi avatar trishume avatar wvanbergen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

active_shipping's Issues

Canada Post Issue

Hello there, I can perform the following example with FedEx just fine but when I use Canada post I get an error.

I enter the following:
> require 'active_merchant'
> include ActiveMerchant::Shipping
> package = Package.new(450, [32, 27.5, 4], :units => :metric, :value => 100, :currency => :CA)
> location = Location.new(:address1 => "842 Notre Dame Drive", :country => "CA", :province => "ON", :city => "London", :postal_code => "N6J3C4")
> destination = Location.new(:address1 => "Zur Bleiche 44 A", :country => "DE", :city => "Flensburg", :postal_code => "24941")
> cp = CanadaPost.new(:login => 'CPC_DEMO_XML')
> response = cp.find_rates(location, destination, package)
Here is where I get the error. After I ask for rates, I get the following dump. I'm just the first few useful lines:
ArgumentError: no time information in "www.canadapost.ca"
from /home/mina/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/time.rb:263:in parse' from /home/mina/dev/houseofetiquette.com/vendor/plugins/active_shipping/lib/active_shipping/shipping/carriers/canada_post.rb:210:indate_for'
from /home/mina/dev/houseofetiquette.com/vendor/plugins/active_shipping/lib/active_shipping/shipping/carriers/canada_post.rb:153:in block in parse_rate_response' from /home/mina/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/rexml/element.rb:906:inblock in each'

And the trace goes on, but it's all stuff from inside the ruby gems, not from inside the plugin or my app. Any thoughts? Am I submitting my request wrong, or is there a problem in the api?

Thanks for any help!

UPDATE:
Just an update, I found that I can force the API to work by making the following changes to canada_post.rb under the carriers directory:

    150   xml.elements.each('eparcel/ratesAndServicesResponse/product') do |product|
    151     service_name = (@options[:french] ? @@name_french : @@name) + product.get_text('name').to_s
    152     service_code = product.attribute('id').to_s                                                         
    153     # delivery_date = date_for(product.get_text('deliveryDate').to_s)
    154
    155     rate_estimates << RateEstimate.new(origin, destination, @@name, service_name,
    156       :service_code => service_code,
    157       :total_price => product.get_text('rate').to_s,
    158       :delivery_date => nil,#delivery_date,
    159       :currency => 'CAD'
    160     )

I realize this is a somewhat dirty hack, but it lets me verify other portions of my integration. I would like to be able to get package delivery time though. Any thoughts?

Namespace conflicts

I am using the active_shipping extension in Spree Commerce to calculate live shipping rates. There is a know conflict with active_shipping and ActiveMerchant. I easily solved this by removing the redundant ActiveMerchant lib files and just used the gem files. I suggest you merge this back in or find some other solution. Code here => http://github.com/pho3nixf1re/active_shipping

I found the solution using http://github.com/ariossw/active_shipping but it was out of date compared to your version here.

FedEx returning ERROR 9040

I recently found that all of my attempts at acquiring FedEx tracking data are failing with 9040 stating that there is no information in their system. I've checked manually online and their system does have the data. I've tried different user info as well as getting new user credentials. For the past year everything was fine, but as of about a week or two ago I began seeing this problem. Running ...

#!/usr/bin/env ruby

require 'rubygems'
require 'active_shipping'
include ActiveMerchant::Shipping

#  :login:    # meter number
#  :password: # password from email
#  :key:      # key from initial web page
#  :account:  # account number

fedex = FedEx.new(YAML::load(ERB.new(IO.read(
    'config/fed_ex.yml'
)).result)['test']);

tracking_numbers = %w( 065140275594099 )

tracking_numbers.each do |tracking_number|
    begin
        tracking_info = fedex.find_tracking_info(
            tracking_number, :test => true )

        tracking_info.shipment_events.each do |event|
            puts "#{event.name} at #{event.location.city}, " <<
                "#{event.location.state} on #{event.time}. #{event.message}"
        end

    rescue Exception => e
        puts "tracking number : #{tracking_number} : raised an error."
        puts e.inspect
    end
end

... yields ...

tracking number : 065140275594099 : raised an error.
#<ActiveMerchant::Shipping::ResponseError: ERROR - 9040: No information for the following shipments has been received by our system yet.  Please try again or contact Customer Service at 1.800.Go.FedEx(R) 800.463.3339.>

... on standard ruby and gets pretty ugly on jruby.

I'm trying to avoid calling FedEx, because I can't imagine them being all that helpful. Is anyone else seeing this problem?

FedEx SmartPost

Feature request
Can we get FedEx SmartPost added as an option?

Fedex Track gives error

Hi,

fedex = FedEx.new(:login => 'my_acc_meter_no', :password => 'my_acc_password', :key => 'my_acc_key',
:account=> 'my_acc_no', :test => true)
tracking_info = fedex.find_tracking_info('999999999999', :carrier_code => 'fedex_ground') # Ground package

  tracking_info.shipment_events.each do |event|
puts "#{event.name} at #{event.location.city}, #{event.location.state} on #{event.time}. #{event.message}"

gives error(response)

ActiveMerchant::InvalidCountryCodeError

" Cannot lookup country for an empty name "

Locations quietly default to 'residential', causing FedEx to categorically disable certain shipping types in favor of others.

I'm creating this as a supplement to a ticket I just opened under spree_active_shipping.

FedEx's publicly documented business logic makes certain shipping options only available for commercial shipments, and others only available for residential shipments. The FedEx code in this project defaults all Location objects to 'Residential' if they are not explicitly set as otherwise by the application. This leads to results that are confusing to shipping novices (i.e. me).

Possible solutions

1. Explicitly encode a default value for :address_type when building a Location object

Change the address_type initializer (in ActiveMerchant::Shipping::Location) to immediately and visible specify a default

# before
self.address_type = options[:address_type]

#after
DEFAULT_ADDRESS_TYPE = 'commercial'
self.address_type = options[:address_type] || DEFAULT_ADDRESS_TYPE 

2. Extend the Fedex Carrier class to print som warnings to the console when a Location is used without explicitly setting an :address_type

[Warning] FedEx shipments will default to Residential if you do not specify an :address_type for your origin and destination Locations.  FedEx offers different shipping options based on this setting.

3. Add something to the README about the residential/commercial issue

Something like the text in the previous suggestion would work.

Thanks for the sweet library!

cc: @jdugan

Fedex Ground delivery_range requires manual parsing

Problem

Fedex supplies an in words representation of delivery times for Fedex Ground as opposed to date estimates as their other rates use. This requires manual parsing of the range to be added.

On Fedex Ground this is an example of the provided value:

  <v6:TransitTime>THREE_DAYS</v6:TransitTime>

On other services Fedex offers:

  <v6:DeliveryTimestamp>2012-10-18T16:30:00</v6:DeliveryTimestamp>

Suggested Fix

Use a hash to map out days 1-10 for Fedex ground and provide this for the delivery estimates:

 { "ONE_DAYS" => 1 ... "TEN_DAYS" => 10 } 

FedEx Duplicate Waybill Error

When a Fedex tracking number has multiple waybills, the Active Shipping returns an empty set of events. The FedEx API returns the unique reference numbers (which can then be queried as if they were regular tracking numbers). Was this by design, and would you accept a patch that covers this case?

Release a new version

Hey guys its been about a year since you last released a new version. Lots of good stuff is sitting on master and isn't on rubygems. Think you could push something out? In the meantime i will direct our app to build off master at some stable revision.

Active_shipping on firewalled server

Hello,

I have active_shipping set up, and it works on my test server, and on my production server, provided iptables has been flushed.

When I run iptables with the following rules, requesting a rate response hangs indefinitely:

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere            
   24  1728 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:ssh 
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:www 
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:https 
    0     0 DROP       all  --  any    any     anywhere             anywhere            

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   14  2536 ACCEPT     all  --  any    any     anywhere             anywhere            state NEW,RELATED,ESTABLISHED 

Any idea where the problem may lie?

FedEx error in test environment

I am new to active_shipping - I have obtained credentials with FedEx and I am running the included tests with active_shipping. I called FedEx to get sample tracking numbers - they obliged, but now the tracking number is giving me the following error:

/usr/local/Cellar/ruby/1.9.3-p194/bin/ruby -I"lib:test" -I"/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib" "/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/remote/*_test.rb" 
Run options: 

# Running tests:

.......F................

Finished tests in 25.861488s, 0.9280 tests/s, 3.0934 assertions/s.

  1) Failure:
test_tracking(FedExTest) [/Users/nbomberger/arcweb/scratch/apis/active_shipping/test/remote/fedex_test.rb:130]:
Exception raised:
<#<NoMethodError: undefined method `get_text' for nil:NilClass>>.

24 tests, 80 assertions, 1 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1): [/usr/local/Cellar/ruby/1.9.3-p194/bin/ruby...]

Tasks: TOP => test:remote
(See full trace by running task with --trace)

If I use the default tracking number that is included when I cloned the active_shipping, I get a "No Information available for that package", which seems to be a better error code.

Can anyone shed some light on this for me? I have been spinning my wheels on this, and I am not sure if it is something with the gem, or if it is with FedEx.

Thanks in advance,

Nate

Error with latest commit: "logger" not found

undefined local variable or method `logger' for #ActiveMerchant::Billing::BraintreeGateway:0x396c5f0 (NameError)

vendor/plugins/active_shipping/lib/active_shipping/lib/posts_data.rb:36:in `ssl_request'

Fixed it via:

git checkout c56579c

"This product requires a valid value for Non-Delivery Handling", despite specifying non delivery handling.

I've been digging around for a few hours trying to get everything working using CanadaPostPWS. However, I'm now getting stuck with an error message: "This product requires a valid value for Non-Delivery Handling". I'd like to set to "return to sender", which is 'RTS'.

The source seems to indicate that I include RTS this way:

shipment = cp.create_shipment(origin, destination, package, pi, {customer_number: cp.customer_number, service: 'USA.XP', :rts => true })

...but I'm still getting the error. Am I missing something obvious?

Fedex Labels

I'm looking to build on the work brianwebb01 did for UPS labels to create Fedex labels.

Before I re-invent the wheel, has anyone done this already?

Getting error when calling ups api any ideas

  tracking_info = @ups.find_tracking_info('1Z1861VR0398394099', :carrier_code => '03')

  error
  The XML document is well formed but the document is not valid
/data/www/shared/bundled_gems/ruby/1.9.1/bundler/gems/active_shipping-2541a8f38a5c/lib/active_shipping/shipping/response.rb:34:in `initialize'
/data/www/shared/bundled_gems/ruby/1.9.1/bundler/gems/active_shipping-2541a8f38a5c
/lib/active_shipping/shipping/tracking_response.rb:13:in `initialize'
/data/www/shared/bundled_gems/ruby/1.9.1/bundler/gems/active_shipping-2541a8f38a5c/lib/active_shipping/shipping/carriers/ups.rb:596:in `new'
/data/www/shared/bundled_gems/ruby/1.9.1/bundler/gems/active_shipping-2541a8f38a5c/lib/active_shipping/shipping/carriers/ups.rb:596:in `parse_tracking_response'
/data/www/shared/bundled_gems/ruby/1.9.1/bundler/gems/active_shipping-2541a8f38a5c/lib/active_shipping/shipping/carriers/ups.rb:126:in `find_tracking_info'
/data/www/releases/20120602201208/lib/tasks/utility.rake:914:in `block (3 levels) in <top (required)>'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/activerecord-3.0.10/lib/active_record/relation/batches.rb:21:in `block (2 levels) in find_each'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/activerecord-3.0.10/lib/active_record/relation/batches.rb:21:in `each'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/activerecord-3.0.10/lib/active_record/relation/batches.rb:21:in `block in find_each'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/activerecord-3.0.10/lib/active_record/relation/batches.rb:69:in `find_in_batches'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/activerecord-3.0.10/lib/active_record/relation/batches.rb:20:in `find_each'
/data/www/releases/20120602201208/lib/tasks/utility.rake:904:in `block (2 levels) in <top (required)>'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/data/www/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/data/www/shared/bundled_gems/ruby/1.9.1/bin/rake:19:in `load'
/data/www/shared/bundled_gems/ruby/1.9.1/bin/rake:19:in `<main>'

canada_post_pws - You cannot mail on behalf of the requested customer

I have the correct customer number and valid keys according to Canada post i.e. Credit Management Group

ActiveMerchant::Shipping::ResponseError at /shipments/3
You cannot mail on behalf of the requested customer.

    cp = ActiveMerchant::Shipping::CanadaPostPWS.new(:api_key => 'xxxx', :secret => 'xxxx', :platform_id => 'xxxx', :contract_id => 'xxxx' )    #platform id = customer number

    responseCP = cp.find_rates(@origin, @destination, @package_AS)

According to Canada post dev forum:

"You cannot mail on behalf of the requested customer"

This means that the mailed-by and/or mobo customer numbers in your request are not correct. Are you doing contract shipping, or non-contract? If you are doing contract shipping, your contract must also be included in the request. Please check your customer number and mobo number in your request to ensure they are correct.

If you are still having issues, please call our Credit Management Group to ensure you have the correct customer number - 1-866-511-0546. They won’t be able to troubleshoot your issue, but they can validate you are using the correct account number.

If your account number is correct and you are still having issues, please post your xml for us to troubleshoot.

P.S. mobo means mailed on behalf of

UPS Labels

I have another project that has UPS Labels implemented, and I could extract it, but I'm just wondering:

  • Is someone working on it?
  • What's the demand for it? Who would use it if it was available?

ActiveMerchant::Shipping::ResponseError: Error - 0105: General Error

An entirely unhelpful error message is getting thrown about 2/3 of the time we run quotes against FedEx.

From an IRB session I run this code:

origin = Location.new :country => 'US', :state => 'CO', :city => 'xxx', :zip => 'xxx'
destination = Location.new :country => address.country.name, :city => address.city, :zip => address.postal_code
package = Package.new 200, [1,10,10]

response = fedex.find_rates(origin,destination,package)

About 1/3 of the time I get rates back, the rest of the time it throws this:

 ActiveMerchant::Shipping::ResponseError: ERROR - 0105: General Error
    from [...]/gems/active_shipping-0.9.13/lib/active_shipping/shipping/response.rb:34:in `initialize'
    from [...]/gems/active_shipping-0.9.13/lib/active_shipping/shipping/rate_response.rb:10:in `initialize'
    from [...]/gems/active_shipping-0.9.13/lib/active_shipping/shipping/carriers/fedex.rb:255:in `new'
    from [...]/gems/active_shipping-0.9.13/lib/active_shipping/shipping/carriers/fedex.rb:255:in `parse_rate_response'
    from [...]/gems/active_shipping-0.9.13/lib/active_shipping/shipping/carriers/fedex.rb:107:in `find_rates'

I'm not entirely impressed by the reliability here, but I can't seem to find any others having this issue. What am I doing wrong?

Not including insured value for UPS

ActiveShipping currently is ignoring the package monetary values/currency when calculating shipping charges for UPS. Updating the build_rate_request method to include PackageServiceOptions with DeclaredValue and InsuredValue will result in the returned rates including the insurance cost in the total (see code below)

module ActiveMerchant
  module Shipping
    class UPS < Carrier
      protected
      def build_rate_request(origin, destination, packages, options={})
        packages = Array(packages)
        xml_request = XmlNode.new('RatingServiceSelectionRequest') do |root_node|
          root_node << XmlNode.new('Request') do |request|
            request << XmlNode.new('RequestAction', 'Rate')
            request << XmlNode.new('RequestOption', 'Shop')
            # not implemented: 'Rate' RequestOption to specify a single service query
            # request << XmlNode.new('RequestOption', ((options[:service].nil? or options[:service] == :all) ? 'Shop' : 'Rate'))
          end

          pickup_type = options[:pickup_type] || :daily_pickup

          root_node << XmlNode.new('PickupType') do |pickup_type_node|
            pickup_type_node << XmlNode.new('Code', PICKUP_CODES[pickup_type])
            # not implemented: PickupType/PickupDetails element
          end
          cc = options[:customer_classification] || DEFAULT_CUSTOMER_CLASSIFICATIONS[pickup_type]
          root_node << XmlNode.new('CustomerClassification') do |cc_node|
            cc_node << XmlNode.new('Code', CUSTOMER_CLASSIFICATIONS[cc])
          end

          root_node << XmlNode.new('Shipment') do |shipment|
            # not implemented: Shipment/Description element
            shipment << build_location_node('Shipper', (options[:shipper] || origin), options)
            shipment << build_location_node('ShipTo', destination, options)
            if options[:shipper] and options[:shipper] != origin
              shipment << build_location_node('ShipFrom', origin, options)
            end

            # not implemented:  * Shipment/ShipmentWeight element
            #                   * Shipment/ReferenceNumber element                    
            #                   * Shipment/Service element                            
            #                   * Shipment/PickupDate element                         
            #                   * Shipment/ScheduledDeliveryDate element              
            #                   * Shipment/ScheduledDeliveryTime element              
            #                   * Shipment/AlternateDeliveryTime element              
            #                   * Shipment/DocumentsOnly element                      

            packages.each do |package|
              imperial = ['US','LR','MM'].include?(origin.country_code(:alpha2))

              shipment << XmlNode.new("Package") do |package_node|

                # not implemented:  * Shipment/Package/PackagingType element
                #                   * Shipment/Package/Description element

                package_node << XmlNode.new("PackagingType") do |packaging_type|
                  packaging_type << XmlNode.new("Code", '02')
                end

                package_node << XmlNode.new("Dimensions") do |dimensions|
                  dimensions << XmlNode.new("UnitOfMeasurement") do |units|
                    units << XmlNode.new("Code", imperial ? 'IN' : 'CM')
                  end
                  [:length,:width,:height].each do |axis|
                    value = ((imperial ? package.inches(axis) : package.cm(axis)).to_f*1000).round/1000.0 # 3 decimals
                    dimensions << XmlNode.new(axis.to_s.capitalize, [value,0.1].max)
                  end
                end

                package_node << XmlNode.new("PackageWeight") do |package_weight|
                  package_weight << XmlNode.new("UnitOfMeasurement") do |units|
                    units << XmlNode.new("Code", imperial ? 'LBS' : 'KGS')
                  end

                  value = ((imperial ? package.lbs : package.kgs).to_f*1000).round/1000.0 # 3 decimals
                  package_weight << XmlNode.new("Weight", [value,0.1].max)
                end

                package_node << XmlNode.new("PackageServiceOptions") do |package_service_options|
                  package_service_options << XmlNode.new("DeclaredValue") do |declared_value|
                    declared_value << XmlNode.new("CurrencyCode", package.currency)
                    declared_value << XmlNode.new("MonetaryValue", (package.value.to_i/100)) 
                  end
                  package_service_options << XmlNode.new("InsuredValue") do |declared_value|
                    declared_value << XmlNode.new("CurrencyCode", package.currency)
                    declared_value << XmlNode.new("MonetaryValue", (package.value.to_i/100)) 
                  end
                end
                # not implemented:  * Shipment/Package/LargePackageIndicator element
                #                   * Shipment/Package/ReferenceNumber element
                #                   * Shipment/Package/PackageServiceOptions element
                #                   * Shipment/Package/AdditionalHandling element  
              end

            end

            # not implemented:  * Shipment/ShipmentServiceOptions element
            #                   * Shipment/RateInformation element

          end

        end
        xml_request.to_s
      end
    end
  end
end

UPS returns "Missing/Illegal Package/PackageWeight/Weight" only within app.

International UPS shipments stopped working suddenly for me and I get this error response:

ActiveMerchant::Shipping::ResponseError: Missing/Illegal Package/PackageWeight/Weight

The strange things is, I created a self-contained test case and it works properly, even in the console of my rails app. When the exact same test case is run in the context of my running app (using binding.pry to do that) it shows the error.

This is the test case I'm running. Any idea why this error would be raised only in my running app? Or any other tips on how I might debug such an issue?

require 'active_shipping'
include ActiveMerchant::Shipping

package = Package.new(9.28, [], :units => :imperial)
origin = Location.new({:country => 'US', :state => 'CA', :city => 'Santa Cruz', :zip => '95060'})
destination = Location.new({:country => 'BR', :state => '', :city => 'brasilia', :zip => 'abc123'})
ups = UPS.new(:login => 'xxxx', :password => 'xxxx', :key => 'xxxx')
rates = ups.find_rates(origin, destination, [package]).rates
p rates

UPS Price incorect

Return wrong price from API Server

UPS Online Calculator return 9.75
API Return 9.71

@packages = [ Package.new( 2, [10,10,10], :units => :imperial ) ]

  @origin = Location.new(  :country => 'US',
                        :state => 'DC',
                        :city => 'WASHINGTON',
                        :zip => '20015',
                        :address_type => 'residential')

  @destination = Location.new( :country => 'US',
                        :state => 'NY',
                        :city => 'BROOKLYN',
                        :zip => '11201',
                        :address_type => 'residential')

Drop 1.8 support

It's getting to that time when we should move forward.

Within the next few weeks we are going to drop all support for 1.8.7.

Though, on the plus side, we'll be adding support for 2.0! Primarily being adding 2.0 to travis.yml and seeing what breaks :P

Generating labels and creating shipments

Currently, i don't think we can generate labels or create shipments with a carrier using active_shipping gem. It would be good if we had these provisions too.

Generating Shipping Labels from Packages

I'm looking into implementing the ability to generate shipping labels for some carriers, and I was wondering if this is something Active Shipping would accept a pull request for (or already has and I simply missed it in the code).

Please let me know, thanks!

Rexml parse error illegal character '&' in raw string... from usps rate

I suddenly started getting this error on my site, seems to originate from where I retrieve rates from USPS.

RuntimeError: Illegal character '&' in raw string [long URL string here that has an ampersand in it]

/usr/local/lib/ruby/1.9.1/rexml/text.rb:154:in `block in check'
/usr/local/lib/ruby/1.9.1/rexml/text.rb:152:in `scan'
/usr/local/lib/ruby/1.9.1/rexml/text.rb:152:in `check'
/usr/local/lib/ruby/1.9.1/rexml/attribute.rb:153:in `element='
/usr/local/lib/ruby/1.9.1/rexml/element.rb:1104:in `[]='
/usr/local/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:35:in `block in parse'
/usr/local/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:34:in `each'
/usr/local/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:34:in `parse'
/usr/local/lib/ruby/1.9.1/rexml/document.rb:230:in `build'
/usr/local/lib/ruby/1.9.1/rexml/document.rb:43:in `initialize'
/app/vendor/bundle/ruby/1.9.1/bundler/gems/active_shipping-4cb4dd8db8e9/lib/active_shipping/shipping/carriers/usps.rb:278:in `new'
/app/vendor/bundle/ruby/1.9.1/bundler/gems/active_shipping-4cb4dd8db8e9/lib/active_shipping/shipping/carriers/usps.rb:278:in `parse_rate_response'
/app/vendor/bundle/ruby/1.9.1/bundler/gems/active_shipping-4cb4dd8db8e9/lib/active_shipping/shipping/carriers/usps.rb:176:in `us_rates'
/app/vendor/bundle/ruby/1.9.1/bundler/gems/active_shipping-4cb4dd8db8e9/lib/active_shipping/shipping/carriers/usps.rb:156:in `find_rates'
/app/lib/order_extras/shipping_methods.rb:161:in `usps_shipping_rates'
/app/lib/order_extras/shipping_methods.rb:116:in `cache_shipping_rate_list'
/app/lib/order_extras/shipping_methods.rb:69:in `available_shipping_rates'
/app/lib/order_extras/shipping_methods.rb:77:in `available_shipping_rates_for_select'
/app/app/views/checkouts/_shipping_rate_list.html.erb:1:in `_app_views_checkouts__shipping_rate_list_html_erb___2165393928026064843_10174040'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/template.rb:145:in `block in render'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:125:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/template.rb:143:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/partial_renderer.rb:237:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:41:in `render_partial'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:15:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/rendering_helper.rb:24:in `render'
/app/app/views/checkouts/_address_form.erb:43:in `_app_views_checkouts__address_form_erb___634939038148726116_31203620'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/template.rb:145:in `block in render'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:125:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/template.rb:143:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/partial_renderer.rb:237:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:41:in `render_partial'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:15:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/rendering_helper.rb:24:in `render'
/app/app/views/checkouts/new.html.erb:96:in `block (2 levels) in _app_views_checkouts_new_html_erb__1426887589779718808_45083720'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/capture_helper.rb:40:in `capture'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/form_helper.rb:605:in `fields_for'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/form_helper.rb:1467:in `fields_for_nested_model'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/form_helper.rb:1457:in `fields_for_with_nested_attributes'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/form_helper.rb:1302:in `fields_for'
/app/app/views/checkouts/new.html.erb:89:in `block in _app_views_checkouts_new_html_erb__1426887589779718808_45083720'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/capture_helper.rb:40:in `capture'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/helpers/form_helper.rb:378:in `form_for'
/app/app/views/checkouts/new.html.erb:59:in `_app_views_checkouts_new_html_erb__1426887589779718808_45083720'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/template.rb:145:in `block in render'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:125:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/template.rb:143:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/template_renderer.rb:18:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:36:in `render_template'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_view/renderer/renderer.rb:17:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:110:in `_render_template'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/streaming.rb:225:in `_render_template'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:103:in `render_to_body'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:88:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rendering.rb:16:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/usr/local/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:39:in `render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:167:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rendering.rb:10:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:447:in `_run__4318878279597665851__process_action__4113955223391491211__callbacks'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal.rb:203:in `dispatch'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal.rb:246:in `block in action'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/app/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/exception_notification-3.0.1/lib/exception_notifier.rb:41:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__3290974283035621157__call__1002847409987708811__callbacks'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
/app/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:479:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:223:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in `catch'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:54:in `process'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
/app/vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/app/vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/server.rb:159:in `start'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/controllers/controller.rb:86:in `start'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/runner.rb:187:in `run_command'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/runner.rb:152:in `run!'
/app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/bin/thin:6:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
/app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>' … Illegal character ‘&’ in raw string "http://production.shippingapis.com/?fp=[... removing this because im not sure if it is sensitive data or not its a long URL with an ampersand within it ...]


No "Commercial Base Rate" for USPS carrier

When getting rates as a Commercial Base Rate for USPS prices are slightly cheaper. However, this doesn't appear to be an option for the USPS carrier.

(it can vary by a whole dollar for medium flat rate boxes)

undefined method `sum' for #<ActiveMerchant::Shipping::Package:0x007fee1c4862c0>

When using the CanadaPostPWS class

@cp = ActiveMerchant::Shipping::CanadaPostPWS.new(:api_key => 'xxx', :secret => 'xxx')
@response = @cp.find_rates(origin, destination, package)

I am using the same data setup for the UPS class and the UPS works as expected

#<ActiveMerchant::Shipping::Package:0x007fee1c4862c0 @options={}, @dimensions=[#<Quantified::Length: 10.0 centimetres>, #<Quantified::Length: 10.0 centimetres>, #<Quantified::Length: 10.0 centimetres>], @weight_unit_system=:metric, @dimensions_unit_system=:metric, @weight=#<Quantified::Mass: 4.0 grams>, @value=nil, @currency=nil, @cylinder=false, @gift=false, @oversized=false, @unpackaged=false, @inches=[3.9370078740157477, 3.9370078740157477, 3.9370078740157477]>

UPS country issue

I am looking up UPS shipping rates with Locations such as these:

Location.new(:zip => "90210", :country => 'US', :state => 'CA', :city => 'Beverly Hils')

I keep getting an error from Location.rb line 81 in the country_code method saying:

NoMethodError: undefined methodvalue' for #Array:0x1071ca428`

If I replace that method to always return 'US' it works. I am using ruby 1.8.7 and rails 2.3.12 on Mac Lion.

Thanks!

Getting must be expressed in pounds units error from Fed Ex

I am getting this error when submitting the request

packages = [

Package.new( (7.5 * 16), # 7.5 lbs, times 16 oz/lb.
[15, 10, 4.5], # 15x10x4.5 inches
:units => :imperial) # not grams, not centimetres
]

[#<ActiveMerchant::Shipping::Package:0x007fb2fce1b638 @options={:units=>:imperial}, @Dimensions=[#<Quantified::Length: 4.5 inches>, #<Quantified::Length: 10 inches>, #<Quantified::Length: 15 inches>], @unit_system=:imperial, @weight=#<Quantified::Mass: 120.0 ounces>, @value=nil, @Currency=nil, @Cylinder=false, @gift=false>]
<------------
false
ERROR - 6641: Weight for requested package 1 must be expressed in pound units (LB) for Domestic Express Shipments

FedEx Address Validation

active_shipping doesn't appear to currently do FedEx address validation. We are currently using active_shipping in our project and have a need to identify the residential status of addresses before shipping. I'm planning on implementing this functionality myself. So if anyone has any comments on this it would be appreciated. Thanks.

UPS tracking details doesn't handle brand new packages?

We have a shipment where UPS is returning this:

<?xml version="1.0"?>
<TrackResponse><Response><ResponseStatusCode>1</ResponseStatusCode><ResponseStatusDescription>Success</ResponseStatusDescription></Response><Shipment><Shipper/><ShipmentWeight><UnitOfMeasurement><Code>LBS</Code></UnitOfMeasurement><Weight>0.00</Weight></ShipmentWeight><Service><Code>03</Code><Description>UPS GROUND</Description></Service><ShipmentIdentificationNumber>1ZR08E820311157913</ShipmentIdentificationNumber><Package><TrackingNumber>1ZR08E820311157913</TrackingNumber><PackageWeight><UnitOfMeasurement><Code>LBS</Code></UnitOfMeasurement><Weight>0.00</Weight></PackageWeight></Package></Shipment></TrackResponse>

I suspect this is a brand new shipment where UPS doesn't have any detail in its database yet. It causes a undefined method 'get_text' for nil:NilClass error here:

https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/shipping/carriers/ups.rb#L341

Canada Post PWS (2) - parse_rates_response with a contract_id cause a REXML::ParseException

XML response from CP contains '& amp;' and doesn't work well with the REXML::Text::unnormalize(response).

Quick and dirty fix :
line : parse_rates_response(response, origin, destination)
replaced by: parse_rates_response(response.gsub('& amp;','-'), origin, destination)
( or doc = REXML::Document.new(REXML::Text::unnormalize(response.gsub('& amp;','-')))

NOTE : remove space between & and amp

USPS fails valid_credentials? for 2 new accounts.

I've signed up for USPS web tools api here: https://www.usps.com/business/web-tools-apis/welcome.htm for two separate accounts and neither one will return true when testing the credentials...

irb(main):029:0> u = ActiveMerchant::Shipping::USPS.new(:login => '862TINYL2647', :test => true)
=> #<ActiveMerchant::Shipping::USPS:0x007fe82cd28f68 @options={:login=>"862TINYL2647", :test=>true}, @last_request=nil, @test_mode=true>
irb(main):030:0> u.valid_credentials?
=> false
irb(main):041:0> u = ActiveMerchant::Shipping::USPS.new(login: '522VERMO8059', test:true)
=> #<ActiveMerchant::Shipping::USPS:0x007fe82cf3b288 @options={:login=>"522VERMO8059", :test=>true}, @last_request=nil, @test_mode=true>
irb(main):042:0> u.valid_credentials?
=> false

Not sure what I'm doing wrong. Have tried on both v.0.11.0 and from latest commit on master branch.

Any ideas how I can fix this? Is there anyway I can output or log the requests being sent & received?

Clarify FedEx Docs

On the readme, maybe specify that the options key :login should have the value Fedex calls 'meter number'

fdx = FedEx.new(:login => meter, :account => account, :password => password, :key => key)

FedEx rate estimates can use outdated currency code

Problem

For certain countries (so far only occurred for Singapore) FedEx returns a currency code that is no longer being used (e.g. by XE.com). This causes a currency conversion to fail on e.g. the Shopify side when trying to look up the conversion rate for "SID" currency (supposed to be "Solomon Island Dollar", but FedEx lists it as Singapore Dollars).

TODO

Work around the "mistake" on the FedEx part by overwriting SID with SGP currency code. Also double check if any other currency codes might not be correct, although I assume it's a one off here.

More information

FedEX currency code API docs

invalid usps service types

i have noticed some issues with using service types FIRST CLASS and BPM explicitly instead of :all

:first_class => Invalid First Class Mail Type.
:bpm => Service not available.

all other types work fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.