{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/omnipay-common/issues/69","labels_url":"https://api.github.com/repos/thephpleague/omnipay-common/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/omnipay-common/issues/69/comments","events_url":"https://api.github.com/repos/thephpleague/omnipay-common/issues/69/events","html_url":"https://github.com/thephpleague/omnipay-common/issues/69","id":122656332,"number":69,"title":"String > Float > String amount conversion breaks decimal place check","user":{"login":"TedAvery","id":608185,"avatar_url":"https://avatars.githubusercontent.com/u/608185?v=3","gravatar_id":"","url":"https://api.github.com/users/TedAvery","html_url":"https://github.com/TedAvery","followers_url":"https://api.github.com/users/TedAvery/followers","following_url":"https://api.github.com/users/TedAvery/following{/other_user}","gists_url":"https://api.github.com/users/TedAvery/gists{/gist_id}","starred_url":"https://api.github.com/users/TedAvery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TedAvery/subscriptions","organizations_url":"https://api.github.com/users/TedAvery/orgs","repos_url":"https://api.github.com/users/TedAvery/repos","events_url":"https://api.github.com/users/TedAvery/events{/privacy}","received_events_url":"https://api.github.com/users/TedAvery/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-17T03:56:22Z","updated_at":"2015-12-17T10:40:24Z","closed_at":null,"body":"I have an amount of $79.10 that I am trying to charge via [omnipay-stripe](https://github.com/thephpleague/omnipay-stripe).\r\n\r\nThere are a number of actions in [AbstractRequest.php](https://github.com/thephpleague/omnipay-common/blob/5fa50e04275d354bceb0870c0bf1cb6421b3a6f7/src/Omnipay/Common/Message/AbstractRequest.php#L325) starting at line 325 that cause this amount to fail.\r\n\r\nIf I pass the string `'79.10'` as an amount when creating the charge, line 325 converts it to float, which causes it to become a float of `79.09999999999999`. But then at line 338, it takes that amount that was converted to float and puts it back to string (`'79.09999999999999'`) which then fails the decimal place check, throwing the exception `'Amount precision is too high for currency.'`\r\n\r\nSo as it stands, $79.10 is an impossible amount to charge with this library."},"comment":{"url":"https://api.github.com/repos/thephpleague/omnipay-common/issues/comments/165416255","html_url":"https://github.com/thephpleague/omnipay-common/issues/69#issuecomment-165416255","issue_url":"https://api.github.com/repos/thephpleague/omnipay-common/issues/69","id":165416255,"user":{"login":"judgej","id":395934,"avatar_url":"https://avatars.githubusercontent.com/u/395934?v=3","gravatar_id":"","url":"https://api.github.com/users/judgej","html_url":"https://github.com/judgej","followers_url":"https://api.github.com/users/judgej/followers","following_url":"https://api.github.com/users/judgej/following{/other_user}","gists_url":"https://api.github.com/users/judgej/gists{/gist_id}","starred_url":"https://api.github.com/users/judgej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/judgej/subscriptions","organizations_url":"https://api.github.com/users/judgej/orgs","repos_url":"https://api.github.com/users/judgej/repos","events_url":"https://api.github.com/users/judgej/events{/privacy}","received_events_url":"https://api.github.com/users/judgej/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T10:40:24Z","updated_at":"2015-12-17T10:40:24Z","body":"That same value is dealt with here:\r\n\r\nhttp://stackoverflow.com/questions/34325753/convert-string-to-float-without-losing-precision\r\n\r\nThe solution here is going to be about how the float gets rounded in the conversion back to a string.\r\n\r\nFloats are a really bad way to store and perform arithmetic on currency values. However, in OmniPay there is no arithmetic, and it does not get stored, so we should be able to cope with this inaccuracy as it should not (in theory) be accumulative."}}