Name: stripe-python
Owner: seantis gmbh
Description: Python library for the Stripe API.
Created: 2017-05-29 08:39:48.0
Updated: 2017-05-29 08:39:51.0
Pushed: 2017-05-28 13:54:39.0
Homepage: https://stripe.com
Size: 1280
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The Stripe Python library provides convenient access to the Stripe API from applications written in the Python language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Stripe API.
See the Python API docs.
You don't need this source code unless you want to modify the package. If you just want to use the package, just run:
pip install --upgrade stripe
or
easy_install --upgrade stripe
Install from source with:
python setup.py install
The library needs to be configured with your account's secret key which is
available in your Stripe Dashboard. Set stripe.api_key
to its
value:
rt stripe
pe.api_key = "sk_test_..."
st charges
pe.Charge.list()
trieve single charge
pe.Charge.retrieve("ch_1A2PUG2eZvKYlo2C4Rej1B9d")
For apps that need to use multiple keys during the lifetime of a process, like one that uses Stripe Connect, it's also possible to set a per-request key and/or account:
rt stripe
st charges
pe.Charge.list(
api_key="sk_test_...",
stripe_account="acct_..."
trieve single charge
pe.Charge.retrieve(
"ch_1A2PUG2eZvKYlo2C4Rej1B9d",
api_key="sk_test_...",
stripe_account="acct_..."
The library can be configured to use urlfetch
, requests
, pycurl
, or
urllib2
with stripe.default_http_client
:
nt = stripe.http_client.UrlFetchClient()
nt = stripe.http_client.RequestsClient()
nt = stripe.http_client.PycurlClient()
nt = stripe.http_client.Urllib2Client()
pe.default_http_client = client
Without a configured client, by default the library will attempt to load
libraries in the order above (i.e. urlfetch
is preferred with urllib2
used
as a last resort). We usually recommend that people use requests
.
A proxy can be configured with stripe.proxy
:
pe.proxy = "https://user:pass@example.com:1234"
The library can be configured to emit logging that will give you better insight
into what it's doing. The info
logging level is usually most appropriate for
production use, but debug
is also available for more verbosity.
There are a few options for enabling it:
Set the environment variable STRIPE_LOG
to the value debug
or info
port STRIPE_LOG=debug
Set stripe.log
:
rt stripe
pe.log = 'debug'
Enable it through Python's logging module:
rt logging
ing.basicConfig()
ing.getLogger('stripe').setLevel(logging.DEBUG)
If you're writing a plugin that uses the library, we'd appreciate it if you
identified using stripe.set_app_info()
:
tripe.set_app_info("MyAwesomePlugin", version="1.2.34", url="https://myawesomeplugin.info")
This information is passed along when the library makes calls to the Stripe API.
Run all tests (modify -e
according to your Python target):
tox -e py27
Run a single test suite:
tox -e py27 -- --test-suite stripe.test.resources.test_updateable.UpdateableAPIResourceTests
Run a single test:
tox -e py27 -- --test-suite stripe.test.resources.test_updateable.UpdateableAPIResourceTests.test_save
Run the linter with:
pip install flake8
flake8 stripe