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.

KeyWhat it is
Store keyIdentifies the Buckaroo store that the transaction belongs to. Each store has its own key
Secret keySigns 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)
VariablePurposeDefault
BUCKAROO_STORE_KEYYour store keyRequired
BUCKAROO_SECRET_KEYYour secret keyRequired
BUCKAROO_MODEtest or livetest
BUCKAROO_LOG_LEVELDEBUG, INFO, WARNING, ERROR or CRITICALINFO
BUCKAROO_LOG_DESTINATIONstdout, file or bothstdout
BUCKAROO_LOG_FILELog file namebuckaroo_app.log
BUCKAROO_LOG_MASK_SENSITIVEMask sensitive values in the logtrue

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.



Did this page help you?