-
Notifications
You must be signed in to change notification settings - Fork 1
Add API to list account balance and facilitate basic payment processing #1
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,2 @@ | |||
requests==2.12.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think requests
is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree about specifying explicitly, I'm familiar with that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because I didn't know this is python2 only :) I will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make clear which one?
|
||
1. Make sure you have an updated version of Python | ||
|
||
1. Install the **Stripe Python Library**: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a requirement? Or is there additional info we're collecting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the example.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apache is good with me, but is there a reason to not use nginx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.