Forums

pay pal ipn listner

bleak26 19 Dec, 2011
I am using chronoform version 4.0 RC2.0

I have created a form which submits to paypal and on payment the paypal ipn calls back that forms paypal listener. If the paypal transaction is verified then a “custom code” action should run which contain the following.

<?php
$con = mysql_connect("*****","*******","**********");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("*********", $con);

$query ="UPDATE
  `jos_chronoforms_data_request_permit`
SET
  `have_they_paid` = 1
WHERE
  `jos_chronoforms_data_request_permit`.`custom` = ";
  $query .= "'".$form->data['custom']."'";

mysql_query($query);

mysql_close($con);
?> 


at the inital form submision, My form sends a variable called 'custom' which contains a unique id, which is used by the "custom code" action in the listner to identify which database record is associated with the call to the listener and update that record to paid.

My problem is that I dont know how to properly access the $_POST array from inside the action, so I am using $form->data['custom']. Is this correct? or should I be accessing it in another way? (as the code above is not working when i use $form->data['custom'])

I am finding it hard to test $form->data as i can’t see the output when it runs.

I am also unsure whether I should be running this code when it is at view or controller ?

Thankyou in advance
GreyHead 19 Dec, 2011
Hi bleak26,

I dug into the code and, as far as I can see the Listener action doesn't do anything with the data except to echo it back to PayPal for verification (IMHO it should also validate against a local copy). You should be able to access the results from the $_POST array I think so I'd use
$custom = JRequest::getVar('custom', '', 'post');
should get the value you need.

Bob
This topic is locked and no more replies can be posted.