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.

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 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.

VariablePurposeDefault
BPE_MODEtest or livetest
BPE_CURRENCY_CODEDefault currencyEUR
BPE_RETURN_URLDefault return URLNone
BPE_RETURN_URL_CANCELDefault cancel URLNone
BPE_PUSH_URLDefault push URLNone
BPE_HTTP_TIMEOUTRequest timeout in secondsNone
BPE_HTTP_CONNECT_TIMEOUTConnect timeout in secondsNone

These variables take precedence over the values you pass to the constructor. If BPE_MODE is set to test on your production server, the client stays in test mode even when your code says live.


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().



Did this page help you?