Return URL after paypal is encoded and doesn't work

Started by bjornforum, December 06, 2015, 10:06:26 AM

Previous topic - Next topic

bjornforum

Hi!

I've been testing with paid subscriptions, but I run into an error:

When a test user makes a payment using paypal, he returns to the forum with the following URL:

http://forum.abc/index.php?action=profile%3bu%3d257%3barea%3dsubscriptions%3bsub_id%3d3%3bdone

This lands him on the index, without any info about the payment.

If I decode the URL to
http://forum.abc/index.php?action=profile;u=257;area=subscriptions;sub_id=3;done
the user returns to the right page confirming the payment.

In the first case the user and forum owner also get an error email:

QuoteDe onderstaande fout is opgetreden bij het afsluiten van een betaald abonnement. De fout is hieronder weergeven:
---------------------------------------------------------------
Het afhandelingsscript voor betaalde abonnementen kon geen abonnementslogingang vinden voor het lid met lid-ID 257 en abonnement-ID: 3

Met vriendelijke groet,
Freely translated from dutch to english: the managing script for paid subscriptions couldn;t find a slot entry for member with id 257 and subscription id 3.

Anyone an idea on how to fix this?

Thanks
Björn

Sir Osis of Liver

The return url takes the subscriber back to the board index after payment is completed, but should not be throwing an error.  The hex codes should not cause any problems.  Is the subscription activated after successful payment?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

bjornforum

Yes it is activated but that is due to the IPN. It takes a minute or so after returning to the forum, so it is not direct on return (that's why my conclusion is that it is IPN)

With the hex codes you don't see an error while returning to the forum, but you do get the error in the email. You also don't get any confirmation on the forum.

With the correct URL you see the confirmation that the subscription is succesful.

Sir Osis of Liver

The return link at PayPal seems to add the hex code.  When subscriber is returned to forum, or uses PayPal's return link, it redirects to board index, not subscription confirmation.  Don't know why you're seeing that, or why it's generating errors.

Link to your forum?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters


Sir Osis of Liver

Looks like a straightup 2.0.11 install.  If you can pm temporary admin access, will take a look when I get back on tonight.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

Ok, set up a TestSub (€0.10/1 day), payment is successful, returns to board index, subscription is activated, no error.  PayPal substitutes hex codes in the return url, but this shouldn't and doesn't cause an error.

You have a lot of mods installed, the two I see that may be problematic are Pretty URLs and Tapatalk.  You're also getting a lot of 404 errors looking for robots.txt in your forum root, and some missing .js files that appear to be mod related.  But TestSub works correctly, I'm not seeing your problem. 

The email is being sent, but forum is not logging a corresponding error.  Been a long time (years) since I've seen this error email,  would have to pick through the code to find it.  Only admins should receive it, not the subscriber, unless subscriber is also admin.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

#7
Have you received any emails containing the following?

Quote
Het afhandelingsscript voor betaalde abonnementen kon geen abonnementslogingang vinden voor het lid met lid-ID 623 en abonnement-ID: 4

I received what appears to be the correct new subscription confirmation that is sent to admins.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

bjornforum

Hi,

thanks for your extensive testing. The mail you got is actually the error as in the first post:

Freely translated from dutch to english: the managing script for paid subscriptions couldn't find a slot entry for member with id 257 and subscription id 3.

If you set a mail message for the customer in the subscription page, they will also get this error in stead of the set mail message. That's why I currently don't have a 'thank you' mail set.

Also, it is true you don't get any errors on returning, but you shouldn't return to the index but to the subscription success page as in the screenshot below:


(Thanks for your payment. As soon as the payment is verified the subscription will be activated)

You can see this screen if you go to http://www.fpv-racing.nl/index.php?action=profile;u=623;area=subscriptions;sub_id=4;done

It seems somehow Paypal is getting the wrong URL to return to after payment. I could try replacing the ; in the url with & maybe, but where is this URL generated?

Thanks
Björn



bjornforum

That was it!

I replaced the ; in

$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done');


with &:

$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile&u=' . $memID . '&area=subscriptions&sub_id=' . $context['sub']['id'] . '&done');


in /Sources/Profile-Actions.php

Now I return to the success page as it should. Seems Paypal is the one that is encoding the ; in return URL's. Probably because it's such an uncommon character in URL's.

Thanks for your help!
I'll refund your test purchases right away.

Björn

Sir Osis of Liver

Um, well ......

Actually, you've discovered a problem that I don't believe anyone here was aware of (certainly not me), and I've replicated it on a test install.  The test subscriptions I did on your forum worked correctly, and sent the correct subscription notification to admin.  I did not receive the error email, and still don't know what that's about.  But on completing payment, PayPal return link takes subscriber back to board index, and has done so for quite some time.  I had forgotten about the payment confirmation page.  If the ; or = characters in any link are converted to hex codes, SMF ignores the action and returns to board index.  PayPal converts ; or = to hex, and that causes the link to fail and go to board index.  PayPal does not convert & to hex, SMF reads the link normally, and goes to payment confirmation.  At some point PayPal must have changed the way they process the return link, and since the subscription still works, no one noticed the difference.  I will report this as a bug, it should be easy to fix.

Thanks for bringing this to our attention.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

bjornforum

Haha ok glad to be of help :P

I only got the error mails when I had a confirmation email set up in the settings (the one a customer receives on successful subscription). When I removed those texts I didn't get the error mails anymore.

The specific fix indeed is quite easy, but it might be smart to start converting all links with ; to & since it's more commonly accepted.

Looking

I've started this: Paid Subscriptions Bug? as there seems to be other issues related to this as well. As pointed out there were no notification Emails sent either as should be sent if something happens.

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: