Jump to content

Paypal IPN cURL Issue. £40 via Paypal today for the man who solves it!


Recommended Posts

Where does payment_status come from?

 

if(isset($_REQUEST['payment_status']) && $_REQUEST['payment_status'] == 'Completed') 

 

Will prevent that error, but it does not get to the source of the problem, at least I do not think it does.

This line 8 notice (not error :P ) is telling us, that payment_status is not being send to this script.

Got any idea?

 

maybe the $_REQUEST variable? as its not getting any data using $_REQUEST

 

is there an alternative to $_REQUEST

$_REQUEST combines $_POST and $_GET (and $_COOKIES if I recall correctly), so that would no be it.

 

How is this script called?

 

from .htaccess:

 

RewriteRule ^transaction/(.*) /index.php?p=transaction&unique_id=$1

I bet thats your problem. You are assigning any query string etc to unique_id it seems, try and print out this:

 

echo $_REQUEST['unqiue_id'];

 

and see what prints out.

 

Interesting.. Where am I doing this in the code;

 

<?php
include('include/config.php');
error_reporting(E_ALL);
ini_set('display_errors','On');

//Array ( [p] => transaction [unique_id] => 11775 [mc_gross] => 0.99 [address_status] => confirmed [payer_id] => 94VEYGKNGKHL4 [tax] => 0.00 [address_street] => 39 lorne road [payment_date] => 15:46:12 Oct 22, 2007 PDT [payment_status] => Completed [charset] => windows-1252 [address_zip] => ha3 7nh [first_name] => Eimantas [mc_fee] => 0.34 [address_country_code] => GB [address_name] => CLANNED.COM [notify_version] => 2.4 [custom] => [payer_status] => verified [business] => andrewmalecha@hotmail.com [address_country] => United Kingdom [address_city] => london [quantity] => 1 [payer_email] => me@eimantas.com [verify_sign] => AJimJXiQSlZfm5u0TF0QZd7zwTkCAQq2Hna2HaTfItpROB1JNPuIYXFp [txn_id] => 6V249714A4487505X [payment_type] => instant [payer_business_name] => CLANNED.COM [last_name] => Sipas [address_state] => england [receiver_email] => andrewmalecha@hotmail.com [payment_fee] => 0.34 [receiver_id] => BFTEYADYLF9TG [txn_type] => web_accept [item_name] => CollegeCappers.com Lock Club [mc_currency] => USD [item_number] => [residence_country] => GB [payment_gross] => 0.99 [shipping] => 0.00 )

