Jump to content

Paypal Integration


Gotharious

Recommended Posts

Hello there,

 

I'm having a difficulty making the paypal integration with my online booking system, the developer who was making me this (who i can't find now) has set everything from searching to the point where you choose number of rooms you want in a hotel, then you click book now, it takes you to another page where you find information about your booking, and beneath it, you are supposed to enter you billing information, which doesn't really work

 

what i want to do now, is instead of making the client enter his billing info on the website, it takes him to PayPal website where he pays there.

I mean when you click, it gives you details of your order, and beneath it a form to enter your data.

I want to add a "Make the Reservation" button that will redirect the client to the PayPal website where he makes the payment.

 

I'm not sure which code I should post here, so I guess I should just post the code where the user gets the details of his order and enters his details.

 

 

book.php

 

<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td valign="top">
              <?php include("includes/bookinManager.php"); ?>
                  
              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formtable">
                <tr>
                  <th align="left" valign="top" class="formtable"> Booking Data </th>
                </tr>
                <tr>
                  <td valign="top"> </td>
                </tr>
                <tr>
                  <td valign="top">
			  <?php
			  	echoPostedData();
			  ?>
                  </td>
                </tr>
                <tr>
                  <td valign="top"> </td>
                </tr>
              </table>
             
              
              </td>
            </tr>
            <tr>
              <td valign="top"><img src="images/spacer.gif" width="28" height="10" /></td>
            </tr>
            <tr>
              <td valign="top">
              <?php
			if(isset($_POST['bookroom']))
		  {?>
              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formtable">
                <tr>
                  <th align="left" valign="top" class="formtable"> Your Details </th>
                </tr>
                <tr>
                  <td valign="top" > </td>
                </tr>
                <tr>
                  <td valign="top">
                  <?php //echoForm2();
                  ?>
                  
                  
                  <form id="userDetails" name="userDetails" action="" method="post">
                  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td valign="top" class="subtitle3"><strong>Your Name</strong><br />
                      <input type="text" name="name" size="50" /></td>
                      
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><strong>Email address</strong><br />
                        <input type="text" name="email" size="50" />
                      </td>
                    </tr>
                    <tr>
                    <td> </td>
                    <td> </td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3">
                      
                      <?php
			$roomsarray = explode(",",$_POST['roomid']);
			$roonsNo =  explode(",",$_POST['roomnum']);

			for($i = 0;$i<count($roomsarray);$i++)
			{
				if($roonsNo[$i] > 1)
				{	

					for($j = 0;$j<$roonsNo[$i];$j++)
					{
						echo "<div>";
						$result = mysql_query("select * from rooms where id = '$roomsarray[$i]'");
						$row = mysql_fetch_array($result);
						echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>";
						echo "</div>";
						echo "<table>";
						echo "<tr>";
						echo "<td>";
						echo "<span class=subtitle3><strong> Full guest name </strong></span>";
						echo "<br />";
						echo "<input type=text name=\"guest_name[]\" size=30/>";
						echo "</td>";
						echo "<td align=center>
						<span class=subtitle3><strong> Max people</strong></span>
						<br />
						<span class=subtitle3>".$row['people']."guests</span>
						</td>";
						echo "<td align=center>
						<span class=subtitle3><strong>Smoking</strong></span><br />
						<select name='smoking'>
						<option value=\"\">...</option>
						<option value=\"yes\">Yes</option>
						<option value=\"no\">No</option>
						</select>
						</td>";									
						echo "</tr>";									
						echo "</table>";
						echo "<br />";
					}
				}
				else
				{						
					if($roonsNo[$i] != 0)
					{
						echo "<div>";
						$result = mysql_query("select * from rooms where id = '$roomsarray[$i]'");
						$row = mysql_fetch_array($result);
						echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>";
						echo "</div>";

						echo "<table>";
						echo "<tr>";
						echo "<td>";
						echo "<span class=subtitle3><strong> Full guest name</strong></span>";
						echo "<br />";
						echo "<input type=text name=\"guest_name[]\" size=30/>";
						echo "</td>";
						echo "<td align=center>
						<span class=subtitle3><strong> Max people</strong></span>
						<br />
						<span class=subtitle3>".$row['people']."guests</span>
						</td>";
						echo "<td align=center>
						<span class=subtitle3><strong>Smoking</strong></span><br />
						<select name='smoking'>
						<option value=\"\">...</option>
						<option value=\"yes\">Yes</option>
						<option value=\"no\">No</option>
						</select>
						</td>";									
						echo "</tr>";									
						echo "</table>";

						echo "<br />";
					}
				}

			}

?>

                      </td>
                      
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><hr /></td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"> </td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><strong>Your Address</strong><br />
                      <input type="text" name="address" size="50" /></td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><strong>City</strong><br />
                      <input type="text" name="city" size="50" /></td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><strong>ZIP Code</strong><br />
                      <input type="text" name="zip" size="50" /></td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><strong>Country</strong><br />
                      <input type="text" name="country" size="50" /></td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><strong>Telephone</strong><br />
                      <input type="text" name="tel" size="50" /></td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"> 
                     </td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><table width="60%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td valign="top"><strong>Credit card type</strong><br />
                     <select name="cardtype">
                     <option value="american_express">American Express</option>
                     <option value="visa">Visa</option>
                     <option value="master_card">Master Card</option>
                     <option value="diners_club">Dinerts Club</option>
                     <option value="jcb">JCB</option>
                     </select></td>
                          <td valign="top"><strong>Credit card Number</strong><br />
                          <input type="text" accept="cardnum" />
                          </td>
                          <td valign="top"> </td>
                        </tr>
                        <tr>
                          <td valign="top"><strong>Card Holder's Name</strong><br />
                          <input type="text" name="holder"/></td>
                          <td valign="top"><strong>Expiration date</strong><br />
                         <input type="text" name="exdate" class="date_input" />
                         </td>
                          <td valign="top"><strong>CVC-code</strong><br />
                         <input type="text" name="cvc" size="7"/>
                         </td>
                        </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"> </td>
                    </tr>
                    
                    <tr>
                    <td align="right">
                      <input type="submit" name="submit" id="submit" value="Make the reservation" />
                      </td>
                    </tr>
                  </table>
			  </form>
                  
                  
                  
                  
                    </td>
                </tr>
                <tr>
                  <td valign="top"> </td>
                </tr>
              </table>
              <?php } ?>

 

