Reputation: 2763
I am trying to send the total amount to be paid by the customer with <input type="hidden" name="amount" value="{$total}">
where {$total}
holds the total amount(smarty) but when I click buy now button of paypal,it shows amount to be paid as 0.00 . Whats wrong ?My code is :
Total :
{$total}
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="SVXVEBF9CH4YU">
<input type="hidden" name="amount" value="{$total}">
<input type="image" src="https://www.paypalobjects.com/en_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>
I am testing it in localhost
,is this creating that problem ?
Upvotes: 0
Views: 6150
Reputation: 365
Just try this code
<input name=AMT value="{$total}">
Corrected,
<input type="hidden" name="amount" value={$total}>
Upvotes: -1
Reputation: 19356
The reason you can't override the amount dynamically, is because you have a so-called 'PayPal hosted button'.
With a hosted button, the amount is stored on PayPal's side and can't be overwritten with the 'amount' variable.
You'll either want to use a non-hosted button (as Peter Szymkowski is using in his answer), or use the BMUpdateButton API call to dynamically update the button's amount.
An example request for BMUpdateButton would look as follows:
USER=Your API username
PWD=Your API password
SIGNATURE=Your API signature
VERSION=82.0
HOSTEDUBTTONID=The value of <input type="hidden" name="hosted_button_id" value="">
BUTTONTYPE=The type of button. E.g. BUYNOW
BUTTONCODE=The type of code you want to get back. E.g. HOSTED
L_BUTTONVAR0=amount=The new amount with a period as separator
L_BUTTONVAR1=item_name=Optional: a new item name if you wish
Similary, you could also use the BMCreateButton API to create a new button, or use the BMButtonSearch API to search through a list of all your stored hosted buttons (to find the hosted_button_id of your button automatically, for example)
The reason to use a hosted button is because it's more secure. A non-hosted, unencrypted button would basically leave the amounts open to manipulation. Fraudulent transactions waiting to happen.
Upvotes: 3
Reputation: 16943
paypal amount key is amount_1
, not amount
so...
<input type="hidden" name="amount_1" value="{$total}">
Edit:
This works perfect for me.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="platnosci">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="notify_url" value="http://www.google.pl/paypal.php">
<input type="hidden" name="item_name_1" value="Item description">
<input type="hidden" name="amount_1" value="34.00">
<input type="hidden" name="currency_code" value="PLN">
<input type="hidden" name="shopping_url" value="http://www.arest.pl">
<input type="hidden" name="email" value="tester">
<input type="submit">
</form>
Make sure your {$total} is not blank
Upvotes: 0