UPS quotes via shipping gem

greetings,

has anyone had luck with the UPS portion of the shipping gem?

i get nil’s returned for price, wondering what i’m missing. to avoid all
confusion i included the account/login in the instantiation (sub with
real values).

@ups = Shipping::UPS.new :ups_account => ‘7B4F74E3075AEEFF’, :ups_user
=> ‘username’, :ups_password => ‘password’, :zip => 92064, :sender_zip
=> 19122, :weight => 2

the fake UPS account number looks nuts, mine is only 6 character long.

any insight would be much appreciated. thanks.

minimal wrote:

greetings,

has anyone had luck with the UPS portion of the shipping gem?

i get nil’s returned for price, wondering what i’m missing. to avoid all
confusion i included the account/login in the instantiation (sub with
real values).

@ups = Shipping::UPS.new :ups_account => ‘7B4F74E3075AEEFF’, :ups_user
=> ‘username’, :ups_password => ‘password’, :zip => 92064, :sender_zip
=> 19122, :weight => 2

the fake UPS account number looks nuts, mine is only 6 character long.

any insight would be much appreciated. thanks.

Hello,

I had this exact problem and found the solution somewhere on Google. I
know how much this pissed me off so I want to help others.

OK first off make your life easier and create a file
/config/shipping.yml and add your ups account information as shown
below.

ups_license_number: ups_xml_access_key
ups_user: ups_username
ups_password: ups_password

One important thing to notice is that I am using ups_license_number: as
opposed to ups_account: as shown in the Shipping gem docs :frowning: . This is
what is causing all the trouble. Also note that I am using the xml
access key and not the account number.

Next you need a method to get your quote. Here is a quick one to get you
started.

#in your controller
def ups_quote(to_zip, sender_zip, weight)
#define the parameters for the quote
params ={
:zip => to_zip,
:sender_zip => sender_zip,
:weight => weight,
:prefs => “#{RAILS_ROOT}/config/shipping.yml”
}
#build the shipping gem object
@shipping = Shipping::UPS.new params
end

#in your view

Shipping Quote: <%= number_to_currency @shipping.price %>

That should solve your problem. I wish I could remember who was the
author of that forum response so I could give credit where it is due.
Also keep in mind that UPS tends to go offline from time to time and
without a failsafe method in place of ups_quote your application will
break and output an error. You will need to add error trapping to the
above method.

Best regards,

Tim M.