Permalink
Browse files

USPS: ignore package value instead of raising error if it's not USD

  • Loading branch information...
1 parent 3b6035b commit dcca0c612c79c5dcfe535d9f2f05951ec287c398 @jamesmacaulay jamesmacaulay committed Apr 21, 2011
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/active_shipping/shipping/carriers/usps.rb
View
10 lib/active_shipping/shipping/carriers/usps.rb
@@ -248,14 +248,16 @@ def build_world_rate_request(packages, destination)
package << XmlNode.new('Pounds', 0)
package << XmlNode.new('Ounces', [p.ounces,1].max.ceil) #takes an integer for some reason, must be rounded UP
package << XmlNode.new('MailType', MAIL_TYPES[p.options[:mail_type]] || 'Package')
- if p.value && p.value > 0 && p.currency && p.currency != 'USD'
- raise ArgumentError, "USPS needs package values in USD"
- end
package << XmlNode.new('GXG') do |gxg|
gxg << XmlNode.new('POBoxFlag', destination.po_box? ? 'Y' : 'N')
gxg << XmlNode.new('GiftFlag', p.gift? ? 'Y' : 'N')
end
- package << XmlNode.new('ValueOfContents', (p.value || 0) / 100.0)
+ value = if p.value && p.value > 0 && p.currency && p.currency != 'USD'
+ 0.0
+ else
+ (p.value || 0) / 100.0
+ end
+ package << XmlNode.new('ValueOfContents', value)
package << XmlNode.new('Country') do |node|
node.cdata = country
end

0 comments on commit dcca0c6

Please sign in to comment.