Paypal, mysql, and php


I am new here, and I joined to get some help. What I have so far is a reward shop. What I need is  a donation system where users who donate money to help support the server receives virtual points.

My problem is I am unable to get the donation system to set up! I need to be able to log the username of the person donating and the amount. Then from there update my sql database and award the donor with donor points. But so far I have no luck with the php coding or the paypal IPN. If someone can help me get this project going it would be great!

Edit: I can donate and it updates to my database. but the thing is I don't know how to make it so it updates the right account . My donate table is different from my account table. And all it stores into the paypal table is the transaction id, amount, email, etc. How would I go about programming a code in php where it checks the session to see if the person is logged in, if so then it sends that data(username, id, email) to database. When paypal sends the info back it verifys and updates the points to the right account. Where would I go about doing something like this?
Who is Participating?
Scott MadeiraConnect With a Mentor Commented:
The sample ipn-listener code from the PayPal web site ( shows you the minimum structure to receive the IPN message from PayPal, send the acknowledgment back to PayPal and shows you where you need to write code to validate the messages and save the information to the database.  You need to have this function in your system.   I don't know what the ipn.php script you refer to is doing so I can't comment on whether you need both or not.

As for hiring somebody to do it?  I'd think it would be a day or two of effort if they had access to all of your code and your servers.  One place to search would be to see who may be available.  What you want is not very complicated.  You may be able to find a college kid that would do it for $20/hr or so and get it done pretty quickly.

I don't know if EE has a projects / employment section or not.
Let's see... If I'm understanding you right the problem is that your donation page, after returning from paypal service, loses session user parameters and you don't know how to associate the donation to a user account.

Usually payment platforms are base upon webservices that expect some parameters related to transaction and return different values depending on the result of the transaction.

I supose you probably are sending the execution directly to paypal, and when their service returns your page has lost session data.

What you need to do is:

1) Ask for your users to log onto your system.
2) Send to paypal service the transaction data without losing your current session environment (use an AJAX call, include paypal form inside your page code if user interaction is required for transaction or simply open it in a new window).
3) On paypal service return, from your code, check the value of the response and save data to your database accordingly.
Scott MadeiraConnect With a Mentor Commented:
I will assume you are a php person and can write code to do the things that need to be done.  If not, then you are biting off more than you can chew with your project.

Here is how I would approach the problem.

1. When a person makes a donation they need to provide three things:  a username, a password and an amount.

2. Take the username and password and create an account for the person in the account table if they don't have one already.  If the username is already taken then they will need to choose another username.  Also, in that table you need to have a unique key field (userID, for example) as the primary key on the table.  you can add address, phone, etc. if you want that info too.

3. Create a donations table that has the following fields (at a minimum):  donationID (primary key and unique), userID (the userID from the account table of the person donating), the amount donated, txnID (the paypal transaction ID), Payment status (status of the donation.)

4. Send the person to PayPal to pay and in the message sent to PayPal include the donationID so you can link the donation to the donations table. I think the IPN field that you can use for this is item_name and item_number but you will need to check the IPN documentation to be sure.

5. In your IPN script that you write you will be looking for the item_number to match the IPN message coming back from PayPal with what you stored in your donation table.  you can update the payment status in your table based on the payment status of the IPN message.

Every time somebody makes a new donation you add a new row to the donations table.

There are a huge number of other details to consider but this outline should get you started in the right direction.  there are lots of IPN scripts available online to help with the post-processing of the payment.
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

sky479Author Commented:
Thanks a lot I will try both of your methods and see how it goes. I've been trying for days so I thought I should seek professional help. I got a work frame to work with now, before I was in the dark searching everywhere on what to do. Thanks again and I am going to try your 2 methods and see what I come up with. Will update you guys on how I did it and see if it works.
sky479Author Commented: I need the  ipn-listener.php? I have the ipn.php but I don't know if they are similar or not.
sky479Author Commented:
Okay, if I where to hire someone to help me with this where would I get the help and how much do you guys think it will cost me?
Ray PaseurCommented:
Not sure if this question is still active, but I have done exactly the thing you are talking about for my church.  We accept donations via PayPal.  In practical terms, we receive about as much money via PayPal as we receive via cash in the collection plate.

We have a separate bank account associated with PayPal donations.  The PayPal IPN script is used to keep a log of donations (although PayPal keeps this information for us, too).  Information available in the IPN script includes the donor's email address, and given the anonymity of church donations, this is all we use to keep track of the donors and the amounts.  Our log of donations enables us to give the donors quarterly and annual statements.

You cannot check a client session in the IPN script.  It is an asynchronous script that is not associated with a client session.  So your design that associates points with donations must use something other than the session.  That is why we use the email address from PayPal as the client identifier.

HTH, ~Ray
Guy Hengel [angelIII / a3]Billing EngineerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.