I'm trying to add a donation page with paypal integration. It works perfectly fine. But what I want to add is to first sign the form from my site and then send it to paypal as well as the selected amount of donation. I've also trid to put this code <input type="hidden" name="amount" value="<?php echo $total; ?>"> as per my research. But it's still not working. Please see my code below for your review/reference.
Code
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="QWEVB36VTJYEG">
<input type="hidden" name="amount" value="88.00">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_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_US/i/scr/pixel.gif" width="1" height="1">
</form>
The result would be just like this: (Blank Value) (The value must be 88.00)
As far as I know, donations on Paypal can't be restricted to one single value. The amount input is ignored, to be sure that people who will donate are not being manipulated and forced to pay a price they did not choose.
However, if you want to propose some fixed prices, here is a Paypal Community code which will help you doing that.
EDIT: Here is a StackOverflow answer which is pretty clear and confirms my thoughts.
Related
I am certainly interested in using PayPal's Standard payment buttons; however, I would like to be able to set the amount myself in code, instead of being forced to create a button with a fixed amount through Paypal. For example, I thought the following code would work:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="amount" value="5.00">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIH2wYJKoZIhvcNAQcEoIIHzDCCB8gCAQExggE6MIIBNgIBADCBnjCBmDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExETAPBgNVBAcTCFNhbiBKb3NlMRUwEwYDVQQKEwxQYXlQYWwsIEluYy4xFjAUBgNVBAsUDXNhbmRib3hfY2VydHMxFDASBgNVBAMUC3NhbmRib3hfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMA0GCSqGSIb3DQEBAQUABIGAH+DqNBRlDwSh687j3TxNmxEdl5Qz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YJKoZIhvcNAQkEMRYEFEZCu52pVGGuQnysWYPrliEa73/0MA0GCSqGSIb3DQEBAQUABIGAdbJUsYUTVyNZ/0/ivmpPr1xSzk9okSRA6lrmgSOWwZP7/sukM/mSZ9b/nvjStbspSK1HPgmDyeDmKy355dX83/42P04b/faGikPPaBHSvEsoL4MmMSj/Jqfzg1iV8tbynyf/VT9DlitZlho54CygGaT/ZcML6M/JRJlECWzsnc0=-----END PKCS7-----
">
<input type="image" src="https://www.sandbox.paypal.com/en_US/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.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
This does not work either:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="U7K937HLYPW6L">
<input type="hidden" name="amount" value="5.00">
<input type="image" src="https://www.sandbox.paypal.com/en_US/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.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Instead of directing the user to a page where they could make a payment of 5.00, the page instead allows users to input their own amount. In my real application, I would use PHP to calculate the total (at a cart style page) and associate that value with the 'amount' key, but I cannot even get it to work even with static values. What is the solution?
Thanks much!
You would need to utilise their API to produce dynamic pricing to break away from the "cart" type system provided by paypal. Essentially you would look to replace the paypal "cart" page with your own by coding using the API.
I am trying to add PayPal checkout to my website. The total amount for each payment varies and so I use PHP to generate the total sum. I am trying to POST the amount to a hosted button so that it is more secure, using the advanced variables option on the 3rd step when creating a button but I can't seem to get it to work.
Does anybody know if it is possible to actually do this or does it have to be done another way?
Code on the website:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="GMENQCFMYUE46">
<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.">
<input type="hidden" name="amount" value="<?php print("$total")?>"/>
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="item_name" value="<?php print("$origin - $destination Transfer $date")?>" />
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
The item_name works fine but I understand that the amount variable wont carry over in this way so I am trying to find a way to do this.
I've got my own shopping cart and everything set up, I just need a "Pay Now" button for my website users, and I just intend to send the entire cart's total amount up to payPal, that's it, no other integration necessary. So the customers on my website have already reviewed their order, checked quantities and shipping charges etc for individual items, and now PayPal just needs to be given the total amount which they will confirm and pay.
My code for the "Pay Now" button is below ($overall_total has already been calculated somewhere above in my php code):
<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="JRECLRTYAJDKY">
<input type="hidden" name="amount" value="<?php echo $overall_total;?>">
<input type="hidden" name="item_total" value="<?php echo $overall_total;?>">
<input type="hidden" name="item_name" value="Your Shopping order">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
The user submits this form when they hit "Pay Now", and they come to next page. But Even though I included the amount and item_total variables, the next page gives me an item_total of 0.00. Also, I don't want any Quantity or Item price to show since I am simply implementing an aggregate cart payment for customers, and they have already reviewed per item charges before coming to the payment. This is what I get:
How can I get rid of Quantity and Item price, and have the $overall_total value that I calculated inside the total price on the PayPal summary?
there is no item_total or any total, since every single button handles ONE item at once
$overall_total must be in the english format with "." as decimals separator
problem may be the cmd parameter.. use instead:
<input type="hidden" name="cmd" value="_xclick">
also you need to specify:
<input type="hidden" name="business" value="yourBusiness#yourBusiness.tld">
look at this for a more complete example:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="yourBusiness#yourBusiness.tld">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="amount" value="10.10">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Item bought desc">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_paynow_SM.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
also have a look at:
the documentation of cart parameters: HTML Form Basics for PayPal Payments Standard
the cart button builder: Create a PayPal payment button
about the "quantity" issue, sadly you can't hide it... if this is an important issue for you, you could try instead the ExpressCheckout (using php) which is very customizable and not that difficult to implement
hoping to be helpful
The most straightforward way to get around the Qty:1 issue of simple 'Pay Now' buttons is to implement 'Cart Upload' instead, which is how 99% of shopping carts implement Standard. See: PayPal's Cart Upload Documentation
If you are a programmer who can handle API calls, I instead recommend using Express Checkout (perhaps with SOLUTIONTYPE=Sole) rather than a Standard form post like Cart Upload. EC is a more robust interface to program against and essentially a free upgrade to Standard that's available to all PayPal seller accounts.
I need to paste this code at admin panel and then display Paypal Button on website.
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="6UKjJ8hU6ML5f">
<input type="hidden" name="custom" value="<?php print($_SESSION['mid'].'-'.$_SESSION['mps']);?>">
<input type="image" src="https://www.sandbox.paypal.com/en_US/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.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Then, need to display this code on website using following code.
print $rs->fields("ppbutton");
Now, problem is that due to PHP code inside Paypal form, whenever I try to print above value (paypal button) on website, it's giving error because of PHP code inside another PHP code.
I also think, print htmlentities($rs->fields("ppbutton"));
is the best option for you.
You can get the most recent updates about the function from this site.
http://php.net/manual/en/function.htmlentities.php
print htmlentities($rs->fields("ppbutton"));
I have a form that a user fills out prior to reaching the PayPal Buy Now button. The form contains information such as the users name and the amount they will be paying (in a hidden field).
I know there probably is a way to pass the name variable to PayPal using the Advanced Variables feature, but is there a way to alter the buttons price?
And can I do this using PHP variables?
Eg: item_name=<?php $myitem ?>
Any advice would be great! Thanks
EDIT: Form as requested
<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="XXXX">
<input type="image" src="https://www.paypalobjects.com/en_AU/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_AU/i/scr/pixel.gif" width="1" height="1">
</form>
If I understand correctly your question, you have to put the amount hidden field on paypal form.
e.g.
<input type="hidden" name="amount" value="100">
<input type="hidden" name="currency_code" value="USD">
This form will prompt paypal to ask $100 from buyer.
of course you can add your own var there e.g.
<input type="hidden" name="amount" value="<?php echo $amount;?>">
HTH
I cannot even get this working with an unhosted button. It seems Paypal never lets you change the amount. I see it like this :
hosted button : amount is set in the code pointed to by the 'hosted button id'
unhosted button : PayPal encrypts the information, of which amount is part of
so, in either case you cannot change it, or at least, I haven't been able to do this.
Having said that, there is a variable called 'amount' you can use. So, I'm very confused about this.