Friday, April 30, 2010

Paypal Webstie Standard Payment Method

Paypal Webstie Standard Payment Method for website

    
When we use Paypal website standard payment method for shopping cart with multiple buy item. On this method customer complete it's shopping on website and the time of payment he completely move to paypal website with complete detail of his buy item name, item qty , item amount and with Total Amount. On paypal site all detail will display as display on his shopping cart. here all necessary field that is will on site like first name, address,etc. will automatically filled and here customer need to just fill their credit card and it’s related field’s to complete the process.    

    
When customer complete the payment process then one url of success payment is also send form the site to paypal (in return input type) site will appear in form button on click on that button customer will reach to success page of website.      

    
There is on link of fail on cancel for not to complete the process.

    






Paypal Require Code:-





<form id="form1" action="https://www.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="business" value="{$merchantId}" />


<!--merchant paypal id in which payment will go-->
  <input type="hidden" name="cmd" value="_cart" />
  <input type="hidden" name="paymentaction" value="sale" />
  <?php

 // $itemresult result set of customer buy item fetch form order_item table and table where final order item is store
 $i=1;
 while($row = mysql_fetch_array($itemresult))
 {
 $amountinrupee = $row[1];
 $amount = round(intval($amountinrupee)/46.180,2);

 ?>
  <input type="hidden" name="item_name_<?= $i;?>" value="<?= $row[0];?>" />
  <input type="hidden" name="amount_<?= $i;?>" value="<?= $amount;?>" />
  <input type="hidden" name="quantity_<?= $i;?>" value="<?= $row[2];?>" />
  <?php
 $i++;
 }
 ?>
  <input type="hidden" name="first_name" value="<?= $orderdata[7];?>" /><!--customer first name -->
  <input type="hidden" name="last_name" value="<?= $orderdata[8];?>" /><!--customer last name -->
  <input type="hidden" name="address1" value="<?= $orderdata[9];?>" /><!--customer address 1 name -->
  <input type="hidden" name="address2" value="<?= $orderdata[10];?>" /><!--customer add2 name -->
  <input type="hidden" name="email" value="<?= $orderdata[12];?>" /><!--customer email name -->
  <input type="hidden" name="city" value="<?= $orderdata[13];?>" /><!--customer city name -->
  <input type="hidden" name="state" value="<?= $orderdata[14];?>" /><!--customer state name -->
  <input type="hidden" name="country" value="<?= $orderdata[15];?>" /><!--customer country name -->
  <input type="hidden" name="zip" value="<?= $orderdata[16];?>" /><!--customer zip name -->
  <input type="hidden" name="currency_code" value="USD" /><!--currrecy in which payment u need-->
  <input type="hidden" name="upload" value="1" /><!--paypal parameter-->
  <input type="hidden" name="return" value="http://www.example.com/shopcomplete.php" />
  <input type="hidden" name="cancel_return" value="http://www.example.com/shopfail.php" />
  </form>



No comments:

Post a Comment