|
Rank: Starting Member
Groups: Registered
Joined: 7/26/2003 Posts: 1 Location: ,
|
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// assign variables
$item_name = $_POST['item_name1'];
$receiver_email = $_POST['receiver_email'];
$item_number = $_POST['item_number1'];
$payment_status = $_POST['payment_status'];
$payer_email = $_POST['payer_email'];
$quantity = $_POST['quantity1'];
$payment_date = $_POST['payment_date'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
if (!$fp) {
message_die(GENERAL_MESSAGE, 'Your Purchase has NOT been succesful.<br /><br /><a href="index.php">Click here</a> to back to the hompage and retry!');
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// process payment
//Write the data to my own database
if($item_number = 50)
{
$sql = "select creds from php_users where user_id = '$user_id'";
$result=mysql_query($sql) or die (mysql_error());
$all= mysql_fetch_array($result);
extract($all);
$creds = $creds + 50;
$sql = "update php_users set creds='$creds' where user_id ='$user_id'";
$result=mysql_query($sql) or die (mysql_error());
}
if($item_number = 100)
{
$sql = "select creds from php_users where user_id = '$user_id'";
$result=mysql_query($sql) or die (mysql_error());
$all= mysql_fetch_array($result);
extract($all);
$creds = $creds + 100;
$sql = "update php_users set creds='$creds' where user_id ='$user_id'";
$result=mysql_query($sql) or die (mysql_error());
}
if($item_number = 250)
{
$sql = "select creds from php_users where user_id = '$user_id'";
$result=mysql_query($sql) or die (mysql_error());
$all= mysql_fetch_array($result);
extract($all);
$creds = $creds + 250;
$sql = "update php_users set creds='$creds' where user_id ='$user_id'";
$result=mysql_query($sql) or die (mysql_error());
}
if($item_number = 500)
{
$sql = "select creds from php_users where user_id = '$user_id'";
$result=mysql_query($sql) or die (mysql_error());
$all= mysql_fetch_array($result);
extract($all);
$creds = $creds + 500;
$sql = "update php_users set creds='$creds' where user_id ='$user_id'";
$result=mysql_query($sql) or die (mysql_error());
}
if($item_number = 1000 )
{
$sql = "select creds from php_users where user_id = '$user_id'";
$result=mysql_query($sql) or die (mysql_error());
$all= mysql_fetch_array($result);
extract($all);
$creds = $creds + 1000;
$sql = "update php_users set creds='$creds' where user_id ='$user_id'";
$result=mysql_query($sql) or die (mysql_error());
}
include "affiliates/dodacheck.php";
}
else if (strcmp ($res, "INVALID") == 0) {
message_die(GENERAL_MESSAGE, 'Your Purchase has NOT been succesful.<br /><br /><a href="index.php">Click here</a> to back to the hompage and retry!');
}
}
fclose ($fp);
}
?>
It does not transfer the payment at all! It also keeps the payment as pending and I have to click accept or decline. Anyway of fixing this (I have set up IPN on paypal)
Thanks
|
|
Rank: Starting Member
Groups: Registered
Joined: 9/16/2002 Posts: 2,960 Location: ,
|
You should be able to determine the pending reason in online History. You may need to upgrade your account, beomce verified, etc. Patrick Breitenbach PayPal, Inc. Dev Net: https://www.paypal.com/pdn
|