HandleSpecialURL from PayPal

[quote=223667:@Stuart Travis]Greg:

Actually, I changed it to your second post, and now it uploads. I have the same URL as my “cancel” at PayPal. I am returned to a

webapp.i.com.com

address.[/quote]
Could you post the code that you have in there?

if Request.Path = “http://www.part39.com/Toolbar-Dev/index.cgi/cancel” then

return true

end if

ah. okay that’s part of your problem. Request.Path will only be the part after the .cgi script… so what you want is:

if Request.Path = "cancel" then return true end if

Now, in addition to that, I suspect that Paypal is expecting a valid response, so you probably need to do this:

if Request.Path = "cancel" then Request.HTTPStatus = 200 // OK return true end if

So what is it that Paypal is expecting to do with this URL?

OK…

I now have a ‘clean’ window with

www.wepapp.com/webapp-dev/index.cgi/cancel

as its caption.

I couldn’t use the line Request.HTTPStatus = 200. I got a ‘Request has no member named HTTPStatus’ error.

Now that I am back at my website, how do I navigate to somewhere useful?

Sorry… It’s Request.Status…

Beyond that… I take it from your comment that this is not a callback, but a redirect. It’s the browser that is going to that url? If so, you’re going to need to add something to the url to indicate which user it came from. And because the user has actually left the app, when they come they’ll get a new session, so you’ll have to figure out where they need to be and reconstitute their state.

Right… it’s a redirect.

That leads to my second question that I alluded to at the beginning of this. My understanding is that PayPal sends a bunch of information back embedded in the URL (assuming the transaction was a success or not canceled).

How do you parse that information?

Also… from what I can gather from the online manual… I do need to use HandleSpecialURL. I have added ‘special’ after index.cgi so that I now have:

www.wepapp.com/webapp-dev/index.cgi/special/cancel and
www.wepapp.com/webapp-dev/index.cgi/special/success

I have also changed the PayPal return URLs accordingly and I once again return to a ‘clean’ screen at my website.

ok. Does the PayPal redirect allow you to include an identifier that is specific to the user? Specifically, something that you would send to PayPal when you send the user there which would be echoed back? If so, you could generate a “code”, store the user’s state and send them to PayPal. Then when this callback comes, process the data and then do your own redirect from /special back to the main app and setup the user from what was stored.

I have set a cookie. The cookie is specific to a user.

Just out of curiosity… do you need to know that the action was cancelled on Paypal? If not, you could probably just redirect back to your app and only do something special when PayPal succeeds.

Yes, I would like to know the action was cancelled. There are times when I cancel out and go back to the website just to double-check before I go back to PayPal and finish the purchase.

Also, here is the code I have used to set the cookie:

Session.Cookies.Set(“TestCookie”, TestCookieString)
msgbox TestCookieString

Here is the code I use to read the cookie:

junk = Session.Cookies.Value(“TestCookie”)

junk is empty

If you don’t set an expiration date, the cookie is only good for the current session. Try it this way:

Dim d as new date d.totalseconds = d.totalseconds + 3600 // One Hour Session.Cookies.Set("TestCookie", TestCookieString, d)

The code is actually as appears below:

Session.Cookies.Set(“TestCookie”, TestCookieString)
msgbox TestCookieString

junk = Session.Cookies.Value(“TestCookie”)
msgbox junk

I don’t believe it has time to expire.

According to your statement above, “junk” is empty, which would mean that the cookie expired.

If the user is leaving your app to go to PayPal then it certainly does. Cookies without an expiration date can expire as soon as the user leaves your app or as late as when the user closes their browser or tab. It’s just the way cookies work.

[quote=223624:@Stuart Travis]The above suggestions look promising, but I can’t try them. I am getting the usual message, “An error occurred during Xojo Cloud deployment. Please wait a few minutes and try again.” for yet another weekend.

I am probably shut down until Monday afternoon when customer service get through the stack of emails to mine. I really wish Xojo had somebody working weekends to take care of this. It seems that it happens about every other weekend.[/quote]

This has been solved. Stuart was using an old version of Xojo to upload. Using Xojo 2015r2.3 or higher fixes the problem that he was having.

Thanks Jason. Your suggestion to download and install the latest version did indeed fix the problem. I must have missed the email telling me there was a new version!

Greg:

Here is the code as it now stands:

dim j as string
Dim d as new date

d.totalseconds = d.totalseconds + 3600 // One Hour
Session.Cookies.Set(“TestCookie”, TestCookieString, d)
msgbox TestCookieString
j = Session.Cookies.Value(“TestCookie”)
msgbox j

j is empty.

Is there a way to check to see if the cookie was successfully placed other than trying to read its value? I am not sure which of the methods is not working. Am I not set it correctly, or am I not reading it correctly? Is the cookie actually stored under the name TestCookie? When I search my hard drive for a file by that name, none are present.

I just tried that exact code in the Action event of a button and it worked just fine. Where are you running it from?

I am running from the mouse up event of a button.