12th Jun 2006
PHP Class: Paypal Button Generator
Ever tried to make a Paypal button using their Button Creator, or even by getting the information from their Help pages? It’s not easy or dynamic. I’ve made many sites that use Paypal for their payment of both single items and multi item shopping carts. I’ve created this class to make my job easier. I have not come upon something like this in my search on the internet, so I’m sharing it to the world.
This class supports:
- CSS Styles
- Custom IPN, Return, and Cancel pages
- Postage, handling and tax amounts per item
- Custom pass-through variable
NEW - Version 1.1 now supports PayPal Subscriptions!
Sites using this class:
Download
- Download Version 1.1 (30-11-2005) (Zip file)
Trying to get this to work - the images link in the code is broken — and for ex: just wood toys looks like a complete cart system (to me) The Planet source code area states there was an “example file as well” I figure this is the example.php page - I’m stuck here
Yes you’re right, the example file that was included is quite outdated. I’ve re-written the examples, and they’ll give you a much clearer picture now. The zip file has been updated with this new file (and the downloads here work now, yay!). If you’re still having trouble, let me know.
Hi - Great class. I was going to write one myself but yours works perfectly!! My site is an online website builder and one of my products is a 4 page dynamic site with a paypal driven shopping cart. As the customers build their own pages, your class worked perfectly to do all of the redirections etc. Thanks and great work!! You wont be able to see it in working for a few days as i still need to get the products pages built but the product is online.
I will try your this great class.
Thank you.
Sounds great! I’ll try it out!
first be indulgent about my english (i’m french) i’am looking for a php code that might be very easy for you, i’ve built a website with a shopping cart but now i want to integrate paypal to give my customer another way to pay.So when the customer is checking out he is asked to choose and option to pay his cart.when he click on “pay with paypal or credit cartd” i would like to find a way to dynamically build this button in function of the customer’s shopping cart button so that he would be using a single button to send informations about a multiple-items-shopping-cart to paypal
This is working great for our application, I have a few websites that will benefit from this. Right now it’s being used at a college frat website that accepts donations…
cool stuff… thanks
My problem is - I want to build a cart which will prevent visitors to view private pages until they PAY thru paypal. How to do it ? Will this CLASS help me
No. The class will create a Button that they can use to pay with, that is all. What you are looking for is Paypal IPN. It’s a secure way of checking whether the visitor has just come from paypal, and if the payment was a success or failure.
This class has an option for an IPN url, which you will need to use as part of the process. Searching paypals site for IPN will help you find out more.
Thanks JC, But what is the effectiveness of your class, PAYPAL buttons u generate dynamically ?I also need a list of buttons with an ID for each of the button , (ID from Database).. I also need this, but also a payment security - I mean IPN type should be incorporated in my system, I mean- the payment was a success or failure.
Yes exactly. Dynamic generation of buttons with hidden custom fields and the like.
There is a less secure way of getting the success or failure to a page, known as the passthrough URL. But, because it is simply a POST request it is open to vulnerability.
I should mention that I wrote this class over 2 years ago, I don’t even know if paypal supports it’s features anymore.
Hi, anyone know if its possible with this class, to include the logo of my site, in the paypal banner, when a user is bying a product.
i’ve tryed to use the attribute $image, but it dosen’t work. i used an image with 150×50.
am i doing somthig wrong? is that the attribute?
I have been looking for something like this for ages.
Assuming PayPal haven’t changed the way they work, I look forward to putting this to good use.
Thanks.
A teeny little suggestion, if I may : modify the constructor
thusly :
function PayPalButton($paypal_url=’https://www.paypal.com/cgi-bin/webscr’)
and make the code use that string : makes it heaps easier to do testing via the paypal sandbox. Otherwise - Lovely Stuff!
Cheers,
Martin
Exactly what I was looking for!