Paypal Sandbox

Paypal Sandbox

by Allen Dino -
Number of replies: 11
Hello everyone.

I've been searching the forums for days and still I haven't found any concrete solution for this (judging by the numerous threads left unanswered by the community):

"Thank you for your payment! Unfortunately your payment has not yet been fullynot yet registered to enter the course "XXXX" Please try continuing to the course in a few seconds, but if you continue to have trouble then please alert the Teacher or the site administrator processed, and you are.."

This happens after I have completed my payment, as buyer, to my merchant sandbox account in Paypal, and have clicked the "Click here to enter your course" button presented by Paypal.

With that over with, a couple of questions:
1.) In Paypal IPN (Instant Payment Notification) option, is it necessary that the <moodle>/enrol/paypal/ipn.php be transmitted in https? I found a few solutions in the forum that shows https instead of the normal http.
2.) I also read in some of the threads here that the Paypal sandbox is consistently changing so there might be problems testing with it. Can we be assured that by "going live," that the enrol script via Paypal will work without the "Thank you-Unfortunately" message and actually enrol the students properly?
3.) Does a hosting service possibly add to this problem? I am currently using Bluehost as our hosting service. Do any of you guys use Bluehost and have also attempted to integrate moodle and paypal? If so, did it work?

I've tried all the possible solutions posted in this forums to no avail. sad

Can anybody, who has the same headache, post their solutions if they were able to fix their's?

Thanks a lot!

Cheers,
Allen
Average of ratings: -
In reply to Allen Dino

Re: Paypal Sandbox

by Alan Barrett -

Your questions...
(1): Outside the sandbox you do not need HTTPS, inside I can't remember.

(2): The non-sandbox stuff does seem to be stable.
(3): Does work with hosting service although you will have seen from one of my Posts that I needed to put in a bug fix when the hosting provider was using Squid proxy.

I have debug code for ipn.php which monitors the IPN request back from Paypal and sends e-mails back from the server to an e-mail address to let one monitor any errors. Nearly all errors in IPN will result in the error message that you get.

I have attached the debug version of ipn.php if you are interested in looking at debug output. You will need to change all the "yourmail@yourdomain.com" to your own e-mail. This debug code matches the latest ipn.php in CVS.

I would be willing to help interpret debug output.

    Alan.

In reply to Alan Barrett

Re: Paypal Sandbox

by Allen Dino -
Hi Alan,

Thanks for the quick reply. WIll test this out and give you feedback soon!

Cheers,
Allen
In reply to Alan Barrett

Re: Paypal Sandbox

by Allen Dino -
Hi Alan,

Here's the debug emails:

Subject: In ipn.php Before fsockopen(), paypaladdr:www.sandbox.paypal.com
Body:
cmd=_notify-validate&mc_gross=5.00&protection_eligibility=Ineligible&payer_id=VFA97PY43QQ9E&tax=0.00&payment_date=01%3A10%3A24+Nov+21%2C+2008+PST&payment_status=Pending&charset=UTF-8&first_name=Test&option_selection1=allen&mc_fee=0.45&notify_version=2.5&custom=3-2&payer_status=verified&business=allend_1221726249_biz%40gmail.com&quantity=1&verify_sign=A3xf-GiVpGWuNGjBLNPW92LORyGLABzbnY75N0C9PgOZ1fAJpixQgr.U&payer_email=allend_1221728337_per%40gmail.com&option_name1=User&txn_id=6MY03729JC105561R&payment_type=instant&last_name=User&receiver_email=allend_1221726249_biz%40gmail.com&payment_fee=0.45&receiver_id=FBRCRVABGZCAW&pending_reason=paymentreview&txn_type=web_accept&item_name=Animahenasyon+2008&mc_currency=USD&item_number=Anim2008&residence_country=US&test_ipn=1&payment_gross=5.00&shipping=0.00
INCOMING POST WAS
KEY:mc_grossVALUE:5.00END
KEY:protection_eligibilityVALUE:IneligibleEND
KEY:payer_idVALUE:VFA97PY43QQ9EEND
KEY:taxVALUE:0.00END
KEY:payment_dateVALUE:01%3A10%3A24+Nov+21%2C+2008+PSTEND
KEY:payment_statusVALUE:PendingEND
KEY:charsetVALUE:UTF-8END
KEY:first_nameVALUE:TestEND
KEY:option_selection1VALUE:allenEND
KEY:mc_feeVALUE:0.45END
KEY:notify_versionVALUE:2.5END
KEY:customVALUE:3-2END
KEY:payer_statusVALUE:verifiedEND
KEY:businessVALUE:allend_1221726249_biz%40gmail.comEND
KEY:quantityVALUE:1END
KEY:verify_signVALUE:A3xf-GiVpGWuNGjBLNPW92LORyGLABzbnY75N0C9PgOZ1fAJpixQgr.UEND
KEY:payer_emailVALUE:allend_1221728337_per%40gmail.comEND
KEY:option_name1VALUE:UserEND
KEY:txn_idVALUE:6MY03729JC105561REND
KEY:payment_typeVALUE:instantEND
KEY:last_nameVALUE:UserEND
KEY:receiver_emailVALUE:allend_1221726249_biz%40gmail.comEND
KEY:payment_feeVALUE:0.45END
KEY:receiver_idVALUE:FBRCRVABGZCAWEND
KEY:pending_reasonVALUE:paymentreviewEND
KEY:txn_typeVALUE:web_acceptEND
KEY:item_nameVALUE:Animahenasyon+2008END
KEY:mc_currencyVALUE:USDEND
KEY:item_numberVALUE:Anim2008END
KEY:residence_countryVALUE:USEND
KEY:test_ipnVALUE:1END
KEY:payment_grossVALUE:5.00END
KEY:shippingVALUE:0.00END

Subject: In ipn.php VALID PAYMENT!, status: Pending, reason: paymentreview
Body: Test

Hmmm. Something is telling me that "paymentreview" is something I should have missed out in the Paypal configurations?

Thanks,
Allen
In reply to Allen Dino

Re: Paypal Sandbox

by Alan Barrett -

Yes it sounds like your configuration requires manual approval of payments. It is a while since I setup Paypal so I cannot remember where the configuration for this is.

    Alan.

In reply to Alan Barrett

Re: Paypal Sandbox

by Allen Dino -
Ok, I'll check it out. Maybe this might be one of the causes that some of the users are having and were unable to solve.

The ipn script you gave me showed me what I needed to do next. Thanks a lot for this! I'll get back on this thread once I have moved further.

Cheers,
Allen
In reply to Alan Barrett

Re: Paypal Sandbox

by Allen Dino -
Hello everyone,

I've finally got to solve this issue. Seems I was the one at fault since I ENABLED the Payment Review feature of my PayPal business sandbox account. To disable the Payment Review feature, log in to you sandbox account, click "Test Accounts," and from there, you will see the list of test accounts you have. In that list, there is a column entitled "Payment Review" and you will see if each of your test accounts have this feature enabled/disabled.

Hope this helps anyone with the same issue that I have.

Alan,

Thanks for this great script! It really helps debug the IPN notices. Just a followup question though, when using your IPN script, enrollees will properly pay thru PayPal, and after that, they will be enrolled in Moodle. But, when I revert back to the original IPN of moodle, I still get the "Thank you-Unfortunately" message. In you IPN code, did you just add the email notifications and didn't change anything else? I'll try to compare your code with the orginal one also.

Thanks again!

Cheers,
Allen
In reply to Allen Dino

Re: Paypal Sandbox

by Alan Barrett -

I am pretty sure that I just added debug code and everything else is the same. But you should check. If there is any difference it could be caused by the extra time it takes to send the e-mails, but that would not seem to explain any difference in outcome.

    Alan.

In reply to Alan Barrett

Re: Paypal Sandbox

by Allen Dino -
Hi Alan,

As always, thanks for the quick reply. I've compared the original IPN code with yours, and you're right, there are no differences...

I've had a few successful enrollments using your script, but recently, the enrollments via you script results in a "thank you-unfortunately" message BUT the student still gets enrolled. black eye

Here are the email messages from your script, in chronological order:

Subject: In ipn.php Before fsockopen(), paypaladdr:www.sandbox.paypal.com
Body:
CONTENTS OF POST: POST /cgi-bin/webscr HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 847

cmd=_notify-validate&mc_gross=2.00&protection_eligibility=Ineligible&payer_id=SCYV3MR2C3SPQ&tax=0.00&payment_date=22%3A32%3A30+Nov+26%2C+2008+PST&payment_status=Completed&charset=windows-1252&first_name=Test&option_selection1=Allen+Dino&mc_fee=0.36&notify_version=2.6&custom=12-2&payer_status=verified&business=allend_1221726249_biz%40gmail.com&quantity=1&verify_sign=An5ns1Kso7MWUdW4ErQKJJJ4qi4-AEmrhlhzH7My3bWMWbOcdJAHQ9Pr&payer_email=allend_1221728337_per%40gmail.com&option_name1=User&txn_id=74737182WS472733A&payment_type=instant&last_name=User&receiver_email=allend_1221726249_biz%40gmail.com&payment_fee=0.36&receiver_id=HLLT3CQH8L4GA&txn_type=web_accept&item_name=Animation+Congress&mc_currency=USD&item_number=AnimationCongress&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=12-2&payment_gross=2.00&shipping=0.00
INCOMING POST WAS
KEY:mc_grossVALUE:2.00END
KEY:protection_eligibilityVALUE:IneligibleEND
KEY:payer_idVALUE:SCYV3MR2C3SPQEND
KEY:taxVALUE:0.00END
KEY:payment_dateVALUE:22%3A32%3A30+Nov+26%2C+2008+PSTEND
KEY:payment_statusVALUE:CompletedEND
KEY:charsetVALUE:windows-1252END
KEY:first_nameVALUE:TestEND
KEY:option_selection1VALUE:Allen+DinoEND
KEY:mc_feeVALUE:0.36END
KEY:notify_versionVALUE:2.6END
KEY:customVALUE:12-2END
KEY:payer_statusVALUE:verifiedEND
KEY:businessVALUE:allend_1221726249_biz%40gmail.comEND
KEY:quantityVALUE:1END
KEY:verify_signVALUE:An5ns1Kso7MWUdW4ErQKJJJ4qi4-AEmrhlhzH7My3bWMWbOcdJAHQ9PrEND
KEY:payer_emailVALUE:allend_1221728337_per%40gmail.comEND
KEY:option_name1VALUE:UserEND
KEY:txn_idVALUE:74737182WS472733AEND
KEY:payment_typeVALUE:instantEND
KEY:last_nameVALUE:UserEND
KEY:receiver_emailVALUE:allend_1221726249_biz%40gmail.comEND
KEY:payment_feeVALUE:0.36END
KEY:receiver_idVALUE:HLLT3CQH8L4GAEND
KEY:txn_typeVALUE:web_acceptEND
KEY:item_nameVALUE:Animation+CongressEND
KEY:mc_currencyVALUE:USDEND
KEY:item_numberVALUE:AnimationCongressEND
KEY:residence_countryVALUE:USEND
KEY:test_ipnVALUE:1END
KEY:handling_amountVALUE:0.00END
KEY:transaction_subjectVALUE:12-2END
KEY:payment_grossVALUE:2.00END
KEY:shippingVALUE:0.00END

