{"id":184,"library":"braintree","title":"Braintree Python SDK","description":"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.","status":"active","version":"4.42.0","language":"python","source_language":"en","source_url":"https://github.com/braintree/braintree_python","tags":["braintree","payments","paypal","python","payment-gateway"],"install":[{"cmd":"pip install braintree","lang":"bash","label":"Python"}],"dependencies":[{"reason":"Required. Installed automatically.","package":"requests","optional":false}],"imports":[{"note":"Amount must be a string ('100.00'). submit_for_settlement: True is required to capture funds immediately. Without it, transaction is only authorized — not captured.","wrong":"# Wrong: amount as float\nresult = gateway.transaction.sale({'amount': 100.00, ...})\n\n# Wrong: forgetting submit_for_settlement — authorizes but doesn't capture\nresult = gateway.transaction.sale({\n    'amount': '100.00',\n    'payment_method_nonce': nonce\n    # no options — payment authorized but not captured\n})","symbol":"BraintreeGateway","correct":"import braintree\n\ngateway = braintree.BraintreeGateway(\n    braintree.Configuration(\n        environment=braintree.Environment.Sandbox,\n        merchant_id='your_merchant_id',\n        public_key='your_public_key',\n        private_key='your_private_key'\n    )\n)\n\n# Generate client token — send to frontend\nclient_token = gateway.client_token.generate()\n\n# Create transaction with nonce from frontend\nresult = gateway.transaction.sale({\n    'amount': '100.00',   # string, not float\n    'payment_method_nonce': nonce_from_client,\n    'options': {\n        'submit_for_settlement': True  # capture immediately\n    }\n})\n\nif result.is_success:\n    print(result.transaction.id)\nelse:\n    for error in result.errors.deep_errors:\n        print(error.message)"}],"quickstart":{"code":"# pip install braintree\nimport braintree\n\ngateway = braintree.BraintreeGateway(\n    braintree.Configuration(\n        environment=braintree.Environment.Sandbox,\n        merchant_id='your_merchant_id',\n        public_key='your_public_key',\n        private_key='your_private_key'\n    )\n)\n\n# Step 1: Generate client token for frontend\nclient_token = gateway.client_token.generate()\n# Pass client_token to frontend Braintree Drop-in UI\n\n# Step 2: Receive nonce from frontend, create transaction\nresult = gateway.transaction.sale({\n    'amount': '49.99',\n    'payment_method_nonce': 'nonce-from-frontend',\n    'options': {'submit_for_settlement': True}\n})\n\nif result.is_success:\n    print('Success:', result.transaction.id)\nelif result.transaction:\n    print('Processor error:', result.transaction.processor_response_code)\nelse:\n    for err in result.errors.deep_errors:\n        print('Validation error:', err.message)","lang":"python","description":"Braintree Python SDK — client token generation and transaction sale."},"warnings":[{"fix":"pip install --upgrade braintree","message":"SSL 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.","severity":"breaking","affected_versions":"< 4.33"},{"fix":"amount = f'{float_value:.2f}'","message":"Amount must be a string ('100.00'), not float or int. Passing a number raises an error or causes unexpected behavior.","severity":"gotcha","affected_versions":"all"},{"fix":"'options': {'submit_for_settlement': True}","message":"Without submit_for_settlement: True, transactions are only authorized — not captured. Funds are not collected. Must explicitly settle.","severity":"gotcha","affected_versions":"all"},{"fix":"Check both: result.transaction for processor errors, result.errors.deep_errors for validation errors.","message":"result.is_success being False doesn't always mean total failure — check result.transaction for processor decline (card declined) vs result.errors for validation errors.","severity":"gotcha","affected_versions":"all"},{"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.","message":"AuthenticationError indicates invalid Braintree API credentials (merchant_id, public_key, private_key) or incorrect environment configuration.","severity":"breaking","affected_versions":"all"},{"fix":"Verify Braintree API credentials (Merchant ID, Public Key, Private Key) are correct and configured properly in your `braintree.Configuration` object.","message":"AuthenticationError: 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.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T09:48:22.782Z","next_check":"2026-06-25T00:00:00.000Z","problems":[{"fix":"Install the braintree package using pip: `pip install braintree`","cause":"The Braintree Python SDK is not installed in the current Python environment or the environment where the code is being executed.","error":"ModuleNotFoundError: No module named 'braintree'"},{"fix":"Double-check your Braintree API keys and ensure you are using the correct environment (Sandbox vs. Production) when initializing the Braintree gateway.","cause":"Your Braintree API credentials (Merchant ID, Public Key, Private Key) are incorrect, or you are attempting to use credentials for a different environment (e.g., sandbox keys in production or vice-versa).","error":"braintree.exceptions.AuthenticationError"},{"fix":"Upgrade your Braintree Python SDK to the latest version (`pip install --upgrade braintree`). If the issue persists, ensure your system's OpenSSL libraries are up to date.","cause":"Braintree updated its root SSL certificate in April 2024. Older Python SDK versions (specifically those older than ~4.33) will fail to connect after March 2026 due to an outdated SSL certificate, or your system's OpenSSL version is too old.","error":"SSLError: SSLCertificateError"},{"fix":"Rename your local Python file (e.g., to `braintree_utils.py` or `payment_gateway.py`) to avoid naming conflicts with the installed `braintree` package.","cause":"You have a Python file named 'braintree.py' in your project's directory, which causes a circular import when you try to import the official 'braintree' SDK.","error":"AttributeError: 'module' object has no attribute 'Configuration' or AttributeError: partially initialized module 'braintree' has no attribute 'BraintreeGateway' (most likely due to a circular import)"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.79,"mem_mb":14.8,"disk_size":"23.4M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.56,"mem_mb":14.8,"disk_size":"24M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.98,"mem_mb":16.1,"disk_size":"25.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.81,"mem_mb":16.1,"disk_size":"26M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.92,"mem_mb":16,"disk_size":"17.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.91,"mem_mb":16,"disk_size":"18M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.89,"mem_mb":16.4,"disk_size":"17.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.83,"mem_mb":16.4,"disk_size":"17M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.76,"mem_mb":14.5,"disk_size":"22.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.66,"mem_mb":14.5,"disk_size":"23M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}