Registry / payments / braintree

braintree

JSON →
library4.42.0pypypi✓ verified 50d ago

PayPal's Braintree payment gateway Python SDK. Current version: 4.42.0 (Mar 2026). Stable API — no major breaking changes from v3 to v4 for Python. SSL certificate update required: Braintree updated root SSL cert April 2024 — SDKs older than ~4.33 will fail after March 2026. Three-step flow: generate client token server-side → collect payment method nonce client-side → create transaction server-side. Amount as string. submit_for_settlement must be True to actually capture funds.

payments
pip install braintree
Install & Compatibility
Where this runs
tested against v4.44.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.842s · 23.5MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 2.2s · import 0.746s · 24MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BraintreeGateway
from braintree import BraintreeGateway
import braintree
Configuration
from braintree import Configuration
import braintree
Environment
from braintree import Environment
import braintree

Braintree Python SDK — client token generation and transaction sale.

# pip install braintree import braintree gateway = braintree.BraintreeGateway( braintree.Configuration( environment=braintree.Environment.Sandbox, merchant_id='your_merchant_id', public_key='your_public_key', private_key='your_private_key' ) ) # Step 1: Generate client token for frontend client_token = gateway.client_token.generate() # Pass client_token to frontend Braintree Drop-in UI # Step 2: Receive nonce from frontend, create transaction result = gateway.transaction.sale({ 'amount': '49.99', 'payment_method_nonce': 'nonce-from-frontend', 'options': {'submit_for_settlement': True} }) if result.is_success: print('Success:', result.transaction.id) elif result.transaction: print('Processor error:', result.transaction.processor_response_code) else: for err in result.errors.deep_errors: print('Validation error:', err.message)
Debug
Known issues
breakingSSL certificate update: Braintree updated root SSL cert April 2024. SDK versions older than ~4.33.0 will stop working after March 30, 2026. Update to latest version.
fix
pip install --upgrade braintree
affects: < 4.33
gotchaAmount must be a string ('100.00'), not float or int. Passing a number raises an error or causes unexpected behavior.
fix
amount = f'{float_value:.2f}'
affects: all
gotchaWithout submit_for_settlement: True, transactions are only authorized — not captured. Funds are not collected. Must explicitly settle.
fix
'options': {'submit_for_settlement': True}
affects: all
gotcharesult.is_success being False doesn't always mean total failure — check result.transaction for processor decline (card declined) vs result.errors for validation errors.
fix
Check both: result.transaction for processor errors, result.errors.deep_errors for validation errors.
affects: all
breakingAuthenticationError indicates invalid Braintree API credentials (merchant_id, public_key, private_key) or incorrect environment configuration.
fix
Verify your Braintree API credentials (merchant_id, public_key, private_key) are correct and correspond to the specified environment (e.g., sandbox, production). Ensure they are properly configured in your Braintree gateway initialization.
affects: all
breakingAuthenticationError: This typically indicates incorrect Braintree API credentials (Merchant ID, Public Key, Private Key) or an issue with their configuration. Ensure your gateway credentials are set up correctly.
fix
Verify Braintree API credentials (Merchant ID, Public Key, Private Key) are correct and configured properly in your `braintree.Configuration` object.
affects: all
Upgrade
Version history
4.44.0latest on PyPI
Audit
Dependencies
requestsrequiredRequired. Installed automatically.
Agent activity
94 hits · last 30 days
node
10
seranking-bot
4
ahrefsbot
3
Amazon
1
amazonbot
1
bytedance
1
Resources