Re: response and post in django

24 views
Skip to first unread message
Message has been deleted

Bill Freeman

unread,
Mar 12, 2012, 2:57:20 PM3/12/12
to django...@googlegroups.com
The straightforward thing is to use urllib2. The tricky thing is that
the thread that got the post from them in the first place will be
blocked waiting for their response.

But are you understanding the API correctly? I would expect the
"VERIFIED" to either be in their POST to your listener (to indicate
that the payor's payment method is valid), or that it would be in your
response to that POST to tell paypal that this looks like a valid
payment (the payment amount or item quantities haven't been hacked,
etc.).

But you could be right.

Bill

On 3/12/12, hack <scott...@gmail.com> wrote:
> I read the paypal ipn docs, and think I understand the procedure for
> processing payments.
> The only issue I have is that I am not 100% certain how to do this via
> django.
>
> Basically you setup a listener http://mysite.com/mylistener/, and when
> someone makes a payment paypal responds by notifying your litener. (ie
> - http://mysite.com/mylistener/?paypalparms=somepaypalstuff&blah=blah
>
> So I then access all the parms and verify them. However, the place where
> I'm stuck is how exactly do I programmatically execute a post back to
> paypal to confirm my receipt and how do I obtain their response object to
> view response.content? Basically I need to view the content of the body to
> see if it contains VERIFIED, etc. Django seems a little different than
> java servlets, which is what I am used to using. Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/wCjYi1UxT50J.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

hack

unread,
Mar 12, 2012, 3:35:04 PM3/12/12
to django...@googlegroups.com
Yea, the docs say its in the body of the response.  

I'll try the lib you suggest.  I was also taking a look at the httplib page as well.

Thanks.

Bill Freeman

unread,
Mar 12, 2012, 3:56:03 PM3/12/12
to django...@googlegroups.com
urllib2 uses urllib and httplib under the hood. There all part of the
standard python install.

Yeah the docs may say it's in the body of the response, but is that
your response to them, or the response to some request you have to
further make to them.

This sounds familiar. It may or may not have been Paypal, but I've
done something like this in the past, and there was no extra request.
Yes, you have to have a remembered cart, or something, to coordinate
with what they're sending you, unless you're getting everything you
need for fulfillment in the post from them.

Anyway, good luck. In my experience, webservice documentation has
spotty quality.

>> > django-users...@googlegroups.com.


>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>>
>

> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/django-users/-/UHrly8fABmMJ.


> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to

> django-users...@googlegroups.com.

hack

unread,
Mar 12, 2012, 4:41:04 PM3/12/12
to django...@googlegroups.com
Yes, I could not agree more on spotty quality.

The paypal instructions are below.  See # 3.

I'm checking out urllib2 now.  I don't see a way of obtaining a response.

Co  n s t r  u c t i  n g   Yo u r   P o  s tb a c k
Use these guidelines for constructing your postback to PayPal:.
1. Your postback must be sent to https://www.paypal.com/cgi-bin/webscr. Instant Payment Notification (IPN)
Using IPN with Multiple Currencies
3
28 March 2008 - first technical draft Order Management Integration Guide
NO T E: You can implement IPN without SSL, including your postbacks for validation, but 
PayPal recommends against doing so.
2. Your postback must include the variable cmd with the value _notify-validate:
cmd=_notify-validate
3. Your postback must include exactly the same variables and values that you receive in the 
IPN from PayPal, and they must be in the same order. 
P r o  ce s s i n g   t h e   P a y P a l  Re s p o n s e   t o   Yo  u r   P o s t b a c k
PayPal responds to your postbacks with a single word in the body of the response: VERIFIED
or INVALID.
When you receive a VERIFIED postback response, perform the following checks on data in 
the IPN: 
1. Check that the payment_status is Completed.
2. If the payment_status is Completed, check the txn_id against the previous PayPal 
transaction that you processed to ensure it is not a duplicate.
3. Check that the receiver_email is an email address registered in your PayPal account.
4. Check that the price, carried in mc_gross, and the currency, carried in mc_currency, are 
correct for the item, carried in item_name or item_number.


>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/UHrly8fABmMJ.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to

hack

unread,
Mar 12, 2012, 4:53:56 PM3/12/12
to django...@googlegroups.com
Oh, it looks like when you do a urlopen the return object is a response.  


On Monday, March 12, 2012 2:57:20 PM UTC-4, ke1g wrote:

> django-users+unsubscribe@googlegroups.com.


> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

On Monday, March 12, 2012 2:57:20 PM UTC-4, ke1g wrote:

> django-users+unsubscribe@googlegroups.com.

Bill Freeman

unread,
Mar 12, 2012, 5:08:20 PM3/12/12
to django...@googlegroups.com
Yes. urlopen returns a response object. If you stick something in
the data argument it does a POST, otherwise a GET. You are
responsible for urlencodeing any query parameters in the url passed
in. The response has things like a code attribute, and I forget
whether you just call read() on it or on some attribute of it to get
the response body.

>> > django-users...@googlegroups.com.

>> > django-users...@googlegroups.com.


>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>>
>

> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/django-users/-/sSWTr8YpGuQJ.


> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to

> django-users...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages