• Jul
  • 09
  • 2012

You might have gone through our previous post which explains how to implement authorise.net in PHP website. Now it’s time to explain about another highly used PayPal payment gateway.

Suppose you are developing any e-commerce website. You will surely need to develop payment gateway for allowing your users to pay online.

We are writing and explaining the code for integrating PayPal with any website.Before you proceed for implementing PayPal in live mode, you must implement it in test mode and then test it well.

Here is the code for implementing PayPal in any website.

<form name="frmpaypal" action="<?=$paypal_action?>" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?=$paypal_email_id?>" />
<input type="hidden" name="item_name" value="<?=$item_name?>" />
<input type="hidden" name="item_number" value="<?=$item_number?>" />

<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return" value="<?=$success_url?>" />
<input type="hidden" name="cancel_return" value="<?=$cancel_url?>" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="amount" value="<?=$amount?>" />
<input type="hidden" name="custom" value="<?=$custom_id?>" />

<input type="hidden" name="first_name" value="<?=$rs_mem[0]['vFirstName']?>" />
<input type="hidden" name="last_name" value="<?=$rs_mem[0]['vLastName']?>" />
<input type="hidden" name="address1" value="<?=$rs_mem[0]['vAddress']?>" />
<input type="hidden" name="city" value="<?=$rs_mem[0]['vCity']?>" />
<input type="hidden" name="state" value="<?=$rs_mem[0]['vState']?>" />
<input type="hidden" name="zip" value="<?=$rs_mem[0]['vZipCode']?>" />
<input type="hidden" name="country" value="<?=$rs_mem[0]['vCountry']?>" />
<input type="hidden" name="image_url" id="image_url" value="<?=$logo_img_url?>" />

<input type="hidden" name="notify_url" value="<?=$notify_url?>" />
<input type="submit" name="submit" value="Submit"/>

In the above code, We have mentioned all the parameters with proper naming convention so that you can easily understand it.But there are some parameters which need to be mentioned.

$paypal_action = "https://www.sandbox.paypal.com/cgi-bin/webscr"; ( This is used for testing the script)
$paypal_action = "https://www.paypal.com/cgi-bin/webscr"; ( This is used for making your paypal payment gateway live)

$custom_id and $notify_url are not necessary to use. If you want to use it then you can use for notifying admin above the transaction.

The above Paypal Integration is the Paypal Standard Payment, paypal also provides many more Paypal Payment Options which you can check at https://developer.paypal.com/ or can contact us by clicking here

Ravi Makhija

Ravi Makhija

A writer, an Entrepreneur. Curious about the internet of everything. Interested in the cutting edge landscape of mobile apps and SAAS products. Blogs for Guru Technolabs - A Mobile App Development Company.

Popular Blogs

Among the many digital tools that are being used with increasing frequency, the one that has the greatest...

Having a Best Website like opening a door and inviting…

In this internet era, the business website is the most…

The Live chat is the common thing now days, if…

Let's Discuss a Project

Please share your unique idea or project requirement with us, our business concern person will get back to you with further details.