Forums

Configuration of paypal Listener

oneira 09 Aug, 2013
Hi, i'm finishing a form which uses Paypal, and it's actually my first time using it. I'm having troubles configuring the PayPal Listener. Right now i can send the data to the Paypal Sandbox (for testing purposes) but i can't confirm when it returns. I would also like to add a new field to the array sent, but it doesn't seem to recognize it. So i have two questions:

1) Is it possible to pass another variable, to allow me to update the DB once the paypal listener returns

i have read this post but i'm trying to use the EXTRA FIELDS in the settings pane of the Paypal Redirect. Right now i have

<?php
(..)
$user_id=$formAward->getUserId();

echo "<input type='hidden' id='id_user' name='id_user' value='".$user_id."'/>";
?>


the $user_id variable is correctly set, but id doesn't get passed. The Extra Fields are configured as follows:

item_number = item_number
id_user = id_user

But the second one is not passing trough. When i submit the form i get

https://www.sandbox.paypal.com/cgi-bin/webscr?(...)&item_number =One+time+Donation&id_user =&


so, essentially, what i'm i doing wrong?

------------------------------------

2) How can i see the data being returned from the Paypal to the form?

http://bridgebuilders.info/index.php?option=com_chronoforms&chronoform=application
">
http://bridgebuilders.info/index.php?option=com_chronoforms&chronoform=application


Right now, i have a simple action in the paypal listener, which is to write a message on the screen. However i would need to update the DB, using the parameters returned. I've used the info here
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=22619&start=0
">
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=22619&start=0


but i havent figure it out how to extract the info sent from the Paypal.
Thanks.
GreyHead 10 Aug, 2013
Hi oneira,

How is $formAward defined in this line?
$user_id=$formAward->getUserId();
It looks as though that may not be doing what you need.

The PayPal Listener action needs to be in its own event. Because the IPN confirmation is an 'invisible' hand-shake you can't output anything to the screen; you can I think add a DB Save to the action to save the information that PayPal returns (there is a lot of it). I've also used the Joomla! Logger code to output info to a text file that I can review later. (I think this will work with the Listener action but I've always coded my own PayPal custom actions.)

The id_user is not a valid PayPal variable so will probably be ignored by PayPal and may not be returned to the Listener. You can use one of the valid PayPal variables instead (check the PayPal docs to see which they are). Personally I assign a short random string to the transaction and set that as the 'invoice' variable which PayPal will return; I save the transaction data to the database and then use the invoice string to recover it when needed.

Bob
oneira 12 Aug, 2013
thanks for the reply

after fighting for a couple of hours, i managed to make it work using $form->data['invoice'] = $user_id;

so the sending process to Paypal is complete.


However, i have configured the on IPN event, as explained in a different post, but the only thing i have discovered so far is that is returning via the Invalid section, and it's not dumping the array it should return, for me to check the values being passed. Also, haven't found a way to return automatically to my form.

Thanks
Max_admin 12 Aug, 2013
Hi,

There are 2 different urls which you can configure with PayPal:

#1- the return url, you can set this in the PayPal redirect settings, it should be to any url you want, except your form's "on submit" or "ipn" events, for example, it may be to an article saying "thank you, we will get back to you shortly".

#2- The IPN url, it should be set in your PayPal account profile, it should point to the form's IPN event as explained on the FAQ on our FAQs page here.

PayPal will not pass all the form data back, you have to save it then load it back again later from the database.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
oneira 12 Aug, 2013
Right now, i have the Paypal configured as follows:

Notification URL http://bridgebuilders.info/index.php?option=com_chronoforms&chronoform=application&event=ipn&task=send
Message delivery Enabled



I followed the advised and saved the information to the DB BEFORE sending the data to Paypal, however, i'm passing an ID in the 'custom' field of the Paypal extra values, which I need to update the data after the Paypal is processed. Right now I'm get to the Paypal confirmation of payment, with a link to go back to my form, but when i click back, it goes, entering the IPN event, but i cant see the values passed back, because i need the custom value and the invoice id.

thanks
Max_admin 12 Aug, 2013
Clicking back after payment should NOT access the IPN event, this means that you have mixed the return url with the ipn url, please set the return url to something else.

The ipn url is accessed in the background (through the PayPal server itself), in order to check the data returned at this access, you should use an email action and write this code in the email body:

<?php print_r2($form->data); ?>


You may also set different emails in the 3 different listener events to check which one is triggered!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
oneira 12 Aug, 2013
Hi, just tried the suggestion and changed the return URL.

However, tried the email suggestion with different emails and received nothing.

I briefly activated the live site and checking the history on my seller's account, i see that an IPN was sent to the address, but I couldn't confirm. So, can i test them with the sandbox running?
Max_admin 12 Aug, 2013
Please post a screenshot for your form events setup, you may also contact me directly through the "Contact us" page to keep your info private.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
oneira 13 Aug, 2013
Hi max, already sent you a PM with the screenshot and some code. thanks
oneira 23 Aug, 2013
this is the configuration of the on IPN event. Since the form is already sending the info to Paypal and for the most part is already working, I'm just posting this.



In every case of the Listener i placed an email action, as Max suggested. I changed the return address to a different one. I already have a small function in php written to update the record using the info returned, but I'm not receiving any email with info.

The code i'm planning on using would be as follows

   private function update($id, $invoice){
      $db = JFactory::getDbo();
      
      $query = $db->getQuery(true);
      
      // Fields to update.
      $fields = array(
                  'confirmation_donation=1',
                   'invoice_donation=\''.$invoice.'\'');
   
      // Conditions for which records should be updated.
      $conditions = array(
                      'id_donation='.$id);

      $query->update($db->quoteName('frbz3_Donation'))->set($fields)->where($conditions);

      $db->setQuery($query);

      if (!$db->query()) 
       {
          throw new Exception($db->getErrorMsg());
       }
      else {
         $x = (int)$db->insertid();
      }
   }


this is inside a class (formAward) and the two parameters it is receiving would be coming from the Paypal. I'm sending the first one via the custom variable of the Paypal array, and the second one would be the generated invoice ID.

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