Paypal integration using php in your e-commerce web-site

Paypal integration

When you are working with the e-commerce web-site and you need to setup payment gateway to make a payment for your web-site owner then its very easy using the paypal payment gateway.

Paypal gateway provide many methods to setup online payment for your web-site and here we will discuss one method which is very simple and easy to integrate in your e-commerce web-site. you need to set up below form and form elements.

<form name="frmpaypal" action="<?php echo $paypal_action_url;?>" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="<?php echo $client_paypal_email_id;?>" />
    <input type="hidden" name="item_name" value="<?php echo $item_name;?>" />
    <input type="hidden" name="item_number" value="<?php echo $item_number;?>" />
 
    <input type="hidden" name="no_note" value="1" />
    <input type="hidden" name="no_shipping" value="1" />
    <input type="hidden" name="return" value="<?php echo $success_url;?>" />
    <input type="hidden" name="cancel_return" value="<?php echo $cancel_url;?>" />
    <input type="hidden" name="currency_code" value="USD" />
    <input type="hidden" name="amount" value="<?php echo $amount;?>" />
    <input type="hidden" name="custom" value="<?php echo $custom_id;?>" />
 
    <input type="hidden" name="first_name" value="<?php echo $FirstName;?>" />
    <input type="hidden" name="last_name" value="<?php echo $LastName;?>" />
    <input type="hidden" name="address1" value="<?php echo $Address;?>" />
    <input type="hidden" name="city" value="<?php echo $City;?>" />
    <input type="hidden" name="state" value="<?php echo $State;?>" />
    <input type="hidden" name="zip" value="<?php echo $ZipCode;?>" />
    <input type="hidden" name="country" value="<?php echo $Country;?>" />
    <input type="hidden" name="image_url" id="image_url" value="<?php echo $company_logo_url;?>" />
 
    <input type="hidden" name="notify_url" value="<?php echo $notify_url;?>" />
    <input type="submit" name="submit" value="Submit"/>
</form>

Here, $paypal_action_url is the php variable where you need to set the paypal url. there is two type of url where one is live url and second one for testing purpose. when you set testing url then actual money transaction will not done. while in the live url your money will be deducted and you need to rollback if you are testing.

$paypal_action_url = “https://www.sandbox.paypal.com/cgi-bin/webscr”; ( Set this url for testing purpose)
$paypal_action_url = “https://www.paypal.com/cgi-bin/webscr”; ( Set this url for your real paypal payment)

I hope this will be helpful to setup paypal gateway in your web-site.