Configuration
Every request to Buckaroo is signed with your credentials. The client handles the signing, so you only supply the keys, the mode and your defaults.
Create the client
import { Buckaroo } from '@buckaroo/buckaroo_sdk';
const buckaroo = Buckaroo.InitializeClient(
{
websiteKey: process.env.BUCKAROO_STORE_KEY,
secretKey: process.env.BUCKAROO_SECRET_KEY,
},
{
mode: 'TEST', // or 'LIVE'
currency: 'EUR',
returnURL: 'https://example.com/buckaroo/return',
pushURL: 'https://example.com/buckaroo/push',
}
);With CommonJS, use const { Buckaroo } = require('@buckaroo/buckaroo_sdk');.
The
websiteKeyoption takes your store key. The store key used to be called the website key, and the option kept its name.
The SDK does not read environment variables itself. The example above reads the keys from process.env, and you choose the variable names.
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 confirmCredentials() to check that the keys are valid, for example in a health check or behind a "test connection" button:
if (!(await buckaroo.confirmCredentials())) {
throw new Error('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.
const config = {
mode: process.env.NODE_ENV === 'production' ? 'LIVE' : 'TEST',
currency: 'EUR',
};See Test and go live before you switch.
Configuration options
The second argument sets the mode and the defaults for every request.
| Option | Required | Description |
|---|---|---|
mode | Yes | TEST or LIVE |
currency | Yes | Default ISO currency code, such as EUR |
returnURL | No | Where the customer is sent after paying |
returnURLCancel, returnURLError, returnURLReject | No | Alternative return pages |
pushURL | No | Where Buckaroo sends the push message |
continueOnIncomplete | No | 1 to send the customer to the Buckaroo payment page when the request is incomplete |
timeout | No | Request timeout in milliseconds. Defaults to 10000 |
A value you pass in a payment request overrides the default for that request.
If you leave out the second argument, the client uses TEST mode and EUR.
More than one store
Buckaroo.InitializeClient() creates the client and keeps it as the default. To work with more than one store, create a client for each one:
const storeA = new Buckaroo({ websiteKey: 'STORE_KEY_A', secretKey: 'SECRET_KEY' }, config);
const storeB = new Buckaroo({ websiteKey: 'STORE_KEY_B', secretKey: 'SECRET_KEY' }, config);Updated about 2 hours ago