Wednesday, November 4, 2009

Integration of paypal in PHP

The instructions below provide a brief overview of the PayPal Shopping Cart. For more detailed instructions or to add special features to your Shopping Cart, please refer to the Website Payments Standard Integration Guide (PDF, 4.6 MB, March 2008).




How It Works

The PayPal Shopping Cart is easy to set-up and use:

  1. Log in to your Premier or Business PayPal account.

  2. Click on the Merchant Services tab.

  3. Click on the PayPal Shopping Cart link.

  4. Specify the name, price, and other details of the item you wish to sell.


  5. Add more optional information such as shipping, sales tax, and option fields (for size, color, etc.).

  6. Click Create Button Now and the Button Factory will generate customized HTML code.

  7. Paste the HTML code on your website to create your "Add to Cart" and "View Cart" buttons.

When a buyer clicks the "Add to Cart" button, a new window will appear listing the contents of the buyer's PayPal Shopping Cart, including the item just added. To make the purchase, the buyer clicks "Checkout" from this window.




PayPal Shopping Cart HTML Code

Experienced HTML users can bypass the Button Factory and create their own PayPal Shopping Cart payment buttons by altering the HTML code directly. The sample code below shows the minimum information you need to create an Add to Cart button (in this case, to purchase an HTML book):

<form name="_xclick" target="paypal" action="" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="HTML book">
<input type="hidden" name="amount" value="24.99">
<input type="image" src="http://www.paypal.com/en_US/i/btn/sc-but-01.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="add" value="1">
</form>




Pasting the code above into your website would generate a button that looks like this:



If you dynamically generate portions of your site, you can populate your Add to Cart buttons dynamically and save time by updating the variables with information from your database. To use the button above for a different item, you would only need to edit three variables: item_name, item_number, and amount.

To add a View Cart button to your website, just use this code:

<form name="_xclick" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="">
<input type="image" src="https://www.paypal.com/en_US/i/btn/view_cart.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="display" value="1">
</form>


Pasting the code above into your website would generate a button that looks like this:






No comments:

Post a Comment