Forums

PayPal Listener using PayPal Button

techbranch 08 Nov, 2015
Do you have any instructions for just using the PayPal listener to wait for purchases using a standard PayPal button?
GreyHead 08 Nov, 2015
Hi techbranch,

Do you need to use the Listener? I ask because it's not commonly used with a PayPal button. Is this a hosted button?

If you do then you will need to set a notify_url either in your PayPal account or in the button settings (if that is possible). After that the setup is as normal. Please see this FAQ

Bob
techbranch 08 Nov, 2015
Bob,
Thank you very much for such a prompt response.
Yes I use PayPal buttons here on my website:http://www.onlinefishingtournament.com
and I do have the following URL setup in my PayPal IPN settings.
http://www.onlinefishingtournament.com/index.php?option=com_chronoforms&chronoform=tournament_registered&event=ipn

My intent is to have the IPN return the item name and cost to the site and the listener insert that into the tournament_registered table



I want to use the listener to confirm when people pay and to post to a table.
techbranch 08 Nov, 2015
On the demo paypal form it has the DB Save in the button submit from the form but there will be no form here.
Just the listener and on the listener inside your demo I only see a DB Read
techbranch 08 Nov, 2015
Here is a good example of what I am trying to do.
Use a paypal button like this. When it hits the notify URL i was hoping your paypal listener would be be listening and write to a table for me.
<!-- Begin PayPal Button -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="orders@onlinefishingtournament.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="Redfish from onlinefishingtournament.com">
<input type="hidden" name="item_number" value="dd01">
<input type="hidden" name="amount" value="1.99">
<input type="hidden" name="return">
value="http://www.onlinefishingtournament.com/redfish/thanks.cgi">
<input type="hidden" name="cancel_return">
value="http://www.onlinefishingtournament.com/canceled.html">
<input type="hidden" name="notify_url" value="http://www.onlinefishingtournament.com/notify.cgi">
<input type="image" border="0" name="submit" src="http://images.paypal.com/images/x-click-but5.gif" alt="Buy Redfish with PayPal">
</form>
<!-- End PayPal Button -->
techbranch 08 Nov, 2015
The idea comes from here.
https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/article_pdn_intro-outside
I want to substitute the Chronoform IPN listener for his notify.cgi python script

Thanks for your help
techbranch 10 Nov, 2015
Bob,

So the question I have for you is how do I set up the LISTENER to receive the order details returned from the PayPal servers and DB Save to a table on my website?

The way my paypal buttons work they have a place for me to put the return URL in which would be the link to the ChronoForm but I dont want the form to do anything but LISTEN and DB Save.

Currently Whenever someone clicks on the PayPal button and buys a tournament registration PayPal servers hit this URL for me

<input type="hidden" name="notify_url" value="http://www.onlinefishingtournament.com/index.php?option=com_chronoforms&chronoform=tournament_registered&event=ipn">

I need help on how to setup a listener to capture the hidden order details in the PayPal button form and write them to my database?

Thank you for your help in advance.
GreyHead 10 Nov, 2015
Hi Techbranch,

Create a form called tournament_registered if you don't already have it; in the Setup tab click the Add New Event button and call the new event ipn

That Event will then behave like any other. You can add, Custom Code, and DB Save actions to it. To save the data you can either create a table with column names that match the PayPal data parameter names* - or you could use the custom code action to use json_encode to collapse the data into a single string and save that instead.

Usually you need the PayPal Listener to respond to PayPal and confirm the transaction details. if that is needed in this setup then you can also add that action and configure it. I would suggest that you do not use the On Success box there though as there seem to be some problems with it. Add the other actions after the PayPal Listener.

Bob

* here's a sample list of parameter names if that helps: business, charset, custom, first_name, handling_amount, ipn_track_id, item_name, item_number, last_name, mc_currency, mc_fee, mc_gross, notify_version, payer_email, payer_id, payer_status, payment_date, payment_fee, payment_gross, payment_status, payment_type, protection_eligibility, quantity, receiver_email, receiver_id, residence_country, shipping, tax, transaction_subject, txn_id, txn_type, verify_sign
techbranch 11 Nov, 2015
I created a form and table called them tournament_registered.
I Added ON IPN, the listener and a DB Save to the correct table.
When I issue a simulated IPN from paypal sandbox I get this error:
IPN was not sent, and the handshake was not verified. Please review your information.
GreyHead 11 Nov, 2015
Hi techbranch,

You need to check why the IPN isn't being sent. That's at the PayPal end I think.

Bob
techbranch 11 Nov, 2015
I am getting closer. I had an error in my notify_url
http://www.onlinefishingtournament.com/index.php?option=com_chronoforms&chronoform=tournament_registered&event=ipn
http://www.onlinefishingtournament.com/index.php?option=com_chronoforms5&chronoform=tournament_registered&event=ipn

See the top one was missing the "5" thus was giving a 404 error.
techbranch 11 Nov, 2015
When I unpublish the form the IPN says it sent correctly from the paypal simulator but when I publish the form it says
IPN was not sent, and the handshake was not verified. Please review your information.
techbranch 11 Nov, 2015
I had to delete the chronoforms cache to get it to work.
Now it seems to be working again
techbranch 11 Nov, 2015
Well, its almost 100% working.
I am having a problem getting the <input type="hidden" name="amount" value="1"> from my PayPal button to show up in my BD Save after the payment has been processed.
my form has the hidden filed "amount", my table has the column "amount" but that column is blank even though the payment is processed the IPN is received and the item_name and item_number are showing.

Its like they dont send the amount back to me
GreyHead 12 Nov, 2015
Hi techbranch,

I recommend that you save the data before the transfer to PayPal so that you can cross-check the amount afterwards. The PayPal docs will tell you what they send back - payment_gross may be what you need.

You can also check what is being sent by adding an Email action to the ipn event and including code like this in the template:
<?php
echo'<div>$_FORM: '.print_r($_FORM, true).'</div>';
?>

Bob
techbranch 13 Nov, 2015
Now that I got the listener to DB Save a table I would also like to update a different tables records with some information I query from that table.
Or trigger a stored procedure that will query that table and count the number of records and update a different table with those results.

Is there a way to DB Read and put in my own code then DB Save but actually update a record on a different table using this form?

OR
Do I need to trigger a stored procedure using the form and if so, how would I execute a stored procedure after the DB Save of the IPN message?

Regards
Sean
GreyHead 13 Nov, 2015
Hi techbranch,

The data that is available is all in the $form->data array - you can use any of this in either a DB Save action and/or a Custom Code action. If you use the DB Save then you can put a Custom Code action before it to prepare the data for saving. But I don't think that you can use a Procedure with a DB Save - I do recall that we had a hack to make a View work in CFv4 and there might be a solution for a procedure in the forums here somewhere.

If you don't or can't use a DB Save action you can call a MySQL query from a Custom Code action something like this:
<?php
$db = \JFactory::getDBO();
$query = "
    INSERT INTO `#__`
       . . .
        WHERE `` = '' ;
";
$db->setQuery($query);
$result = $db->execute();
. . .
?>

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