Making a PayPal Form to accept a payment on our site

PayPal makes doing this very easy by providing those “Buy-It-Now” buttons you’ve probably seen around the place. Basically when you see one of those buttons, it is really the submit button on an HTML form with all the form fields set to hidden. This is fine for when you have a set price and set item, but in our situation we want the client to be able to fill out what it is they are paying for (e.g. an invoice number) and also to set how much they are paying.

This is easily done by changing the <input> fields from hidden to text and stripping away the defaults so that the user can fill them in. So let’s get started.

Step 1 – Make a Payment Confirmation Page

First of all you should make a page to send the user to after payment has been processed. For the example form that I am making – one for FreelanceSwitch – I created this page On this page you should be placing a simple confirmation message so that your client doesn’t feel like they just sent money off into the ether. Next upload the confirmation page so it’s accessible over the web and you have a URL for it.

Step 2 – Create the Form

Next we create the form. When I first made this form I used the Buy-It-Now button form generator on PayPal and then modified accordingly, but you can just use the code below and make the changes I’ve described further on:

<form action=”” method=”post” id=”payPalForm”>

<input type=”hidden” name=”item_number” value=”01 – General Payment to”>
<input type=”hidden” name=”cmd” value=”_xclick”>
<input type=”hidden” name=”no_note” value=”1″>
<input type=”hidden” name=”business” value=””>
<input type=”hidden” name=”currency_code” value=”USD”>
<input type=”hidden” name=”return” value=””>
<input type=”hidden” name=”cancel_ return” value=””>

Item Details:<br /><input name=”item_name” type=”text” id=”item_name”  size=”45″>
<br /><br />
Amount: <br /><input name=”amount” type=”text” id=”amount” size=”45″>
<br /><br />
<input type=”submit” name=”Submit” value=”Submit”>


The parts that need modification are as follows:

Item Number
The item number field is this one:

<input type="hidden" name="item_number" value="01 - General Payment to">

The value you place in this field appears when the user goes to PayPal and clicks the down arrow for more details on their purchase (you can see it by entering some information in the test form below). I’ve used the value “01 – General Payment to” and theoretically if I had some other forms for say donation I might write “02 – Donation” and so on.

The business field is this one:

<input type="hidden" name="business" value="">

Your PayPal ID or an email address associated with your PayPal account. Email addresses must be confirmed.

Currency Code

The currency of prices for trial periods and the subscription. The default is USD.

For allowable values, see Currency Codes.

Return URL

<input type="hidden" name="return" value="">

The URL to which the payer’s browser is redirected after completing the payment; for example, a URL on your site that displays a “Thank you for your payment” page.

Default – The browser is redirected to a PayPal web page.

Item Name

Description of item being sold (maximum 127 characters). If you are collecting aggregate payments, this can include a summary of all items purchased, tracking numbers, or generic terms such as “subscription.” If omitted, customer will see a field in which they have the option of entering an Item Name


The price or amount of the product, service, or contribution, not including shipping, handling, or tax. If omitted from Buy Now or Donate buttons, payers enter their own amount at the time of payment.

  • Required for Add to Cart buttons
  • Optional for Buy Now and Donate buttons
  • Not used with Subscribe or Buy Gift Certificate buttons

cancel_ return

A URL to which the payer’s browser is redirected if payment is cancelled; for example, a URL on your website that displays a “Payment Canceled” page.

Default – The browser is redirected to a PayPal web page.

For More PayPal HTML Variables Click Here

Bansal Sumit

To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *