News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[4872] PayPal Subscription Sandbox Issues (2.0 RC2)

Started by Shotster, December 30, 2009, 11:26:30 PM

Previous topic - Next topic

Shotster

I'm trying to get paid subscriptions to work, but I can't seem to get the process to complete. I have a PayPal developer account and am using the sandbox for testing. If I use PayPal's IPN simulator, it says the IPN is sent successfully, so subscriptions.php seems to be communicating properly with PayPal. However, if I go through a subscription process for a forum test user, the subscription says "Pending Payment" with an end date of "N/A" for a 1 year subscription.

It seems as though the IPN is being handled but that the database isn't being updated. Has anyone gotten paid subscriptions to work using PayPal's sandbox?

-Steve

Shotster

Quote from: Shotster on December 30, 2009, 11:26:30 PMHas anyone gotten paid subscriptions to work using PayPal's sandbox?

Ok, I'll answer my own question... Yes, I have!

There are two places in the paypal_payment class of Subscriptions-PayPal.php where for validation purposes the posted business parameter (i.e. your PayPal email address posted via PayPal's IPN) is compared to the e-mail address entered into SMF's paid subscriptions settings through the UI. Thus, if you're using the sandbox (and hence the fictional email address set up through your PayPal developer account) for testing but have entered your actual email address into the SMF subscription settings, the two strings (email addresses) will never match, and validation will fail. The two spots are in the isValid  and precheck methods of the class and begin with a conditional statement like so...

   if ($modSettings['paypal_email'] != $_POST['business']...

So you either have to remember to change to the test email address through the UI or use a constant whose value changes depending on whether you're in test mode or not. I can now go through the subscription process successfully with immediate activation via IPN using PayPal's developer sandbox.

This was not obvious to figure out since the failed validation results in a paid_unknown_transaction_type error in subscriptions.php, which tripped me up initially.

And by the way, I find the terminology confusing as well since PayPal also uses the term "transaction type" (identified by the post parameter txn_type) to mean something quite different. IMO, the SMF variable (and error message) would be more appropriately named "gateway type" because its value is paypal for a PayPal transaction.

Anyway, I hope this saves someone else some anguish.

-Steve

Arantor

Thanks for the comments :)

Not sure whether to move this to Coding Discussion or Tips & Tricks to be honest, though ;)

I have flagged your comments up to the devs, with regards to the terminology and error message, and hopefully we can get some documentation into the manual in time for SMF 2.0 final.

karlbenson

Thankyou for your efforts.

I have moved this to bug reports for the devs to have a look at, test, and make any necessary changes.

Joshua Dickerson

I tracked it because I am pretty sure this hasn't been resolved. It seems more like an issue for development though. So, don't expect anything anytime soon (as you can tell by how long it took to get it tracked).
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Arantor


Advertisement: