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
require __DIR__ . '/vendor/autoload.php';
$buckaroo = new \Buckaroo\BuckarooClient('STORE_KEY', 'SECRET_KEY', 'test');The third argument is the mode: test while developing, live in production. It defaults to test.
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 confirmCredential() to check that the keys are valid, for example in a health check or behind a "test connection" button:
if (! $buckaroo->confirmCredential()) {
throw new RuntimeException('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
$buckaroo = new \Buckaroo\BuckarooClient($storeKey, $secretKey, 'test');
// production
$buckaroo = new \Buckaroo\BuckarooClient($storeKey, $secretKey, 'live');See Test and go live before you switch.
Set defaults
To set defaults such as the currency, the return and push URLs, the language of the payment page or HTTP timeouts, pass a DefaultConfig object instead of the keys:
use Buckaroo\BuckarooClient;
use Buckaroo\Config\DefaultConfig;
$config = new DefaultConfig(
'STORE_KEY',
'SECRET_KEY',
'test', // mode: 'test' or 'live'
'EUR', // currency
'https://example.com/buckaroo/return', // returnURL
'https://example.com/buckaroo/cancel', // returnURLCancel
'https://example.com/buckaroo/push', // pushURL
'My Store', // platformName
'1.0.0', // platformVersion
'My Company', // moduleSupplier
'my-store-buckaroo', // moduleName
'1.0.0', // moduleVersion
'nl-NL', // culture (language of the payment page)
'Web', // channel
null, // logger
30, // timeout in seconds
10 // connect timeout in seconds
);
$buckaroo = new BuckarooClient($config);A value you pass in a payment request overrides the default for that request.
Environment variables
If any of these variables are set in $_ENV, the SDK uses them.
| Variable | Purpose | Default |
|---|---|---|
BPE_MODE | test or live | test |
BPE_CURRENCY_CODE | Default currency | EUR |
BPE_RETURN_URL | Default return URL | None |
BPE_RETURN_URL_CANCEL | Default cancel URL | None |
BPE_PUSH_URL | Default push URL | None |
BPE_HTTP_TIMEOUT | Request timeout in seconds | None |
BPE_HTTP_CONNECT_TIMEOUT | Connect timeout in seconds | None |
These variables take precedence over the values you pass to the constructor. If
BPE_MODEis set toteston your production server, the client stays in test mode even when your code sayslive.
Logging
Attach a logger to see the requests and responses while you develop. The SDK includes a Monolog observer that writes to stdout:
$buckaroo->attachLogger(new \Buckaroo\Handlers\Logging\Observers\Monolog());To send the logs to your own logger, implement Buckaroo\Handlers\Logging\Observer and pass it to attachLogger().
Updated about 4 hours ago