Registry / type-stubs / types-braintree

types-braintree

JSON →
library4.44.0.20260602pypypiunverified

This package provides static type checking stubs for the `braintree` Python SDK. It allows tools like Mypy and Pylance to validate type usage in your Braintree integration code, improving code quality and catching potential errors before runtime. It's maintained as part of the `typeshed` project and is updated regularly to reflect changes in the official `braintree` library. The current version is `4.42.0.20260408`.

pip install braintree types-braintree
INSTALL
IMPORT
SIG · TYPES-BRAINTREE
T
types-braintree
type-stubspythonv4.44.0.20260602
Install
2.3s avg
Import
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.44.0.20260602 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 24.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.3s · import 0.000s · 25MB
23MB installed
● package 23MB
Code
Verified usage

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

Configuration
import braintree; braintree.Configuration(...)
Used to set up your Braintree environment (sandbox/production) and credentials. These are runtime imports from the `braintree` library, for which `types-braintree` provides type hints.
BraintreeGateway
import braintree; braintree.BraintreeGateway(...)
The main entry point for interacting with the Braintree API. These are runtime imports from the `braintree` library, for which `types-braintree` provides type hints.
Environment
import braintree; braintree.Environment.Sandbox
Enum for specifying the Braintree environment (Sandbox, Production). These are runtime imports from the `braintree` library, for which `types-braintree` provides type hints.

This quickstart demonstrates how to configure the Braintree gateway using environment variables and generate a client token. This code uses the actual `braintree` library; `types-braintree` merely provides static type checking for this code.

import braintree import os # Configure Braintree Gateway using environment variables for security gateway = braintree.BraintreeGateway( braintree.Configuration( environment=os.environ.get('BRAINTREE_ENVIRONMENT', braintree.Environment.Sandbox), merchant_id=os.environ.get('BRAINTREE_MERCHANT_ID', 'your_sandbox_merchant_id'), public_key=os.environ.get('BRAINTREE_PUBLIC_KEY', 'your_sandbox_public_key'), private_key=os.environ.get('BRAINTREE_PRIVATE_KEY', 'your_sandbox_private_key') ) ) # Example: Generate a client token (common for web/mobile integrations) try: client_token = gateway.client_token.generate({}) print(f"Generated Client Token: {client_token}") except Exception as e: print(f"Error generating client token: {e}")
Debug
Known issues
gotchaThe `types-braintree` package only provides type hints for the `braintree` library. It does not provide any runtime functionality. You must install the `braintree` package itself for your code to run.
fix
Ensure both `pip install braintree` and `pip install types-braintree` are run in your environment.
affects: All versions
gotchaMismatching versions between `braintree` and `types-braintree` can lead to incorrect type checking results. Newer features in `braintree` might not yet have stubs, or outdated stubs might conflict with runtime changes.
fix
Keep both `braintree` and `types-braintree` up to date. If type errors persist for new features, consider contributing to typeshed or temporarily suppressing specific type checker errors.
affects: All versions
breakingRecent versions of `types-braintree` (and `typeshed` generally) require Python 3.10 or newer. Users on older Python versions will encounter installation errors or unexpected type checking behavior.
fix
Upgrade your Python environment to 3.10 or newer. If you must use an older Python version, you might need to pin `types-braintree` to an older compatible version, which might lack stubs for newer `braintree` features.
affects: >=4.42.0.x
gotchaWhen configuring Braintree, always use `braintree.Environment.Sandbox` for testing and `braintree.Environment.Production` with your actual production keys for live transactions. Using sandbox credentials in production or vice-versa will lead to errors.
fix
Ensure your `BRAINTREE_ENVIRONMENT` and corresponding `merchant_id`, `public_key`, `private_key` environment variables are correctly set for your target environment (Sandbox or Production).
affects: All versions
Upgrade
Version history
4.44.0.20260602latest on PyPI · released Jun 2, 2026
Audit
Dependencies
braintreerequiredThis package provides type stubs for the `braintree` library, which must be installed separately for runtime functionality.
Agent activity
28 hits · last 30 days
node
22
OpenAI (training)
1
Resources
types-braintree — pip install types-braintree · libregistry