shopify / active_shipping Goto Github PK
View Code? Open in Web Editor NEWActiveShipping is a simple shipping abstraction library extracted from Shopify
Home Page: http://shopify.github.io/active_shipping
License: MIT License
ActiveShipping is a simple shipping abstraction library extracted from Shopify
Home Page: http://shopify.github.io/active_shipping
License: MIT License
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:
I have a form and i need to implement the usps api into it?
there is not clear example to use with a form?
I installed the gem, but i couldn't find any related file to it into my app.
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
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!
I have this:
require 'active_shipping'
include ActiveMerchant::Shipping
var = MyModel.find_by_name('name')
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>'
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 "
I have another project that has UPS Labels implemented, and I could extract it, but I'm just wondering:
Feature request
Can we get FedEx SmartPost added as an option?
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 method
value' 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!
block in sanitize_zipactive_shipping (0.10.0) lib/active_shipping/shipping/carriers/canada_post_pws.rb
742 def sanitize_zip(hash)
743 [:postal_code, :zip].each do |attr|
744 hash[attr].gsub!(/\s+/,'') if hash[attr]
745 end
746 hash
747 end
attr :postal_code
hash Seattle, WA, 98109 United States
88 responseCP = @cp.find_rates(origin, destination, packages)
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
The USPS size_code_for method checks if the length+girth of the package is less than 84" and if it is, returns 'REGULAR'. This is incorrect since a regular package must be under 84" AND have a volume of less than one square foot. See http://postcalc.usps.gov/PopUps/pop_up15.htm
To fix, change:
if total <= 84
to
if total <= 84 && package.inches(:volume) < 1728
I just received an email from USPS about some changes to their API. Is this expected to affect ActiveShipping?
destination_node can be nil sometimes, we should handle this nicer.
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.
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).
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
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.
Something like the text in the previous suggestion would work.
Thanks for the sweet library!
cc: @jdugan
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
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]>
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.
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)
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?
This happens when the array of items passed in is empty.
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)
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
I am getting uninitialized constant CanadaPostPWS when calling:
@cp = CanadaPostPWS.new(login)
All other carriers work no problem.
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?
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
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>
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 }
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
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).
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.
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.
USPS sent out a notice that they are deprecating the RateV3 and IntlRate API in May 2011.
Need to update the USPS API to use RateV4 and IntlRateV2
http://www.usps.com/webtools/htm/Rate-Calculators-v1-2a.htm
http://www.usps.com/webtools/_pdf/Rate-Calculators-v1-2a.pdf
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?
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?
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
I've forked and made it into a rubygem. It builds on github:
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')
Package size no longer accepts OVERSIZE
Under : "RateV4Request / Package / Size" and "IntlRateV2Request / Package / Size"
REGULAR: Package dimensions are 12" or less
LARGE: Package dimension is larger than 12"
http://www.usps.com/webtools/htm/Rate-Calculators-v1-2a.htm
http://www.usps.com/webtools/_pdf/Rate-Calculators-v1-2a.pdf
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.
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.
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?
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 ...]
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
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:in
date_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:in
block 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?
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?
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.