Jump to content

PHP IPN Issue


Ruzzas

Recommended Posts

if($p->ipn_data['receiver_email']=='[email protected]'){
	  $amount = $p->ipn_data['mc_gross'] - $p->ipn_data['mc_fee'];
	  mysql_query("	INSERT INTO donations (txn_id,item_number,first_name,last_name,payer_email,amount,mc_gross,mc_fee,receiver,email,payment_type,payment_status,payment_date,payer_business_name,payer_status)
					VALUES (
						'".esc($p->ipn_data['txn_id'])."',
						'".esc($p->ipn_data['item_number'])."',
						'".esc($p->ipn_data['first_name'])."',
						'".esc($p->ipn_data['last_name'])."',
						'".esc($p->ipn_data['payer_email'])."',
						".(float)$amount.",
						'".esc($p->ipn_data['mc_gross'])."',
						'".esc($p->ipn_data['mc_fee'])."',
						'".esc($p->ipn_data['receiver_email'])."',
						'".esc($p->ipn_data['payment_type'])."',
						'".esc($p->ipn_data['payment_status'])."',
						'".esc($p->ipn_data['payment_date'])."',
						'".esc($p->ipn_data['payer_business_name'])."',
						'".esc($p->ipn_data['payer_status'])."',
						'".esc($p->ipn_data['residence_country'])."',
						'".esc($p->ipn_data['mc_currency'])."',
						'".esc($p->ipn_data['payer_id'])."',
						'".esc($p->ipn_data['receiver_id'])."'
		)");
	}

 

It never seems to place any of that data into the mysql, It is overpacked or something?

Link to comment
https://forums.phpfreaks.com/topic/203136-php-ipn-issue/
Share on other sites

You should create the query as a string variable and then execute the query. This allows you to echo the query to the page when needed for debugging purposes. You also have no error handling on your query. So, it is likely failing, but you have no way of knowing.

 

I see at least two definit problems and a few possible problems. In the defined fields list there are two fields listed that should be one:

...,receiver,email,...

 

Based upon the values you are using I think that should be a single field called "receiver_email".

 

Also, in the values to populate in the database you have more values defined than you have fields. The last for values are not in the defined list.

 

I found it pretty easy when I was reformmatting the code into a more logic format. If you follow some sort of standard these types of problems are easily avoided.

 

<?php
    
if($p->ipn_data['receiver_email']=='[email protected]')
{
    //Prepare values
    $tax_id              = esc($p->ipn_data['txn_id']);
    $item_number         = esc($p->ipn_data['item_number']);
    $first_name          = esc($p->ipn_data['first_name']);
    $last_name           = esc($p->ipn_data['last_name']);
    $payer_email         = esc($p->ipn_data['payer_email']);
    $amount              = (float) ($p->ipn_data['mc_gross']-$p->ipn_data['mc_fee']);
    $mc_gross            = esc($p->ipn_data['mc_gross']);
    $mc_fee              = esc($p->ipn_data['mc_fee'];
    $receiver_email      = esc($p->ipn_data['receiver_email']);
    $payment_type        = esc($p->ipn_data['payment_type']);
    $payment_status      = esc($p->ipn_data['payment_status']);
    $payment_date        = esc($p->ipn_data['payment_date']);
    $payer_business_name = esc($p->ipn_data['payer_business_name']);
    $payer_status        = esc($p->ipn_data['payer_status']);
    $residence_country   = esc($p->ipn_data['residence_country']);
    $mc_currency         = esc($p->ipn_data['mc_currency']);
    $payer_id            = esc($p->ipn_data['payer_id']);
    $receiver_id         = esc($p->ipn_data['receiver_id']);
    
    //Create query
    $query = "INSERT INTO donations
                (`txn_id`, `item_number`, `first_name`, `last_name`, `payer_email`,
                 `amount`, `mc_gross`, `mc_fee`, `receiver_email`, `payment_type`,
                 `payment_status`, `payment_date`, `payer_business_name`, `payer_status`,
                 `residence_country`, `mc_currency`, `payer_id`, `receiver_id`)
              VALUES
                ('{$tax_id}', '{$item_number}', '{$first_name}', '{$last_name}', '{$payer_email}',
                 '{$amount}', '{$mc_gross}', '{$mc_fee}', '{$receiver_email}', '{$payment_type}',
                 '{$payment_status}', '{$payment_date}', '{$payer_business_name}', '{$payer_status}',
                 '{$residence_country}', '{$mc_currency}', '{$payer_id}', '{$receiver_id}')";
    
    //Execute query
    $result = mysql_query($query) or die("Error:<br />".mysql_error()."<br />Query:<br />$query");;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/203136-php-ipn-issue/#findComment-1064378
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.