Paypal - No Record of Amount Paid in moodle database?

Paypal - No Record of Amount Paid in moodle database?

by Adam Frederick -
Number of replies: 5
Why is there no record of the amount paid in the moodle database for each paypal transaction? Am I missing some impossible/hard hurdle?
Average of ratings: -
In reply to Adam Frederick

Re: Paypal - No Record of Amount Paid in moodle database?

by Martín Langhoff -
Not sure but I would venture to say... it may be because PayPal keeps track of that. Does it not?
In reply to Martín Langhoff

Re: Paypal - No Record of Amount Paid in moodle database?

by Adam Frederick -
hahaha. hahaha. Really? The problem is that I wanted to create a bit of an accounting program based on the moodle database, and it is a little hard to do without a payment record. On the regular paypal site, I only found the ability to download records of transactions based on comma separation, but I am trying to avoid labor. (extraneous) {I could make a pay-based-entrance student the default student role, then give teachers only the permission to assign roles to non-pay-based-entrance students. Then I would run a query that selected all the pay-based-entrance students based on the time the role was created from all the courses that have a price, but the problem when the price of the course is changed and when a student enrolls in the course multiple times between the running of the accounting program. }
I suppose I should look at the paypal developers site. Thanks for the insightful comment. I'll be sure to ask more questions in other forums that can use such insight.
In reply to Adam Frederick

Re: Paypal - No Record of Amount Paid in moodle database?

by Martín Langhoff -
Hi Adam,

sorry - PayPal is the only enrolment plugin I haven't worked with. I _think_ that

- it sends the user to Paypal
- PayPal asks "did you send the user and how much do you want to charge him/her?" via XMLRPC
- Moodle answers based on the cost of the course
- PayPal tells Moodle "transaction complete" via XMLRPC

So if you look at the enrolment type of the user and it says paypal, and you look at the cost of the course you can do your numbers. Except that if the course cost is updated, your numbers are all wrong. sad

> suppose I should look at the paypal developers site.

That's what I would do. I am sure the API gives you a way to ask for transaction records directly, without getting the user to do a CSV download and then an upload to Moodle.

It can probably be a nice extension to the current PayPal plugin big grin are you thinking of writing it so that it can be included in the official release?

In reply to Martín Langhoff

Re: Paypal - No Record of Amount Paid in moodle database?

by Adam Frederick -
Except that if the course cost is updated, your numbers are all wrong -> Exactly, as I mentioned in the "extraneous" part. That and the fact that if a user enrolls in a course twice before the accounting program is run (say a 2 day course),
It can probably be a nice extension to the current PayPal plugin big grin are you thinking of writing it so that it can be included in the official release?>
Eh, if I get anyone asking me to. I'm not the prettiest coder and I haven't even read moodle's coding policies. I tend to make my own connections to the database instead of using moodle predefined database functions. Its also not the biggest thing for me in regards to editing moodle right now.
I am going to try to add a point system to my site, based on various things such as volunteering, in which teachers get a monthly allotted amount of points to give out to students (reset at the end of the month) - the points go towards enrolling in courses that have a cost... There are various other dynamics but back to the paypal thing.
I took a brief look at the paypal enrollment in the process of writing this response and I found: Pretty simply, paypal sends the paypal/ipn.php file a confirmation key, moodle sends it back, paypal responds, moodle reads the response, checks the response against predefined problems, database inconsistencies (in price). Moodle then uses its universal insert_record function with the data object from the paypal info. There is already an attribute within the object on how much was spent. In fact, moodle does a check to make sure that the price spent was the price necessary to enroll:
 145 if ($data->payment_gross < $cost) {
 146 email_paypal_error_to_admin("Amount paid is not enough ($data->payment_gross < $cost))", $data);
 147 die;
 148  149 }
So, there is a really easy way to get the payment information, and it doesn't require me spending time being a do-gooder (apart from writing this). If I am correct about the nature of the insert_record function, it basically takes an object and fills whatever fields in finds in the table named. As such, the only thing needed to get information on the payment amount is to add the field "payment_gross" to the "enrol_paypal" table. Hah, and I thought I was going to have to deal with paypal!... oh wait, that's that ecommerce solution I'm using, doh. Anyway, I think that is the solution but if I am wrong, you can tell me or I will find out when I try it.


In reply to Adam Frederick

Re: Paypal - No Record of Amount Paid in moodle database?

by Eli7 S -

Hi, Could you help me please? I need to do a query with the courses's prices.  And the price payed for the user.

Also I need to know the pay method: Paypal, Credit Card, Pay with Sales Team.

Can you tell me the name of the tables and name of the fields please.

Thanks a lot.