Advertisement:

Author Topic: [4872] PayPal Subscription Sandbox Issues (2.0 RC2)  (Read 8654 times)

Offline Shotster

  • Semi-Newbie
  • *
  • Posts: 50
[4872] PayPal Subscription Sandbox Issues (2.0 RC2)
« on: December 30, 2009, 11:26:30 PM »
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
« Last Edit: November 13, 2011, 10:56:49 AM by Joshua Dickerson »

Offline Shotster

  • Semi-Newbie
  • *
  • Posts: 50
Re: PayPal Subscription Sandbox Issues (2.0 RC2)
« Reply #1 on: January 01, 2010, 10:19:50 PM »
Has 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,401
    • StoryBB/StoryBB on GitHub
Re: PayPal Subscription Sandbox Issues (2.0 RC2)
« Reply #2 on: January 01, 2010, 10:24:45 PM »
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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline karlbenson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,629
  • Gender: Male
    • Criminal Brief UK
Re: PayPal Subscription Sandbox Issues (2.0 RC2)
« Reply #3 on: January 02, 2010, 10:11:04 AM »
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.

Offline Joshua Dickerson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,777
  • Gender: Male
    • joshuaadickerson on GitHub
    • joshuaadickerson on LinkedIn
Re: [4872] PayPal Subscription Sandbox Issues (2.0 RC2)
« Reply #4 on: November 13, 2011, 10:57:31 AM »
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).
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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,401
    • StoryBB/StoryBB on GitHub
Re: [4872] PayPal Subscription Sandbox Issues (2.0 RC2)
« Reply #5 on: January 09, 2014, 10:53:09 PM »
Moved to https://github.com/SimpleMachines/SMF2.1/issues/1168 so we don't forget it in 2.1
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.