Last post Mar 25, 2011 09:31 AM by Merin
Oct 20, 2006 10:32 PM|dmitcha|LINK
Hi, all - I'm a newbie who just spent all day today trying to add a single PayPal button to my site (built in VWD2005X Ed). I am not using a starter kit and literally just wanted to add an encrypted Buy Now Button to my page. Here's what I tried, and here's
THE QUICKEST SOLUTION:
1) PayPal link (vs. a button) - This works great and quickly if you don't mind not having encryption:
<a href=" https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=YourPaymentEmailAtPayPal&item_name=YourItemName&item_number=YourItemNumber&amount=PriceNoDollarSign">
plus, you can add the real PayPal button image as the hyperlink image by referencing the PayPal button URL provided in the form code PayPal created for your button (<IMG src="https://www.paypal.com, etc.">. Voila - you have a button - just no encryption.
My thanks to Ahmad at PayPal Merchant Tech support (http://www.pdncommunity.com/pdn/board/message?board.id=basicpayments&message.id=2477&jump=true#M2477)
THE BEST SOLUTION (if your host security settings allow it):
2) PayPal Developer modules - I downloaded these and the Buy Now Button worked beautifully locally. But as soon as I uploaded it to my Go Daddy-hosted site, I got an error page: "That assembly does not allow partially trusted callers." If you don't get
that error page, go with these; they are easy and fantastic. You will need to download them, install them, add some code to your web.config (per instructions) open VWD and choose Website/Add Reference and check the new PayPal control listing, then go to Tools/Choose
Toolbox Items and check the new PayPal controls, which will then populate the bottom of your toolbox.
My thanks to PayPal for this comprehensive solution - I wish it had worked with my host!
Download PayPal's developer kits by logging in at www.paypal.com, then going to Merchant Services / PayPal Developer Network (near bottom of page) / SDKs and Toolkits (left menu). The Developers’ Toolkits are enough for simple buttons, but there
are Pro kits for payment on your site.
THE SIMPLEST SOLUTION.
3) For me, the perfect answer was IFRAMES. Someone casually referenced it in a listing here (thanks - can't find you again in the long list of PayPal pleas!), but there was no explanation of how to do it. So I went on a Google hunt!
For any other newbies in need of a very easy solution to your trusted PayPal button on a .NET 2.0 page, all you do is:
A) SAVE PAYPAL'S GENERATED BUTTON FORM AS AN INDEPENDENT HTML FILE IN YOUR VWD PROJECT. Name it, for example, paypalbutton.htm.
- In your PayPal Form code, add target=_top to make sure PayPal opens in the full browser window, not inside of the IFRAME. You also could set target=_blank if you want PayPal to open in a new window.
- Be sure to set the doc's body background color to transparent, just for aesthetics (CSS is best, body style='background-color: transparent' attribute works fine.)
B) REFERENCE YOUR NEW PAYPAL HTML FILE IN AN IFRAME ON YOUR ASPX PAGE. Wherever you want the button to appear on the page, place your IFRAME code, indicating source=paypalbutton.htm (be directory specific, of course). You can set the height pretty small to
fit the button, and set the width however long you need to be able to align the button left or right on your page.
- Be sure to set the IFRAME for allowtransparency=true for aesthetics
That's it! I found this through http://dotnetjunkies.com/WebLog/adambeal/archive/category/2695.aspx and fooled around with it until it was consistent in Netscape, IE and Firefox. Thanks, Adam.
Hope this saves someone else a full day of trial and error! Does anyone know of any security issues with this approach? dma
Oct 21, 2006 01:41 PM|dmitcha|LINK
You will need to download them, install them, add some code to your web.config (per instructions) open VWD and choose Website/Add Reference and check the new PayPal control listing, then go to Tools/Choose Toolbox Items and check the new PayPal
controls, which will then populate the bottom of your toolbox.
May 10, 2007 04:27 PM|arnoldizon|LINK
This is exactly what I am looking for. I downloaded the Paypal dll and add the Dll in my visual studio.
Can you show me a sample code behind in VB.
I appreciate your help.
Sep 10, 2007 11:19 PM|rfurdzik|LINK
I can not find this API, can you send me the exact link? they offer some paid service...
i have placed the form html code, but it does not work with Ajax... this is the code,which does not work with ajax:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="myemail">
<input type="hidden" name="item_name" value="Item name">
<input type="hidden" name="item_number" value="Item ID">
<input type="hidden" name="amount" value="12.00">
<input type="hidden" name="buyer_credit_promo_code" value="">
<input type="hidden" name="buyer_credit_product_category" value="">
<input type="hidden" name="buyer_credit_shipping_method" value="">
<input type="hidden" name="buyer_credit_user_address_change" value="">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
Apr 15, 2008 09:55 PM|jwize|LINK
var inner = document.getElementById('innerDiv');
var outer = document.getElementById('outerDiv');
var innerHtml = inner.innerHTML;
inner.innerHTML = "";
outer.innerHTML = innerHTML;
<div id="outerDiv"></div> <!-- Keep this div up here so the content doesn't shift down -->
<!-- Server Form -->
<form runat="server" id="form1">
<!-- Create Buy Now buttons from an xml or database storage and bind them to a listview-->
<!-- HTML forms listview and form code not included -->
<form .....></form> ...
<form .....></form> ...
<form .....></form> ...
<form .....></form> ...
This is the easiest way to get the design time binding for buy now buttons.
May 06, 2008 01:21 AM|IrishChieft|LINK
These are all hacks. Here's the ASP.NET 2.0 solution to this problem:
May 14, 2008 03:52 AM|emran834|LINK
Got a single ASP.NET Server control will do everything to integrate PayPal payment to your ASP.NET Website once you simply drag and drop the control to your aspx page. It is
ASP.NET PayPal Control for Website Payments Standard. Very easy to use. Rich design time wizard and strong set of API to customize programmatically. Encrypted Website Payments Button can be generated on the fly. Not only that, the control can capture IPN/PDT
and fire IPN server side events where all IPN data is available from it's event argument object. Same for PDT.
Here is the link:
It works in Shared Hosting environment, very easy to use. IPN / PDT can be handled too like handling server side events.
Feb 14, 2010 01:52 PM|JonathanWood|LINK
I'm sorry, but this seems very much like a hack to me as well.
I acknowledge this issue is a bit of a thorn in the side of ASP.NET web forms. But I've come up with two approaches that seems less "hacky" to me:
The one that makes most sense depends on your requirements. Note that these are simply Buy-Now buttons I'm discussing. For anything more involved, you should either delve fully into the PayPal ecommerce API or write your own.
Feb 26, 2010 09:54 AM|cujo3969|LINK
Here is the code:
<input type="hidden" value="_s-xclick" name="cmd" /> <input type="hidden" value="R9ANYYFTZA9" name="hosted_button_id_NON" id="hosted_button_id_NON" />
alt="" src="images/btn-buy-now.gif" /></a> <img height="1" border="0" width="1" src="images/btn-buy-now.gif" alt=" Non-Caffeinated" /></p></div>
Mar 02, 2010 04:10 PM|muybn|LINK
<div style="text-align: center; vertical-align: middle;">
<asp:HyperLink ID="[URL provided by PayPal]"
<asp:Image ID="imgPayPal" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif"
May 28, 2010 05:05 AM|LaurentD|LINK
Like all of us, I was stuck by the fact you need a form tag for the PayPal button to work, which is impossible to insert in an ASP.NET page because of the enclosing ASP.NET standard
My solution was to create an .aspx web form, but to uncheck the Place code in separate file check box of Add new item dialog box. I ended with a page which works basically like an ASP classic page (remember ASP classic, when we were young?). This
way I can do exactly what I want in this page.
In my case, the order is built in a regular ASP.NET page, this particular page being a confirmation step before proceeding to PayPal.
Sep 29, 2010 06:05 AM|forestedge|LINK
Good solutions but the second will only work if you have 1 paypal button on the page. In the case where you have multiple buttons this will not work since it posts the entire form and the Paypal cart handles this by adding only the last item it comes to
from the form post.
This is the hidden inputs added to the webform
Mar 25, 2011 09:31 AM|Merin|LINK