Configuration
Every request to Buckaroo is signed with your credentials. The client handles the signing, so you only supply the keys and the mode.
Create the client
from buckaroo import BuckarooClient
from buckaroo.services.payment_service import PaymentService
client = BuckarooClient("STORE_KEY", "SECRET_KEY", mode="test")
payments = PaymentService(client)mode is test while developing and live in production. It defaults to test. Any other value raises a ValueError.
Where to find your credentials
Both keys are in Plaza under Settings → API keys.
| Key | What it is |
|---|---|
| Store key | Identifies the Buckaroo store that the transaction belongs to. Each store has its own key |
| Secret key | Signs your requests and verifies push messages. It belongs to your Buckaroo account |
Keep your secret key out of version control. Anyone who has it can sign requests in your name. Load both keys from environment variables or a secrets manager instead of writing them in your code.
Check your credentials
Use confirm_credential() to check that the keys are valid, for example in a health check or behind a "test connection" button:
if not client.confirm_credential():
raise RuntimeError("Invalid Buckaroo credentials")Test and live mode
The mode decides which Buckaroo environment receives the request. Nothing else changes, so the same code runs against both. In test mode, no real money is moved.
# development
client = BuckarooClient(store_key, secret_key, mode="test")
# production
client = BuckarooClient(store_key, secret_key, mode="live")See Test and go live before you switch.
Timeouts and retries
To change the request timeout or the retry behaviour, pass a BuckarooConfig object. It also sets the environment, so leave out mode:
from buckaroo import BuckarooClient
from buckaroo.config.buckaroo_config import BuckarooConfig, Environment
config = BuckarooConfig(
environment=Environment.LIVE, # or Environment.TEST
timeout=60, # seconds, default 30
retry_attempts=3, # default 3
)
client = BuckarooClient("STORE_KEY", "SECRET_KEY", config=config)Load the credentials from the environment
Buckaroo.from_env() reads the configuration from environment variables and gives you the payment and solution services in one object:
from buckaroo import Buckaroo
app = Buckaroo.from_env()
app.payments # same as PaymentService(client)
app.solutions # same as SolutionService(client)| Variable | Purpose | Default |
|---|---|---|
BUCKAROO_STORE_KEY | Your store key | Required |
BUCKAROO_SECRET_KEY | Your secret key | Required |
BUCKAROO_MODE | test or live | test |
BUCKAROO_LOG_LEVEL | DEBUG, INFO, WARNING, ERROR or CRITICAL | INFO |
BUCKAROO_LOG_DESTINATION | stdout, file or both | stdout |
BUCKAROO_LOG_FILE | Log file name | buckaroo_app.log |
BUCKAROO_LOG_MASK_SENSITIVE | Mask sensitive values in the log | true |
The SDK reads these from the process environment. It does not load a .env file for you, so use your framework or a package such as python-dotenv for that.
The examples on the other pages use payments. With from_env(), use app.payments in its place.
Updated about 2 hours ago