PAYPAL ERROR: Transaction is being repeated!

PAYPAL ERROR: Transaction is being repeated!

by Ric Morte -
Number of replies: 4

Hi,

Using Moodle Moodle 2.4.3 (Build: 20130318)

This error seems to be appearing in a number of installations. I am using the PayPal sandbox and, apart from this reported error, everything elseappears to work correctly:

  • The payment is credited to the business account
  • The payment is debited to the customer account
  • The website reports payment successful (see attached image)
  • The user is enrolled to the course

Perhaps as a consequence of this error neither the admin nor the newly-subscribed user receives emaikl notifications. Instead the admin receives the "PAYPAL ERROR: Transaction <tx code> is being repeated!" email with the following entries:

GCSE science online:  Transaction failed.

Transaction 76C412249N7239933 is being repeated!

mc_gross => 10.00
protection_eligibility => Ineligible
payer_id => 9M39WH4N3CCG4
tax => 0.00
payment_date => 06:08:34 May 07, 2013 PDT
payment_status => Completed
charset => windows-1252
first_name => Ian
option_selection1 => <User Name Deleted>
mc_fee => 0.54
notify_version => 3.7
custom => 6-2-4
payer_status => verified
business => <business e-mail address deleted>
quantity => 1
verify_sign => AiKZhEEPLJjSIccz.2M.tbyW5YFwA6cwNgwye3KyZfntvOmptmc9Uato
payer_email => <customer e-mail address deleted>
option_name1 => User
txn_id => 76C412249N7239933
payment_type => instant
last_name => Buy
receiver_email => <business e-mail address deleted>
payment_fee => receiver_id => 8NNQF4NW39H98 txn_type => web_accept item_name => A Test Course mc_currency => GBP item_number => ATC residence_country => GB test_ipn => 1 handling_amount => 0.00 transaction_subject => 6-2-4 payment_gross => 10.00 shipping => 0.00 ipn_track_id => 9c8ffb1ac73ce userid => 6 courseid => 2 instanceid => 4 payment_currency => GBP timeupdated => 1367932154

The code controlling this is here (moodle/enrol/paypal/ipn.php):

if ($existing = $DB->get_record("enrol_paypal", array("txn_id"=>$data->txn_id))) { // Make sure this transaction doesn't exist already
message_paypal_error_to_admin("Transaction $data->txn_id is being repeated!", $data);
die;
}

I repeated thhe PayPal for another new user, brand new account. The txn_id is different for the two transactions, so something is adrift with the code. 

I've checked the forum and there does not appear to be a resolution for this error. Either way I'd like to know why it is happening.

Until there is a resolution I shall try commenting-out that section of code to see if it will run to completion (or just remove the "die").

I'll report back if this is a suitable temporary hack. In the meantime any help would be much appreciated.

Thanks,

Ric

Attachment 2013-05-07_140924.png
Average of ratings: -
In reply to Ric Morte

Re: PAYPAL ERROR: Transaction is being repeated!

by Ric Morte -

Update:

I did the hack mentioned previously.

The PayPal emails are being sent to the payer and the payee.

The admin receives no notification other than the repeat transaction email (they have been set to receive notifications and I would have expected a "new user (ABC) has enrolled on course (XYZ)" type of email.

There are three entries in the enrol_paypal table - which also seems correct.

Out of my depth now until someone with greater knowledge than me can wade in...

Cheers,

Ric

In reply to Ric Morte

Re: PAYPAL ERROR: Transaction is being repeated!

by Struan McCallum -

The problems only just started happening recently and it affected all of my Moodle installations that have Paypal enrolment. The payment is processed on the Paypal side but for whatever reason Moodle isn't recognising the Paypal payment to allow enrolment of the student.

Have tried to comment-out those lines as well as I have encountered a series of problems seemingly linked to ipn.php. But no success.

Trying to get in contact with Paypal for a possible resolution (if one exists).

In reply to Ric Morte

Re: PAYPAL ERROR: Transaction is being repeated!

by Malcolm Silver -

Hi

I have just set up a course and am getting the same emal.  It doesn't seem to affect anything else and the payment and enrollment goes through.  I am using a Joomla/Moodle setup via Joomdle.

I am reluctant to make any hacks at this stage as I cant risk unforseen problems occurring but would be interested in a way to solve this.

I am using moodle 2.5+

Malcolm Silver

In reply to Malcolm Silver

Re: PAYPAL ERROR: Transaction is being repeated!

by James Cruickshank -

If anyone is still having this problem, I found another discussion that lead me to a solution for this problem

https://moodle.org/mod/forum/discuss.php?d=177130

Basically it seems that the error is being caused by the calls to message_send() in the ipn script. If this call fails, it causes the ipn script to fail without returning the 200 OK response that paypal requires. Hence the repeated transaction.

Anyway, I found that if I made the changes suggested in the above thread (see the post by James Snell where he describes the helper function attempt_message_send() ) then the ipn.php script works fine and I don't get the transaction repeated messages anymore

Jim