ohno Posted February 8, 2016 Share Posted February 8, 2016 $subtotal = $row[0]; $delivery = $row[1]; $discount = $row[2]; $vatrate = $row[3]; $totalex = str_replace(",","",$subtotal) + str_replace(",","",$delivery); $vatamount = ($totalex - $discount) * ($vatrate/100); $vatamount = number_format($vatamount, 2, '.', ','); $total = $row[4]; $centinel_total = $total * 100; $centinel_delivery = $delivery * 100; $centinel_vatamount = $vatamount * 100; I've got a custom written cart system which for some reason is not passing the correct amounts to our 3D secure processor (Cardinel commerce). I'm not a programmer but looking at how it seems to work I think the issue is with this code. From the processor logs we are passing the tax value with a negative amount and the total is always £1 when the total is above £1000. It all works fine as it should if the total amount is LESS than £1000! Anyone got any ideas what's going on? I'm more than happy to pay someone to fix this!! Quote Link to comment Share on other sites More sharing options...
davidannis Posted February 8, 2016 Share Posted February 8, 2016 Looks to me like you carefully strip commas out of $totalex but then use $total without stripping out commas. Quote Link to comment Share on other sites More sharing options...
davidannis Posted February 8, 2016 Share Posted February 8, 2016 Try adding a line $total = str_replace(",","",$total); before the line $centinel_total = $total * 100; Quote Link to comment Share on other sites More sharing options...
ohno Posted February 8, 2016 Author Share Posted February 8, 2016 Hi David, I'm really glad you replied as you helped me out in the past! I lost your contact details as my hard drive failed and the backup I had failed too! I lost all my emails & contacts and baby photo's etc. Anyway, I'll give that a go, I think you are on the right lines as it seems weird why it would all work under £1000 but go completely wrong when £1000 or above. If that doesn't work would you be interested in looking into it for me? Obviously I'll pay you for your time Thanks, Dave Quote Link to comment Share on other sites More sharing options...
Barand Posted February 8, 2016 Share Posted February 8, 2016 Why are you storing numeric values formatted with commas in the first place. You should do the formatting only on final output. Also, to do this you must be storing them in character fields which wrong. Quote Link to comment Share on other sites More sharing options...
ohno Posted February 8, 2016 Author Share Posted February 8, 2016 You sir are a genius! It now passes the correct amount, will that line of code only affect the $centinel_total string? The tax amount isn't used by them but their logs show an incorrect amount there too, would I just add the same sort of thing above the $centinel_vatamont string? Quote Link to comment Share on other sites More sharing options...
ohno Posted February 8, 2016 Author Share Posted February 8, 2016 I don't know, I didn't write any of this code nor am I a programmer! I'm just trying to fix the mess I've been left with. Quote Link to comment Share on other sites More sharing options...
davidannis Posted February 9, 2016 Share Posted February 9, 2016 You sir are a genius! It now passes the correct amount, will that line of code only affect the $centinel_total string? The tax amount isn't used by them but their logs show an incorrect amount there too, would I just add the same sort of thing above the $centinel_vatamont string? Someplace in the code that is not shown it is inserting commas to separate thousands digits, I'm sure to make it easier for humans to read. I suspect it does it for the tax too but I can't tell without see the code in question. In any case, you'd need a very expensive cart to have taxes that high and a similar line to strip the commas would work. Barand is right - you should not store the values with the commas but we'd need to see all of the code to properly fix it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.