Python Client Library
Installation
With pip
pip install braintree
Without pip
wget http://pycurl.sourceforge.net/download/pycurl-7.19.0.tar.gz tar zxf pycurl-7.19.0.tar.gz cd pycurl-7.19.0 python setup.py install wget http://pypi.python.org/packages/source/b/braintree/braintree-2.12.3.tar.gz tar zxf braintree-2.12.3.tar.gz cd braintree-2.12.3 python setup.py install
Updates
Current version: 2.12.3. Released February 01, 2012.
For details on changes see the change log. If we deprecate any functionality we’ll add updating instructions to the deprecations page.
Fill out this form to receive emails when we release updates to the Python library.
Source Code
Integration Examples
Bugs
If you run into a bug, email us at support@getbraintree.com or create an issue on the github issue tracker.
Quick Start Example
import braintree
braintree.Configuration.configure(
braintree.Environment.Sandbox,
"the_merchant_id",
"the_public_key",
"the_private_key"
)
result = braintree.Transaction.sale({
"amount": "1000.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "05/2012"
}
})
if result.is_success:
print "success!: " + result.transaction.id
elif result.transaction:
print "Error processing transaction:"
print " message: " + result.message
print " code: " + result.transaction.processor_response_code
print " text: " + result.transaction.processor_response_text
else:
print "message: " + result.message
for error in result.errors.deep_errors:
print "attribute: " + error.attribute
print " code: " + error.code
print " message: " + error.message