Hello, I would be sure that someone has come across this already. I hope so.
I am writing a handler for PayPal IPN. Actually, a little easier that I 
thought it would be except for one issue: -

request.vars creates a Storage object, but the key:value pairs are not in 
the same sequence as they are in the URL. It almost seems to be a 
randomised order.
For 99.9% of occasions this is OK. However, as part of the  IPN handler 
authentication, PayPal expects to receive the URL (var) string back exactly 
as they posted it to my application, specifically with the vars in the same 
order. Their documentation re-states this requirement in multiple places !.
I suspect (although I don't know), that PayPal is simply matching the 
return var string to the one it posts. i.e. not actually wasting server 
cycles with intelligent var matching :-(
I am also not on a LIVE server so, although PayPal have a test sandbox, it 
is not a lot of use at this point.

I cannot identify any other function in web2py to pull the raw URL string. 
I think the only function is request.vars.
I note that request.args has an index method (i.e.  request.args(i) ) so 
that the args can be pulled in sequence. But request.vars does not have 
this method.

To test my random order theory, here is a test function()

import urllib
def sample():
#sample of ipn_handler code
    getvars=request.vars
    test1=urllib.urlencode(dict(getvars))
    
    getvars=request.vars
    test2=''
    for item in getvars:
        test2=CAT(test2,'&',item,'=',getvars[item])
    
    test3=request.vars
    
    return dict(test1=test1,test2=test2,test3=test3)

and the view (extract)....
test1: {{=test1}}<br />
test2: {{=test2}}<br />
test3: {{=test3}}<br />

So, if my url vars are as follows:-
?a=11&b=22&c=33&d=44&e=55&f=66&g=77&h=88

...this is what the view shows.
test1: a=11&c=33&b=22&e=55&d=44&g=77&f=66&h=88
test2: &a=11&c=33&b=22&e=55&d=44&g=77&f=66&h=88
test3: <Storage {'a': '11', 'c': '33', 'b': '22', 'e': '55', 'd': '44', 
'g': '77', 'f': '66', 'h': '88'}>

You can see that I have testing two ways to create a return var string 
(test1 and test2), and also shown the Storage object (test3)
test1, test2 and test3 show an identical sequence. But it is different to 
the actual posted URL var sequence.
BTW - the actual IPN string is not determiistic, so it is not like I can 
manually build a return string.

Thanks!
Simon



I note that on web2pyslices, there are (I see) two slices (for PayPal IPN) 
that also appear to generate a randomised return string. According to the 
PayPal docs, that string will be rejected.

So, what on earth am I doing wrong? Or perhaps there is another way to pull 
the vars from the URL? (request.url doesn't pass the vars)
Or has someone a different way to recreate the URL for PayPal IPN?

Thanks
Simon

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to