if($_REQUEST['payment_status'] == 'Completed') 
{
/* get temp order information */
$random_id = $_REQUEST['unique_id'];
    
    if ($random_id <= 20000)
    {
    $query = mysql_query("SELECT * FROM orders_temp WHERE random_id = '$random_id'");
    if(mysql_num_rows($query) == 0) {
	    print '<h1>Error</h1>There was a problem processing your order, are you sure you made your payment? 
	    Contact Administrator.';
	    return;
    }
    
    $row = mysql_fetch_object($query);
    
    /* process new order */
    $user_id = $row->user_id;
    $package_id = $row->package_id;
    $price_id = $row->price_id;
    $pick_id = $row->pick_id;
    $pick_price = $row->pick_price;
    $type = $row->type;
    $added = $row->time_added;
    
    /* if package, get start and end dates */
    if($type == 1) {
    
	    /* get package info */
	    $q2 = mysql_query("SELECT * FROM x_pack_prices WHERE id = '$price_id'");
	    $prices = mysql_fetch_object($q2);

	    
	    /* set starting and ending dates */
	    if($prices->season == 0) {
		    $date_start = $added;
		    $date_end = $added + ($prices->length * 24 * 60 * 60);
	    } else {
		    $date_start = $prices->dstart;
		    $date_end = $prices->dend;
	    }
	    
	    $package_price = $prices->value;
	    
	    $insert = mysql_query("INSERT INTO orders (user_id,package_id,package_price,price_id,type,dstart,dend) VALUES 
			    ('$user_id','$package_id','$package_price','$price_id','$type','$date_start','$date_end')");
	    
	    $order_id = mysql_insert_id();
    
    /* if single pick, dont add dates */
    } else {
    
	    $trans_date = time();
	    $insert = mysql_query("INSERT INTO orders (user_id,pick_id,pick_price,type,transaction) VALUES 
			    ('$user_id','$pick_id','$pick_price','$type','$trans_date')");
		    
	    $order_id = mysql_insert_id();
    }

    // paypal transaction id
    $transaction_id = $_REQUEST['txn_id'];
    
    $to      = 'service@footballadvisers.com';
    $subject = 'Football Advisers order';
    $message = 'NEW ORDER! Order Id: ' . $order_id . ' , Amount Paid: ' . $_REQUEST['payment_gross'];
    $headers = 'From: service@footballadvisers.com' . "\r\n" .
        'Reply-To: service@footballadvisers.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

        mail($to, $subject, $message, $headers);
        
?>
<style type="text/css">
<!--
.style1 {color: #336699}
-->
</style>

<h1 class="style1">Order Completed</h1> 

<strong>Thank you, your order has now been completed.</strong>
<br /><br />
Your Order ID: <? print $order_id; ?> and Transaction ID: <? print $transaction_id; ?>
<br /><br />
Please keep this information safe, and provide them if you are making a query regarding your purchase, thank you. 

<?php        
        
    }
    else
    {
        $query = mysql_query("SELECT * FROM orders_special_temp WHERE random_id = '$random_id'");
        if(mysql_num_rows($query) == 0) 
        {
            print '<h1>Error</h1>There was a problem processing your order, are you sure you made your payment? 
            Contact Administrator.';
            return;
        }
        
        $row = mysql_fetch_object($query);
        
        /* process new order */
        $user_id = $row->user_id;
        $package_id = $row->package_id;
        $package_price = $row->package_price;
                
        $trans_date = time();
        $insert = mysql_query("INSERT INTO orders_special (user_id,package_id,package_price,transaction) VALUES 
                ('$user_id','$package_id','$package_price','$trans_date')");
            
        $order_id = mysql_insert_id();

        // paypal transaction id
        $transaction_id = $_REQUEST['txn_id'];
        
       $to      = 'matt.lynch@footballadvisers.com';
    $subject = 'Number1BETS order';
    $message = 'NEW ORDER! Order Id: ' . $order_id . ' , Amount Paid: ' . $_REQUEST['payment_gross'];
    $headers = 'service@footballadvisers.com' . "\r\n" .
        'Reply-To: service@footballadvisers.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();


        mail($to, $subject, $message, $headers);

?>
<h1 class="style1">Order Completed</h1> 

<strong>Thank you, your order has now been completed.</strong>
<br /><br />
Your Order ID: <? print $order_id; ?> and Transaction ID: <? print $transaction_id; ?>
<br /><br />
Please keep this information safe, and provide them if you are making a query regarding your purchase, thank you. 

<?php
     
    }
}
?>

<?php
include('include/config.php');
error_reporting(E_ALL);
ini_set('display_errors','On');

echo $_REQUEST['unique_id'];
die();

if($_REQUEST['payment_status'] == 'Completed') 
{
   /* get temp order information */
   $random_id = $_REQUEST['unique_id'];
    

 

Not saying that the code is doing that, your htaccess script seems to be doing it.

<?php
include('include/config.php');
error_reporting(E_ALL);
ini_set('display_errors','On');

echo $_REQUEST['unique_id'];
die();

if($_REQUEST['payment_status'] == 'Completed') 
{
   /* get temp order information */
   $random_id = $_REQUEST['unique_id'];
    

 

Not saying that the code is doing that, your htaccess script seems to be doing it.

 

:) for the morons of the world (Me) what am I changing?

 

Sorry!

Nothing is changing, we are just echoing out unique_id to see what value(s) it holds. This is a simple debug tactic so we can see if my theory that the htaccess is assigning the query string to unique_id is true. If so that is why your $_REQUEST data is not populating.

Nothing is changing, we are just echoing out unique_id to see what value(s) it holds. This is a simple debug tactic so we can see if my theory that the htaccess is assigning the query string to unique_id is true. If so that is why your $_REQUEST data is not populating.

 

getting a blank page with 13984 in the top left.

 

http://www.footballadvisers.com/transaction/13984

 

I take it by this you are right?

Sort of, basically when you do that redirect there are no $_REQUEST data like you need there to be for the script to work. I am not sure how it should/would work, but it seems your script is missing a piece of the puzzel.

 

I am not sure where you got the data before and why it is not coming in now, what page calls that transaction page, is it possible to store the data coming in from paypal in a session and instead of using $_REQUEST use $_SESSION ?

 

There are alot of unknowns it seems like but the gist of it is that index.php page is not getting the data it needs through $_REQUEST for whatever reason.

Sort of, basically when you do that redirect there are no $_REQUEST data like you need there to be for the script to work. I am not sure how it should/would work, but it seems your script is missing a piece of the puzzel.

 

I am not sure where you got the data before and why it is not coming in now, what page calls that transaction page, is it possible to store the data coming in from paypal in a session and instead of using $_REQUEST use $_SESSION ?

 

There are alot of unknowns it seems like but the gist of it is that index.php page is not getting the data it needs through $_REQUEST for whatever reason.

 

what about me deleting the rewrite rule for the transaction page and making the transaction page a merged index and transaction page ie. www.footballadvisers.com/transaction.php, so its a full page in its own right and using an absolute url for paypal?

Give it a try. I honestly do not know enough about the script to see how that data would be populated/where you get it from. I will take a look at the other code and see if I cannot figure it out. But if you try that and it works let us know. It will help get this solved.

 

EDIT:

Thinking about it, you have $request defined in the initial script, what does that print out if you print it? I am thinking that the $request variable may have the information you need? But not 100% sure.

Give it a try. I honestly do not know enough about the script to see how that data would be populated/where you get it from. I will take a look at the other code and see if I cannot figure it out. But if you try that and it works let us know. It will help get this solved.

 

EDIT:

Thinking about it, you have $request defined in the initial script, what does that print out if you print it? I am thinking that the $request variable may have the information you need? But not 100% sure.

 

Which script are you seeing the $request defined?

The IPN Script:

 


<?php
/*
* ipn.php
*
* PHP Toolkit for PayPal v0.51
* http://www.paypal.com/pdn
*
* Copyright (c) 2004 PayPal Inc
*
* Released under Common Public License 1.0
* http://opensource.org/licenses/cpl.php
*
*/

//get global configuration information
include_once('../includes/global_config.inc.php'); 

//get pay pal configuration file
include_once('../includes/config.inc.php'); 


//decide which post method to use
switch($paypal[post_method]) { 

case "libCurl": //php compiled with libCurl support

$result=libCurlPost($paypal[url],$_POST); 


break;


case "curl": //cURL via command line

$result=curlPost($paypal[url],$_POST); 

break; 


case "fso": //php fsockopen(); 

$result=fsockPost($paypal[url],$_POST); 

break; 


default: //use the fsockopen method as default post method

$result=fsockPost($paypal[url],$_POST);

break;

}


//check the ipn result received back from paypal

if(eregi("VERIFIED",$result)) 
{ include_once('./ipn_success.php'); } 

else 
{ include_once('./ipn_error.php'); } 


?>

 

 

The IPN Script:

 


<?php
/*
* ipn.php
*
* PHP Toolkit for PayPal v0.51
* http://www.paypal.com/pdn
*
* Copyright (c) 2004 PayPal Inc
*
* Released under Common Public License 1.0
* http://opensource.org/licenses/cpl.php
*
*/

//get global configuration information
include_once('../includes/global_config.inc.php'); 

//get pay pal configuration file
include_once('../includes/config.inc.php'); 


//decide which post method to use
switch($paypal[post_method]) { 

case "libCurl": //php compiled with libCurl support

$result=libCurlPost($paypal[url],$_POST); 


break;


case "curl": //cURL via command line

$result=curlPost($paypal[url],$_POST); 

break; 


case "fso": //php fsockopen(); 

$result=fsockPost($paypal[url],$_POST); 

break; 


default: //use the fsockopen method as default post method

$result=fsockPost($paypal[url],$_POST);

break;

}


//check the ipn result received back from paypal

if(eregi("VERIFIED",$result)) 
{ include_once('./ipn_success.php'); } 

else 
{ include_once('./ipn_error.php'); } 


?>

 

Do you mean $result

Umm...yea? I think that's what I said and you asked...

 

Sorry! I know it can be frustrating dealing with "newbies" I'm good with php but not at this depth so please bear with me  :)

 

You want me to print $result. How am I doing this as I dont know?

 

Thanks

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.