bookinManager.php

 

<?php include("hotelsManager.php"); ?>
<?php include("config.php"); ?>
<?php include("textManager.php"); ?>
<?php
function echoPostedData()
{

	 $dbo = new DB();
	 $hotelObj = new hotelManager();
	 /*$hotelID = $_POST['hotelid'];
	 $datein = $_POST['datein'];
	 $dateout = $_POST['dateout'];
	 $roomid = $_POST['roomid'];*/

	 $_SESSION['hotelID'] = isset($_POST['hotelid']) ? $_POST['hotelid'] : $_SESSION['hotelID'];
	 $_SESSION['datein'] = isset($_POST['datein']) ? $_POST['datein'] : $_SESSION['datein'];
	 $_SESSION['dateout'] = isset($_POST['dateout']) ? $_POST['dateout'] : $_SESSION['dateout'];
         $_SESSION['roomid'] = isset($_POST['roomid']) ? $_POST['roomid'] : $_SESSION['roomid']; 	 


	 //$roomsarray = explode(",",$_POST['roomid']);
	 $_SESSION['roomsarray'] = isset($_POST['roomid']) ? explode(",",$_POST['roomid']) : $_SESSION['roomsarray'];
	 //$roonsNo = $_POST['nrooms'];
	 $_SESSION['nrooms'] = isset($_POST['roomnum']) ? explode(",",$_POST['roomnum']) : $_SESSION['nrooms'];
	 /* NUM OF PEOPLE */
	 $numOfPeople = 0;
	 for($i = 0;$i < count($_SESSION['nrooms']);$i++)
	 {
	 	 $result = mysql_query("select people from rooms where id = '".$_SESSION['roomsarray'][$i]."'");
	 	 $row = mysql_fetch_array($result);
	 	 $numOfPeople += ($row[0] * $_SESSION['nrooms'][$i]);;
	 }


	 /********************** hotels ************************/

	 /******************************************************/

	 echo "<table width=95% border=0 align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
         <tr><td valign=\"top\">";
                  echo "<table>";
                  echo "<tr>";
                  echo "<td valign=top>";
                  	$imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='".$_SESSION['hotelID']."' LIMIT 1");
		$image=mysql_fetch_array($imageqry);
		$imagename=$image['attachmentName'];
		echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>";
	  echo "</td>";
	  echo "<td>";
		  $result=$hotelObj->getHotelbyID($_SESSION['hotelID']);
		  $row = mysql_fetch_array($result);
		  echo "<table>";
		  echo "<tr><td valign=top><strong class=subtitle3>".$row['name']."</strong></td></tr>";
		  echo "<tr><td class=text valign=top>".$row['location']."</td></tr>";
		  echo "<tr><td class=text valign=top>check-in Date: ".$_SESSION['datein']."</td></tr>";
		  echo "<tr><td class=text valign=top>check-out Date: ".$_SESSION['dateout']."</td></tr>";
		  echo "<tr><td class=text valign=top>";
		  $newdate = $_SESSION['dateout'] - $_SESSION['datein'];
		  echo @array_sum($_SESSION['nrooms'])." rooms, ".$numOfPeople." people, ".$newdate." nights";
		  
		  echo "</td></tr></table>";
		  
		  echo "</td>";
		  echo "</tr>";
		  echo "</table>";
        echo "</td></tr></table>";
}

function echoForm2()
{
?>
	<form id="userDetails" name="userDetails" action="" method="post">
                  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td valign="top" class="subtitle3"><strong>Your Name</strong><br />
                      <input type="text" name="name" size="50" /></td>
                      
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3"><strong>Email address</strong><br />
                        <input type="text" name="email" size="50" />
                      </td>
                    </tr>
                    <tr>
                    <td> </td>
                    <td> </td>
                    </tr>
                    <tr>
                      <td valign="top" class="subtitle3">
                      
                      <?php
			$roomsarray = explode(",",$_POST['roomid']);
			$roonsNo =  explode(",",$_POST['roomnum']);

			for($i = 0;$i<count($roomsarray);$i++)
			{
				if($roonsNo[$i] > 1)
				{	

					for($j = 0;$j<$roonsNo[$i];$j++)
					{
						echo "<div>";
						$result = mysql_query("select * from rooms where id = '$roomsarray[$i]'");
						$row = mysql_fetch_array($result);
						echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>";
						echo "</div>";
						echo "<table>";
						echo "<tr>";
						echo "<td>";
						echo "<span class=subtitle3><strong> Full guest name </strong></span>";
						echo "<br />";
						echo "<input type=text name=\"guest_name[]\" size=30/>";
						echo "</td>";
						echo "<td align=center>
						<span class=subtitle3><strong> Max people</strong></span>
						<br />
						<span class=subtitle3>".$row['people']."guests</span>
						</td>";
						echo "<td align=center>
						<span class=subtitle3><strong>Smoking</strong></span><br />
						<select name='smoking'>
						<option value=\"\">...</option>
						<option value=\"yes\">Yes</option>
						<option value=\"no\">No</option>
						</select>
						</td>";									
						echo "</tr>";									
						echo "</table>";
						echo "<br />";
					}
				}
				else
				{						
					if($roonsNo[$i] != 0)
					{
						echo "<div>";
						$result = mysql_query("select * from rooms where id = '$roomsarray[$i]'");
						$row = mysql_fetch_array($result);
						echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>";
						echo "</div>";

						echo "<table>";
						echo "<tr>";
						echo "<td>";
						echo "<span class=subtitle3><strong> Full guest name</strong></span>";
						echo "<br />";
						echo "<input type=text name=\"guest_name[]\" size=30/>";
						echo "</td>";
						echo "<td align=center>
						<span class=subtitle3><strong> Max people</strong></span>
						<br />
						<span class=subtitle3>".$row['people']."guests</span>
						</td>";
						echo "<td align=center>
						<span class=subtitle3><strong>Smoking</strong></span><br />
						<select name='smoking'>
						<option value=\"\">...</option>
						<option value=\"yes\">Yes</option>
						<option value=\"no\">No</option>
						</select>
						</td>";									
						echo "</tr>";									
						echo "</table>";

						echo "<br />";
					}
				}

			}

?>
<hr>
                      </td>
                      
                    </tr>
                    <tr>
                    <td align="right">
                      <input type="submit" name="submit" id="submit" value="Make the reservation" />
                      </td>
                    </tr>
                  </table>
			  </form>
<?php
}

?>

 

Please help me in this as I'm a total noob

Link to comment
Share on other sites

Fortunately, there is a ton of features that Paypal offers, that would let you do everything you want to do, plus more.

 

Un-fortunately, there is so much, it would take someone that can look at all of you code, and help you integrate it, in a one on one setting.

 

You could look at Paypal Integration, or post this in the freelance section.  If you make a go of it on your own, post back if you run into a problem.

 

PS. I really hope that is not the total contents of those files.

Link to comment
Share on other sites

Ok, I've got to make it redirect to paypal when you click on submit

 

but the problem now, I want it to gather information from the website and take it to the paypal website like Room type, number of nights, Number of guests, Number of rooms, Total Price, Guest information etc.

 

Here is the code I typed

 

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="payPalForm">

                  <input type="hidden" name="item_number" value="01 - General Payment to My Domain">
			<input type="hidden" name="cmd" value="_xclick">
               <input type="hidden" name="no_note" value="1">
             <input type="hidden" name="business" value="me@mydomain.com">
            <input type="hidden" name="currency_code" value="USD">
                <input type="hidden" name="return" value="http://mydomain.com/">

First Name: <input name="first_name" type="text" id="first_name" size="45">
Last Name: <input name="last_name" type="text" id="last_name" size="45">
E-mail: <input name="email" type="text" id="email" size="45">
Address 1: <input name="address1" type="text" id="address1" size="45">
Address 2: <input name="address2" type="text" id="address2" size="45">
City: <input name="city" type="text" id="city" size="45">
Country: <input name="countty" type="text" id="country" size="45">


Amount: <input name="amount" type="text" id="amount" size="45">
<br /><br /> 

                      
                      <?php
			$roomsarray = explode(",",$_POST['roomid']);
			$roonsNo =  explode(",",$_POST['roomnum']);

			for($i = 0;$i<count($roomsarray);$i++)
			{
				if($roonsNo[$i] > 1)
				{	

					for($j = 0;$j<$roonsNo[$i];$j++)
					{
						echo "<div>";
						$result = mysql_query("select * from rooms where id = '$roomsarray[$i]'");
						$row = mysql_fetch_array($result);
						echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>";
						echo "</div>";
						echo "<table>";
						echo "<tr>";
						echo "<td>";
						echo "<span class=subtitle3><strong> Full guest name </strong></span>";
						echo "<br />";
						echo "<input type=text name=\"guest_name[]\" size=30/>";
						echo "</td>";
						echo "<td align=center>
						<span class=subtitle3><strong> Max people</strong></span>
						<br />
						<span class=subtitle3>".$row['people']."guests</span>
						</td>";
						echo "<td align=center>
						<span class=subtitle3><strong>Smoking</strong></span><br />
						<select name='smoking'>
						<option value=\"\">...</option>
						<option value=\"yes\">Yes</option>
						<option value=\"no\">No</option>
						</select>
						</td>";									
						echo "</tr>";									
						echo "</table>";
						echo "<br />";
					}
				}
				else
				{						
					if($roonsNo[$i] != 0)
					{
						echo "<div>";
						$result = mysql_query("select * from rooms where id = '$roomsarray[$i]'");
						$row = mysql_fetch_array($result);
						echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>";
						echo "</div>";

						echo "<table>";
						echo "<tr>";
						echo "<td>";
						echo "<span class=subtitle3><strong> Full guest name</strong></span>";
						echo "<br />";
						echo "<input type=text name=\"guest_name[]\" size=30/>";
						echo "</td>";
						echo "<td align=center>
						<span class=subtitle3><strong> Max people</strong></span>
						<br />
						<span class=subtitle3>".$row['people']."guests</span>
						</td>";
						echo "<td align=center>
						<span class=subtitle3><strong>Smoking</strong></span><br />
						<select name='smoking'>
						<option value=\"\">...</option>
						<option value=\"yes\">Yes</option>
						<option value=\"no\">No</option>
						</select>
						</td>";									
						echo "</tr>";									
						echo "</table>";

						echo "<br />";
					}
				}

			}

?>

                      
                    <input type="submit" name="Submit" value="Submit">

</form>

Link to comment
Share on other sites

You should have a form that gets the info, then passes it to a script that collects the data,  and does calculations.  After that, put out a confirmation page, clicking 'yes' goes to paypal, clicking 'no' clears the order.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.