Current location: Hot Scripts Forums » Programming Languages » PHP » Paypal Integration
 
Reply
   
  #1 (permalink)  
Old 05-01-12, 10:21 PM
Paypal Integration

Hi guys i have a shopping cart... this is the code for the confirm order... now I wanna redirect the customer to pay with paypal but i dont know how ?? any help please

this is my confirmorder.php code
PHP Code:

<?php


echo "<h2><u>Confirming Order</u></h2><br>\n";

$total 0;
echo 
"<table width=\"100%\" cellpadding=\"1\" border=\"1\">\n";
echo 
"<tr><td>Product</td><td>Price</td><td>Quantity</td>
<td>Total</td>\n"
;
foreach(
$_SESSION['cart'] as $prodid => $quantity) {
$query "SELECT description, price FROM products WHERE prodid = $prodid";
$result mysql_query($query);
$row mysql_fetch_array($resultMYSQL_ASSOC);
$description $row['description'];
$price $row['price'];

$subtotal $price $quantity;
 
$total += $subtotal;
printf("<tr><td>%s</td><td>%s</td><td>%d</td><td>$%.2f</td></tr>\n"$description$price$quantity$subtotal); }
 
printf("<tr><td colspan=\"3\"><b>Total</b></td><td>$%.2f</td></tr>\n"$total); echo "</table>\n";

echo 
"<form action=\"index.php\" method=\"post\">\n";
echo 
"<input type=\"hidden\" name=\"content\" value=\"finishorder\">\n";
echo 
"<input type=\"submit\" name=\"button\" value=\"Confirm order\">\n";
echo 
"</form>\n";
echo 
"<form action=\"index.php\" method=\"post\">\n";
echo 
"<input type=\"hidden\" name=\"content\" value=\"reviewcart\">\n";
echo 
"<input type=\"submit\" name=\"button\" value=\"Change Order\">\n";
echo 
"</form\">\n";
?>
I have the confirm order bottom and then the finalizing order... where I can put the paypal form to let the customer to pay for the item. THANKS FOR YOUR HELP
Attached Images
File Type: jpg confirm.JPG (15.1 KB, 17 views)
File Type: jpg finalizing order.JPG (10.1 KB, 16 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-03-12, 06:44 PM
Looking a PayPals website they seem to have a good guide/help to get started, if you come across any problems with what they say post back

https://www.paypal.com/cgi-bin/websc...Direct-outside
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-04-12, 04:26 PM
 
 
Paypal integration

Hi thanks for your reply.... I am able to integrate with paypal... but now if the customer buys two different products in paypal only shows me one item with total....i would like to show the name of the products with its respective prices and then the total. Also It wont be able to update my db. Can help me with it please thank yo so much
PHP Code:

<?php


echo "<h2><u>Confirming Order</u></h2><br>\n";

$total 0;
echo 
"<table width=\"100%\" cellpadding=\"1\" border=\"1\">\n";
echo 
"<tr><td>Product</td><td>Price</td><td>Quantity</td>
<td>Total</td>\n"
;
foreach(
$_SESSION['cart'] as $prodid => $quantity) {
$query "SELECT description, price FROM products WHERE prodid = $prodid";
$result mysql_query($query);
$row mysql_fetch_array($resultMYSQL_ASSOC);
$description $row['description'];
$price $row['price'];

$subtotal $price $quantity;
 
$total += $subtotal;
printf("<tr><td>%s</td><td>%s</td><td>%d</td><td>$%.2f</td></tr>\n"$description$price$quantity$subtotal); }
 
printf("<tr><td colspan=\"3\"><b>Total</b></td><td>$%.2f</td></tr>\n"$total);
 echo 
"</table>\n";

echo
"<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
echo
"<input type='hidden' name='cmd' value='_xclick'>";
echo
"<input type='hidden' name='business' value='seller@dezignerfotos.com'>";
echo
"<input type='hidden' name='item_name' value='$description'>";
echo
"<input type='hidden' name='item_number' value='$prodid'>";
echo
"<input type='hidden' name='Product' value='$price'>";
echo
"<input type='hidden' name='amount' value='$total'>";
echo
"<input type='hidden' name='shipping' value='0'>";
echo
"<input type='hidden' name='currency_code' value='USD'>";
echo
"<input type='submit' value='PayPal'>";
echo
"</form>";
echo 
"<form>\n";
echo 
"<input type=\"submit\" name=\"button\" value=\"Confirm order\">\n";
echo 
"</form>\n";
echo 
"<form action=\"index.php\" method=\"post\">\n";
echo 
"<input type=\"hidden\" name=\"content\" value=\"reviewcart\">\n";
echo 
"<input type=\"submit\" name=\"button\" value=\"Change Order\">\n";
echo 
"</form\">\n";
?>
Attached Images
File Type: jpg paypal.JPG (9.2 KB, 8 views)

Last edited by williamh26; 05-04-12 at 04:30 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 
Reply

Bookmarks