Solved

Paypal, mysql, and php

Posted on 2011-03-14
9
587 Views
Last Modified: 2013-12-13
Hi,

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?
0
Comment
Question by:sky479
9 Comments
 
LVL 19

Expert Comment

by:Bardobrave
ID: 35127326
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.
0
 
LVL 14

Assisted Solution

by:Scott Madeira
Scott Madeira earned 500 total points
ID: 35128695
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.
0
 

Author Comment

by:sky479
ID: 35129245
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.
0
 

Author Comment

by:sky479
ID: 35130333
Btw...do I need the  ipn-listener.php? I have the ipn.php but I don't know if they are similar or not.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:sky479
ID: 35130404
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?
0
 
LVL 14

Accepted Solution

by:
Scott Madeira earned 500 total points
ID: 35131352
The sample ipn-listener code from the PayPal web site (https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNImplementation) 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 sitepoint.com 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.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 36404366
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
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 37313466
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP and Soap 3 30
What does "flush tables;" do exactly? 7 47
wordpress issue 2 24
inserting while loop results 2 12
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now