You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 13, 2018. It is now read-only.
def self.cents_from(money)
return nil if money.nil?
if money.respond_to?(:cents)
return money.cents
else
case money
when Float
(money * 100).round
when String
money =~ /\./ ? (money.to_f * 100).round : money.to_i
else
money.to_i
end
end
end
When querying the Stamps.com API for rates, it returns amount values that look like 10.50 representing $10.50, for example. However, when the value is an amount of whole dollars, it looks like 10 representing $10, for example. This causes the cents_from method above to assume that the 10 is a value in cents since it doesn't contain a ..
We discovered this when a customer was charged $0.57 for a shipment from California to Finland! Whoops!
Perhaps the best way would be to have the Stamps Carrier class return this value as an instance of a class that implements a cents method. What would be best practice here?
Thanks
The text was updated successfully, but these errors were encountered:
Before I make a PR, I'd like advice on the best approach to fixing this issue.
The code in question is https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/package.rb#L117-L131
When querying the Stamps.com API for rates, it returns amount values that look like
10.50
representing $10.50, for example. However, when the value is an amount of whole dollars, it looks like10
representing $10, for example. This causes thecents_from
method above to assume that the10
is a value in cents since it doesn't contain a.
.We discovered this when a customer was charged $0.57 for a shipment from California to Finland! Whoops!
Perhaps the best way would be to have the
Stamps
Carrier class return this value as an instance of a class that implements acents
method. What would be best practice here?Thanks
The text was updated successfully, but these errors were encountered: