Integrating PayPal into your site may seem intimidating to those who have never put together a serious project before. It might seem like everything changes when you start dealing with money. You always hear about someone else who has been scammed or in some kind of nightmare involving some sort of online transaction. When you realize how easy PayPal makes it to utilize their services it really puts any anxiety you have to rest.
The first thing to be aware of is PayPal's Integration Center. This is your ultimate reference to PayPal's different options available to you when building your site. Pay special attention to the Website Payments Standard section near the top of that page.
The basic idea around how to use PayPal to accept payments is to create a simple form with certain hidden fields that passes the data along to PayPal and they take care of the rest. For example, lets say you are selling a product that costs $20, here is how you would create a 'Buy it Now' button
This will create a form button similar to ![]()
In a nutshell, after clicking the PayPal 'Buy Now' button it will take the user to a PayPal page with all the information you passed along in the form. Here is the breakdown of each different command and value for this short form.
cmd = _xclick
This tells PayPal to consider this a Buy Now, Donation, or Subscription purchase.
business = me@mybusiness.com
This is how PayPal knows where to send the money. Obviously you must have an account with PayPal with the value being the email address you use to login.
item_name = Plastic_Yo-Yo
This lets PayPal know the title of the item I am selling.
currency_mode = USD
What PayPal should use in terms of currency, in this case United States Dollars.
amount = $3.99
This is the amount to charge for the product. If you leave this command blank, PayPal will take any amount entered by the user. Good for donations.
return = http://www.mybusiness.com/thanks.html
After the user finishes the transaction with PayPal, it will send the user back to this page. Normally this is some sort of thank-you with information about how to get in touch with someone if they have a question.
image_url = http://www.mybusiness.com/logo.jpg
PayPal will display this logo during the checkout process to remind the user what site they are buying from. Helps keep things personal.
That's it! The last line before the closing form tag is the image used as the submit button.
As a bonus I've included some very basic code to add to your own website to accept donations.
Just copy and paste this into your site to create a PayPal Donate button. Obviously, change the business email address and return value to your own. I tell PayPal the item name is Donation and to allow the user to fill in the amount. no_shipping tells PayPal not to ask the user for a shipping address.
That's about it. PayPal has many, many more options available to everyone which can be found at Standard Variable Reference Page.
Some of these links may require you to have a PayPal account and be logged in.
- Edit -
Security
Thanks for questions and comments about security. It is true that people can edit this code, since it is just html, and change the price for any product they are paying for. This usually is not a problem because I always check after receiving payment to reference the amount paid to the product id given, and if they don't match I know something isn't right. Nevertheless dave has provided a link to PayPal's Button Encryption site that explains how to prevent this sort of thing from happening. https://www.paypal.com/IntegrationCenter/ic_button-encryption.html
I also found a nice video introducing PayPal's features (Requires Flash): https://www.paypal.com/en_US/m/standard_demo_load.html



Comments
No comments yet. Be the first!