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="" 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" />

 // $itemresult result set of customer buy item fetch form order_item table and table where final order item is store
 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];?>" />
  <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="" />
  <input type="hidden" name="cancel_return" value="" />

Thursday, April 29, 2010

Integrate Phpbb3 forum login(session) with website

Integrate Phpbb3 forum login(session) with website
When we use third part tool phpbb3 with your website as site forum there is necessary  to set phpbb3 login session when any user login to website so user can also use forum without re-login to phpbb3 forum because there is many session variable that is require for login to forum and work on it.
Website forum:-
Website login
There is 3 way to reach to site forum first open/land to index.php page and reach to it’s viewforum.php page and reach to it’s viewtopic.php page
Website forum page use by user:-,
First we need that user that is register with site also have entry in phpbb3 forum users table and user_group with same user id that is given on site registration time.
When we move site to forum any above forum page than we need to pass that user id as parameter and get that parameter then fetch record from site user table and set all necessary session parameter for keep login on form.

 Forum login session set code:-

//get site user Id
//start forum user session
//check user id exist or login 
$str="select * from site_members where member_id=$var_id"; 
$qstr=mysql_query($str,$dbc) or die('error in members'.mysql_error());
   $user->data[user_ip] = $_SERVER['REMOTE_ADDR'];
    $user->data[user_regdate] = 0;
    $user->data[username] = $fstr['first_name'];
    $user->data[username_clean] = $fstr['first_name'];
    $user->data[user_password] = md5($fstr['password']);
    $user->data[user_passchg] = 0;
    $user->data[user_pass_convert] = 0;
    $user->data[user_email] = '';
    $user->data[user_email_hash] = 0;
    $user->data[user_birthday] =  0- 0-   0;
    $user->data[user_lastvisit] = 1238142551;
    $user->data[user_lastmark] = 0;
    $user->data[user_lastpost_time] = 0;
    $user->data[user_lastpage] = index.php;
    $user->data[user_last_confirm_key] = '';
    $user->data[user_last_search] = 0;
    $user->data[user_warnings] = 0;
    $user->data[user_last_warning] = 0;
    $user->data[user_login_attempts] = 0;
    $user->data[user_inactive_reason] = 0;
    $user->data[user_inactive_time] = 0;
    $user->data[user_posts] = 1;
    $user->data[user_lang] = en;
    $user->data[user_timezone] = 0.00;
    $user->data[user_dst] = 0;
    $user->data[user_dateformat] = 'd M Y H:i';
    $user->data[user_style] = 1;
    $user->data[user_rank] = 0;
    $user->data[user_colour] = '';
    $user->data[user_new_privmsg] = 0;
    $user->data[user_unread_privmsg] = 0;
    $user->data[user_last_privmsg] = 0;
    $user->data[user_message_rules] = 0;
    $user->data[user_full_folder] = -3;
    $user->data[user_emailtime] = 0;
    $user->data[user_topic_show_days] = 0;
    $user->data[user_topic_sortby_type] = t;
    $user->data[user_topic_sortby_dir] = d;
    $user->data[user_post_show_days] = 0;
    $user->data[user_post_sortby_type] = t;
    $user->data[user_post_sortby_dir] = a;
    $user->data[user_notify] = 1;
    $user->data[user_notify_pm] = 0;
    $user->data[user_notify_type] = 0;
    $user->data[user_allow_pm] = 1;
    $user->data[user_allow_viewonline] = 1;
    $user->data[user_allow_viewemail] = 0;
    $user->data[user_allow_massemail] = 1;
    $user->data[user_options] = 831;
    $user->data[user_avatar] = '';
    $user->data[user_avatar_type] = 0;
    $user->data[user_avatar_width] = 0;
    $user->data[user_avatar_height] = 0;
    $user->data[user_sig] = '';
    $user->data[user_sig_bbcode_uid] = '3m872xlu';
    $user->data[user_sig_bbcode_bitfield] = 0;
    $user->data[user_from] = '';
    $user->data[user_icq] = '';
    $user->data[user_aim] = '';
    $user->data[user_yim] = '';
    $user->data[user_msnm] = '';
    $user->data[user_jabber] = '';
    $user->data[user_website] = '';
    $user->data[user_occ] = '';
    $user->data[user_interests] = '';
    $user->data[user_actkey] = '';
    $user->data[user_newpasswd] = '';
    $user->data[user_form_salt] = '168ff8093150140f';
    $user->data[session_id] = session_id();
    $user->data[session_user_id] = $fstr["member_id"];;
    $user->data[session_forum_id] = 0;
    $user->data[session_last_visit] = '1238142551';
    $user->data[session_start] = time();
    $user->data[session_time] = time();
    $user->data[session_ip] = $_SERVER['REMOTE_ADDR'];
    $user->data[session_browser] = $_SERVER['HTTP_USER_AGENT'];
    $user->data[session_forwarded_for] = '';
    $user->data[session_page] = 'index.php';  
    $user->data[session_viewonline] = 1;
    $user->data[session_autologin] = 0;
    $user->data[session_admin] = 0;
    $user->data[is_registered] = 1;
    $user->data[is_bot] = '';
    $result = $auth->login($fstr['username'], $fstr['password'], $autologin);


1.    $user->data[session_page] = 'index.php';  

index.php is the value according to page on which it is use like for viewforum.php it will be viewforum.php and for viewtopic.php it will be viewtopic.php

$auth->login($username, $password, $remember, 1, 0)

$username would be the exact username that would be found in the phpBB user table.

$password would be the string to match by (pre-hash, this should be just the original text, the $auth->login() function takes care of converting it into a comparable hash)

$remember is a boolean value, false if no remember me choice, true if user is going to have a 'remembered' session