Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Add API to list account balance and facilitate basic payment processing #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

benhylau
Copy link
Member

No description provided.

@@ -0,0 +1,2 @@
requests==2.12.4
Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

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

Copy link

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

Copy link
Member Author

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?

Copy link

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
Copy link

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

Copy link
Member Author

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.

Copy link

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
Copy link

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**:
Copy link

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
Copy link
Member

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"
Copy link
Member

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?

Copy link
Member Author

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:
Copy link
Member

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
Copy link
Member

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...
Copy link
Member

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?

Copy link
Member Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants