[Zope] sending a post request to a secure site (paypal) from a
python script/external method
Edward Muller
edwardam@interlix.com
06 Mar 2003 23:16:31 -0600
I do credit card authorization from zope via m2crypto
It's as simple as ....
from M2Crypto import m2urllib
encodedParams = urllib.urlencode(params)
url = m2urllib.FancyURLopener()
u = url.open('https://place.you.are.posting.to',encodedParams)
data = u.read()
This is in an external method.
Hope this helps with your paypal question...
On Wed, 2003-03-05 at 05:47, Richard Ettema wrote:
> 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
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
--
Edward Muller
Interlix - President
Web Hosting - PC Service & Support
Custom Programming - Network Service & Support
Phone: 417-862-0573
Cell: 417-844-2435
Fax: 417-862-0572
http://www.interlix.com