Subject: In ipn.php VALID PAYMENT!, status: Completed, reason:
Body:
Test

Subject: In ipn.php Worked Fully!!!!!!!!!!!!!!!
Body:
Test

Subject: In ipn.php After while (!feof()) loop, countfgets: 12,lenfullstring: 932
Body:
HTTP/1.1 200 OK
Date: Thu, 27 Nov 2008 06:32:39 GMT
Server: Apache/1.3.33 (Unix) mod_fastcgi/2.4.2 mod_gzip/1.3.26.1a mod_ssl/2.8.22 OpenSSL/0.9.7e
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=3iwhWd6TGp4ihsMamJP9TP2iBBrnMvTy6LBWuOO16onVUDeucwrqov0aN4CZYG6xm3kEgJrlMJ7QaheEJljVZXZvAUc8BxnKY3Mkd31fpGWm3HRqBiSZ9jSxS5hRGJUoGUhhlG%7c86OVjA8nsjCkgSTgWh4wYxiU5WRt9uD0FyJP_iM6sBdRX2-8Z2ai8hKx21bUrnhkSFvY80%7clTHWzPsOj6UqwcMArUyNaLBP08KxXLoQhxx1PTrcVwUmqul1oNR3U2juizExoyIjiuaDcG%7c1227767560; domain=.paypal.com; path=/
Set-Cookie: cookie_check=yes; expires=Sun, 25-Nov-2018 06:32:40 GMT; domain=.paypal.com; path=/
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/
Set-Cookie: navlns=0; expires=Wed, 22-Nov-2028 06:32:40 GMT; domain=.paypal.com; path=/
Set-Cookie: Apache=10.191.196.11.154081227767559753; path=/; expires=Wed, 15-Oct-02 00:04:23 GMT
Connection: close
Content-Type: text/html; charset=UTF-8

VERIFIED

It gets frustrating when some of the tests result in complete payment and others, I receive that dreaded "thank you-unfortunately" message. Also, I reverted back to the original ipn.php and made the same enrollment process and the same thing happened --- "thank you-unfortunately" message, then after I click continue, the student enrolled successfully.

I keep enrolling the same student for testing purposes, I just unenroll him from the course when it's time to make another enrollment-paypal test.

Warm regards,
Allen
In reply to Allen Dino

Re: Paypal Sandbox

by Alan Barrett -

What seems to be happening here is that the IPN callback from Paypal (ipn.php) is happening after the return to the user (return.php). So when return.php gets control it sees the payment has not (yet) been received.

There are a number of options here...

- Use the the real Paypal and see does the problem disappear. Other people are using the plugin live successfully.

- Change the wording of lang/en_utf8/moodle.php line:1169 $string['paymentsorry'] to reflect the fact that the payment is likely to have succeeded (rather than failed) and the user should continue to the course.

- Code could be added to return.php to keep refreshing the page until payment is complete.

    Alan.

In reply to Alan Barrett

Re: Paypal Sandbox

by Allen Dino -
Hi Alan,

You're 2nd option was actually what I was thinking of doing since it's the easiest workaround. big grin

As our organization is yet to have our actual "go live" account, I have yet to test it on the live version. Crossing my fingers, I do hope that the headaches I've been encountering during the sandbox tests with Paypal will be gone on the live one.

Further research brought me to a lot of dead ends on this issue and I am really thankful that there are people like you in the community who relentlessly help other stuck developers. approve

Another weird thing though, even if the sandbox business account's IPN feature is disabled, the IPN still works in moodle. wide eyes

Cheers,
Allen
In reply to Allen Dino

Re: Paypal Sandbox

by Sam N -
In the unlikely event that you read this, thanks for your post - solved my IPN problem after ages of looking - Payment Review in the sandbox! :D

Thank you so much for sharing