Can't publish node

baja_tz - September 29, 2007 - 22:05
Project:PayPal Node
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:baja_tz
Status:postponed (maintainer needs more info)
Description

Call '$cost = paypalnode_calculate_fee($node_id)' in 'function paypalnode_paypal_ipn()' always returns 0 so 'if ($cost == $gross_amount)' returns false and node can't be published. If I comment 'if...' line everything works.

#1

baja_tz - October 7, 2007 - 18:51

Call 'paypalnode_calculate_fee($node_id);' cant't get $cost inside 'function paypalnode_paypal_ipn()'. It's always '0', also user is 'anonymous' in log entry (watchdog) even if I put it below 'node_load'. But when I put it in 'function paypalnode_thanks()':
...
$gross_amount = check_plain($_REQUEST['mc_gross']); not
$gross_amount = check_plain((float)$_REQUEST['mc_gross']);
(I have got cost but value of 50 for gross amount even in log from paypal mc_gross is 50.00, that is why i didn't put 'float')

....
if(check_plain($_REQUEST['payment_status']) == 'Completed') {

$node = node_load(array('nid' => $node_id, 'type' => variable_get('paypalnode_content_type', PAYPALNODE_CHARGE_TYPE) ));
$cost = paypalnode_calculate_fee($node_id);
db_query('UPDATE {node} SET status = 1 WHERE nid = %d AND vid = %d', $node_id, $node->vid);

watchdog('paypalnode', t('%title has now been published with cost @cost and gross amount @amount paid. @node', array(
'@amount' => $gross_amount,
'@cost' => $cost,
'%title' => $node->title,
'@node' => print_r($node, TRUE)
)), WATCHDOG_NOTICE, l(t('View'), 'node/'.$node_id));
...
in log I have:
107 has now been published with cost 50.00 and gross amount 50.00 paid. - user:baja
and node is published. This is not solution because I can't force user to go on 'paypalnode/thanks' after payment, just trying to locate where is the problem. Btw. nodepromocode module is activated.

#2

baja_tz - October 7, 2007 - 19:38

In first log entry ('function paypalnode_paypal_ipn'):
[taxonomy] => Array
(
)
Second log entry ('function paypalnode_thanks'):
[taxonomy] => Array
(
[16] => stdClass Object
(
[tid] => 16
[vid] => 2
[name] => Paid Ad
[description] =>
[weight] => 5
)

)

#3

baja_tz - October 9, 2007 - 17:07

Monolog continues :)
I did that this way:
function paypalnode_transaction_form() {
global $user;
...
$form['custom'] = array(
'#type' => 'hidden',
'#value' => $amount,
'#value' => t('@amount/@uid/@user_name', array('@amount' => $amount, '@uid' => $user->uid, '@user_name' => $user->name)),
//put $amount here too because 'custom' is passthrough variable.
...
}
function paypalnode_paypal_ipn() {
...
$custom = check_plain($_POST['custom']);
list($cost, $uid, $user_name) = explode('/', $custom);
...
// $cost = paypalnode_calculate_fee($node_id);
...
}
It works but I don't know is there some security or other issues with this solution, so I am asking author and other more experienced users to answer.

#4

budda - February 9, 2008 - 17:23

Cost calculation has been re-jigged ot hopefully work in all cases now.
Try the latest dev build.

Make sure you backup your database first, and then run /update.php to re-arrange the data in your tables for better price calculating.

#5

baja_tz - March 29, 2008 - 18:26

Sorry because I didn't reply earlier. Taxonomy array is empty again. Thank you for your efforts.

#6

budda - April 3, 2008 - 02:13
Status:active» postponed (maintainer needs more info)

@baza_tz
Not sure what you mean by "Taxonomy array is empty again". Is that a good thing?

#7

baja_tz - April 8, 2008 - 18:11

I mean that

case 'Completed':
...
$cost = paypalnode_calculate_fee($node_id);
...

returns: $cost = 0, because, if you check:
          watchdog('paypalnode', t('%title has now been published. <pre>@node</pre>', array(
            '%title' => $node->title,
            '@node' => print_r($node, TRUE)
            )), WATCHDOG_NOTICE, l(t('View'), 'node/'.$node->nid));

you will see that taxonomy is empty array. It returns:
[taxonomy] => Array
(
)

 
 

Drupal is a registered trademark of Dries Buytaert.