smallc28 Posted November 25, 2012 Share Posted November 25, 2012 Tally The Total Error When I tally the total with an quantity of 2 my php calculate turn short up in php...But when I press the checkout button to paypal everything adds up correctly..... Shipment Trouble When I can add 2 or more items to my cart and checkout with paypal my shipment increase to another 10.00 dollars How would I fix that to remain 10.00? Tax calculate error the more items I add to my database my shipment changes from 0.08% to 0.02% How Would I fix these errors without any bugs ? $shipTotal="10.00"; $taxRate ="0.08"; $pricetotal = $price * $each_item['quantity']; $getTax = $price * $taxRate; $cartTotal = $pricetotal + $getTax + $shipTotal + $cartTotal ; setlocale(LC_MONETARY, "en_US"); $pricetotal = money_format("%10.2n", $pricetotal); // Dynamic Checkout Btn Assembly $x = $i + 1; $pp_checkout_btn .= '<input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '"> <input type="hidden" name="amount_' . $x . '" value="' . $price . '"> <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '"> <input type="hidden" name="shipping_'. $x . '"value="'. $shipTotal .'"> <input type="hidden" name="tax_'. $x . '"value="'. $taxRate * $price .'"> '; // Create the product array variable $product_id_array .= "$item_id-".$each_item['quantity'].","; Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/ Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2012 Share Posted November 25, 2012 Please tell me you aren't using hidden form fields to handle pricing information. Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/#findComment-1394989 Share on other sites More sharing options...
smallc28 Posted November 25, 2012 Author Share Posted November 25, 2012 Please tell me you aren't using hidden form fields to handle pricing information. Not anymore Using floats Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/#findComment-1394990 Share on other sites More sharing options...
smallc28 Posted November 25, 2012 Author Share Posted November 25, 2012 for the hidden form field that's for paypal Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/#findComment-1394991 Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2012 Share Posted November 25, 2012 If that form is presented to the user and then submitted directly to PayPal, you're going to end up giving away a lot of free stuff. It's absolutely trivial for an end user to alter any of those values to anything they want. It will never be in your favor either, I guarantee that. Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/#findComment-1394992 Share on other sites More sharing options...
smallc28 Posted November 25, 2012 Author Share Posted November 25, 2012 then which method would you suggest I use ? Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/#findComment-1394993 Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2012 Share Posted November 25, 2012 Ideally, store it in the $_SESSION superglobal array, and write the items/quantities to a database when a customer confirms the order, along with the amounts they actually are being charged. Then send it to paypal directly. I'm not familiar with the specific methods PayPal allows, but to allow the end user to have any access to the manipulate price of something is suicide and can never be allowed. Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/#findComment-1394994 Share on other sites More sharing options...
smallc28 Posted November 25, 2012 Author Share Posted November 25, 2012 yes I've made a session for that in MySQL incase anyone expert programmers try to alter prices / price jacking....You wouldn't happen to know how to create encrypted buttons would you ? Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/#findComment-1394996 Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2012 Share Posted November 25, 2012 I'm not completely sure what you're asking . . . Quote Link to comment https://forums.phpfreaks.com/topic/271153-php-tally-the-total-nasty-bug/#findComment-1394997 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.