0
votes

I am building a site with a simple paypal payment form

I want the paypal form to take the $total_price of my cart items from my cart page. Here is my code so far:

notice I have changed _xclick in the standard code to _cart..

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="amount" value="<?php echo $total_price; ?>">

<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>

However, when I click on buy now, paypal loads up but instead of displaying a price it asks the user to input price per item! I want it to be taking the total price from my cart page. My cart is a PHP cookies cart.

I read it may be something to do with non-hosted buttons, that may prevent my echo $total_price not to work.

Note: I have changed the button do a non-hosted paypal button but now it says Notice: Undefined variable: total_price in... so is still not working, infact now I have this warning I didn't have before.

Thanks for any help!

1

1 Answers

0
votes

I had the same issue. In my case there was a "$" on the value in the amount input. Removing it and only sending the numeric value fixed it.