PayPal Website Payments Standard HTML Form

Course- PHP Tutorial >

Website Payments Standard consists of HTML FORM on your website that direct your customer�s web browser to the PayPal website in order to pay and after successful payment return the customer to your website.
Lets create a basic HTML form on submit it will redirect to PayPal site and after successful payment return back to your thank you page and on payment declined return back to payment declined page.

HTML Form

 

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="PayPal Email Id">

<!-- Specify a PayPal Shopping Cart Add to Cart button. -->
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">

<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Your Product Name">
<input type="hidden" name="amount" value="3.95">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="currency_code" value="USD">

<!-- Display the payment button. -->
<input type="image" name="submit" border="0" 
src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" 
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" 
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form> 


The above from will send single item to PayPal page. If you want to send multiple items then you need to change Amount field name to amount_x Quantity field name to quantity_x etc. 'x' represents the number. Also don't forget to include the upload variable.

<input type="hidden" name="upload" value="1"> 

 

HTML Form to send Multiple Items.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="PayPal Email Id">

<!-- Specify a PayPal Shopping Cart Add to Cart button. -->
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">

<!-- Specify details about the item that buyers will purchase. -->

<input type="hidden" name="item_name_1" value="Your Product Name-1">
<input type="hidden" name="amount_1" value="3.95">
<input type="hidden" name="quantity_1" value="1">

<input type="hidden" name="item_name_2" value="Your Product Name-2">
<input type="hidden" name="amount_2" value="4.95">
<input type="hidden" name="quantity_2" value="1">

<input type="hidden" name="item_name_3" value="Your Product Name-3">
<input type="hidden" name="amount_3" value="5.95">
<input type="hidden" name="quantity_3" value="1">

<input type="hidden" name="shopping_url" value="http://www.a2zwebhelp.com">
<input type="hidden" name="currency_code" value="USD">

<!-- Display the payment button. -->
<input type="image" name="submit" border="0" 
src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" 
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" 
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>


You can also visit PayPal for more information. Click here to know more information about form fields and values.