Forums

Using Stripe with web2py on pythonanywhere

Stripe is a payment processing API that I'm trying to use. From my local machine, I was able to get it to work successfully following the web2py's example in the textbook, found at: http://web2py.com/books/default/chapter/29/14#Stripe.com But when I take the simple welcome app, with the added code to the index controller, and I install it on my web2py hosted on pythonanywhere, it doesn't work. I get a "No JSON object could be decoded" error. Since the exact same code works when hosted elsewhere, this is a problem specific to pythonanywhere. Please advise.

@davidrip: First welcome to our PA community. It's great here!!

My guess (without knowing) is that your code is going out to some API from Stripe.com. Since stripe.com is not on the PA whitelisted sites for free accounts this of course would fail. As long as that is the case the PA staff will likely be willing to add the domain to the whitelist.

@a2j: Thanks. I think you are correct that this is exactly what is happening. I will send an email directly to the PA staff requesting that api.stripe.com be added, since that is the domain with which my app is trying to communicate.

My pleasure. Hopefully that will be the last of your trouble...☺

I can't believe it wasn't on our whitelist already! Am just looking into it now...

I've added stripe to the whitelist, but unfortunately it looks like the stripe client won't work:

APIError: Invalid response body from API: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>ERROR: The requested URL could not be retrieved</title> <style type="text/css"><!--   %l  body :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; } :lang(he) { direction: rtl; float: right; }  --></style> </head><body> <div id="titles"> <h1>ERROR</h1> <h2>The requested URL could not be retrieved</h2> </div> <hr>  <div id="content"> <p>The following error was encountered while trying to retrieve the URL: <a href="https://api.stripe.com/v 1/account">https://api.stripe.com/v1/account</a></p>  <blockquote id="error"> <p><b>Unsupported Request Method and Protocol</b></p> </blockquote>  <p>Squid does not support all request methods for all access protocols. For example, you can not POST a Gopher request.</p>  <p>Your cache administrator is <a href="mailto:webmaster%W">webmaster</a>.</p> <br> </div>  <hr> <div id="footer"> <p>Generated Fri, 12 Apr 2013 15:43:26 GMT by giles-liveproxy (squid/2.7.STABLE9)</p> <!-- ERR_UNSUP_REQ --> </div> </body></html>  (HTTP response code orwas 501)

Unfortunately we've found that not all HTTPS client libraries work well with our proxy server -- IIRC urllib3 doesn't work either.

So, that means anyone that wants to use stripe is going to have to upgrade to a paid-for account... but then again, if you're talking to a credit card processor, hopefully you can afford it :)

<casts Revive on super-old thread>

Harry,

Just to be clear, if I have a paid PA account then Stripe Checkout should work fine? Both with <username>.pythonanywhere.com and custom domain w/ my own cert?

I'm not averse to upgrading to test it out but I wanted to ask first in case something had changed in the last 18 months ;-)

lil

Yup. All paying accounts have unproxied access to the internet, so there is no issue with the proxy.