[Zope] sending a post request to a secure site (paypal) from a python script/external method
Richard Ettema
richard.ettema@yoursolutions.com
Wed, 5 Mar 2003 11:47:36 -0000
I'm trying to work out how to setup a python script and external method to
post form data to a paypal https url.
I basically want the user to click a button to pay for their selection which
calls the python script, their order info is saved for our records, and then
the external script passes onto paypal's secure server. Is this possible?
The closest I have got this to work is the palpay page displayed with images
missing, but not on a secure connection. I assume the images are missing
because the url in the address bar is that of the python script, not the
paypal url. Should I be doing something different than a read() in the ext.
method?
I have looked thru the examples in the urllib.py and urllib2.py but could
not work out where I am going wrong, or if it is possible.
I have seen comments about python must be built/installed with ssl support
for secure connections to https urls, how do I work out if python was
built/installed with this?
Running:
system: freebsd
Zope: 2.5.1
python: 2.1.3
The python script: payBill
#########
req = context.REQUEST
form_dict = {}
order_ref = context.recordOrder()
form_dict['cmd'] = '_xclick'
form_dict['business'] = 'test@test'
form_dict['item_name'] = 'Services'
form_dict['item_number'] = '%s' % order_ref
form_dict['amount'] = '%.2f' % float(req['gdttl'])
form_dict['return'] = '%s/services_thankyou' % req['URL']
form_dict['cancel_return'] = '%s/services_thanks' % req['URL1']
form_dict['no_note'] = 1
form_dict['currency_code'] = req['currency_code']
#send info to external method
url_req = context.payBillExt( 'https://www.paypal.com/cgi-bin/webscr',
form_dict )
return url_req
##########
The External Method: payBillExt
#########
import urllib2
import urllib
def urlRequestCreation(self, url, data):
"""url"""
url_data = urllib.urlencode( data )
url_req = urllib2.urlopen(url, url_data)
return url_req.read()
#########
Thanks for any pointers in the right direction.
Richard
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.456 / Virus Database: 256 - Release Date: 18/02/2003