Conversation
| @@ -0,0 +1,2 @@ | |||
| requests==2.12.4 | |||
There was a problem hiding this comment.
I don't think requests is used?
There was a problem hiding this comment.
Stripe seems to requires it internally, or at least think it does https://github.com/stripe/stripe-python/blob/master/setup.py
There was a problem hiding this comment.
I am not familiar with python, but shouldn't stripe be responsible for specifying the requests version in that case?
There was a problem hiding this comment.
Stripe specifies the minimum version (0.8.8) . . .
Looking into this a little more and I'm not 100% sure, but it looks like when pip is reading a requirements.txt, it'll detect transitive dependencies, but pip freeze makes no distinction.
There was a problem hiding this comment.
Here are some people exploring the same issue http://stackoverflow.com/questions/9232568/identifying-the-dependency-relationship-for-python-packages-installed-with-pip
On the bright side, specifying everything explicitly in requirements.txt seems to be a best practice: "Requirement files are mostly flat. Maybe MyApp requires Framework, and Framework requires Library. I encourage you to still list all these in a single requirement file" https://pip.readthedocs.io/en/1.1/requirements.html
There was a problem hiding this comment.
Agree about specifying explicitly, I'm familiar with that
There was a problem hiding this comment.
Does this mean we should also have a setup file and make this a pip package? Is requirements.txt a pip-only thing?
There was a problem hiding this comment.
I'd just opt for pip install -r requirements.txt locally? Maybe I'm missing the context of your question tho
| @@ -0,0 +1,71 @@ | |||
| import BaseHTTPServer | |||
There was a problem hiding this comment.
This is Python2? Pretty sure stripe works with python3, is there a reason for not using it?
https://docs.python.org/3.5/library/http.html#module-http
https://github.com/stripe/stripe-python
We commit to being compatible with Python 2.6+, Python 3.3+ and PyPy
There was a problem hiding this comment.
That's because I didn't know this is python2 only :) I will change it.
There was a problem hiding this comment.
Cool, don't think it matters hugely but I tend to shoot for 3 if possible!!
|
|
||
| ## Running the API server | ||
|
|
||
| 1. Make sure you have an updated version of Python |
|
|
||
| 1. Make sure you have an updated version of Python | ||
|
|
||
| 1. Install the **Stripe Python Library**: |
There was a problem hiding this comment.
the requirements file could allow swapping out this step: pip install -r requirements.txt
| # Process the tokenized transaction | ||
| try: | ||
| charge = stripe.Charge.create( | ||
| amount=999, # Amount in cents |
There was a problem hiding this comment.
We should note that this is a test amount and to expect the actual denomination in the post request object.
| amount=999, # Amount in cents | ||
| currency="cad", | ||
| source=token, | ||
| description="Example charge" |
There was a problem hiding this comment.
Is this a requirement? Or is there additional info we're collecting?
| self.send_header('content-type','application/json') | ||
| self.end_headers() | ||
| self.wfile.write('{"success":true}') | ||
| except stripe.error.CardError as e: |
There was a problem hiding this comment.
There are a few other exceptions to account for: https://stripe.com/docs/api#errors
|
|
||
| ## Running the API server | ||
|
|
||
| 1. Make sure you have an updated version of Python |
There was a problem hiding this comment.
Maybe a suggestion to use virtualenv?
|
|
||
| ## Communicating to the running API server | ||
|
|
||
| Assuming the website is served by an Apache HTTP server on the same host... |
There was a problem hiding this comment.
Apache is good with me, but is there a reason to not use nginx?
There was a problem hiding this comment.
I think for actual deployment we will use nginx. I was testing on my VM that uses Apache, so I wrote Apache instructions.
No description provided.