Client SDK

The Client SDK is a JavaScript library that shows Buckaroo payment widgets and buttons on your own page. Your server starts the payment, and the SDK handles the part in the customer's browser: it shows a QR code or button, opens the payment app on a mobile device, follows the status and sends the customer to your return URL.
What you can use it for
| Payment method | What the SDK does | SDK module |
|---|---|---|
| Bancontact | Shows a button that opens a QR code, or opens the Bancontact app on a mobile device | BuckarooSdk.BancontactMobile |
| iDEAL QR | Shows a button that opens a QR code | BuckarooSdk.IdealQr |
| Payconiq | Shows a QR code, or opens the Payconiq app on a mobile device | BuckarooSdk.Payconiq |
| PayPal | Shows the PayPal Express Checkout buttons | BuckarooSdk.PayPal |
The same script also contains the modules for Apple Pay, Google Pay and Click to Pay. Those are described with the payment method itself, for example on the Apple Pay integration page.
Add the SDK
Load jQuery and then the SDK at the bottom of the <body> of your page:
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://checkout.buckaroo.nl/api/buckaroosdk/script"></script>The SDK adds its own stylesheet to the page. All functions are available under BuckarooSdk.
- The SDK needs jQuery 1.9 or higher, and it has no other dependencies
- Always load the script from Buckaroo. Do not host or cache a copy, so that you stay in sync with updates
Language
The widget texts are Dutch by default. Add a language code to the script URL for English (en), French (fr) or Dutch (nl):
<script src="https://checkout.buckaroo.nl/api/buckaroosdk/script/en"></script>How a QR payment works
- Start the payment on your server.
Send the Pay request for the payment method. The response contains the transaction key in theKeyfield. - Start the widget on your page.
Call theinitiatefunction of the payment method with a container and the transaction key. - The customer pays.
On a desktop the customer scans the QR code. On a mobile device, the SDK opens the payment app where the method supports it. - The SDK redirects the customer.
When the payment succeeds, fails or is cancelled, the SDK shows the result and sends the customer to your return URL after a few seconds.
Update your order from the push message, not from what the widget shows. The widget runs in the customer's browser, and the customer can close the page before the redirect.
Every initiate function takes these two arguments first:
| Argument | Type | Description |
|---|---|---|
| Container selector | String | A query selector for the element the widget is added to, such as #bancontact |
| Transaction key | String | The Key from the response to your server-side Pay request |
Bancontact
<div id="bancontact"></div>
<script>
$(function () {
BuckarooSdk.BancontactMobile.initiate('#bancontact', 'YOUR_TRANSACTION_KEY');
});
</script>The SDK adds a button to the container. On a desktop, the button opens a popup with the QR code. On a mobile device, it opens the Bancontact app.
For a test transaction, the popup shows buttons to simulate a successful, failed or cancelled payment.
iDEAL QR
<div id="ideal-qr"></div>
<script>
$(function () {
BuckarooSdk.IdealQr.initiate('#ideal-qr', 'YOUR_TRANSACTION_KEY', false);
});
</script>The SDK adds a button to the container that opens a popup with the QR code.
| Argument | Type | Description |
|---|---|---|
| Processing | Boolean | The third argument. true if your iDEAL subscription is a processing subscription, otherwise false |
| Inline | Boolean | Optional fourth argument. true shows the QR code directly in the container, without the button and popup |
Payconiq
<div id="payconiq"></div>
<script>
$(function () {
BuckarooSdk.Payconiq.initiate('#payconiq', 'YOUR_TRANSACTION_KEY');
});
</script>The SDK shows the QR code in the container. On a mobile device, it opens the Payconiq app.
Follow the status yourself
BancontactMobile.initiate and Payconiq.initiate take an optional callback as third argument. The SDK calls it on every status change.
BuckarooSdk.BancontactMobile.initiate('#bancontact', 'YOUR_TRANSACTION_KEY', function (status, params) {
if (status === 'SUCCESS') {
// params[0] is the URL the customer is redirected to
}
return true; // true: let the SDK redirect. false: handle the redirect yourself
});| Status | Meaning |
|---|---|
WAITING | The QR code is shown and waiting to be scanned. Bancontact only |
PROCESSING | The customer scanned the code and is completing the payment |
SUCCESS | The payment succeeded |
FAILED | The payment failed |
CANCELLED | The payment was cancelled. Bancontact only |
For SUCCESS, FAILED and CANCELLED, the SDK redirects the customer when your callback returns true. Return false to stay on the page and handle the next step yourself.
PayPal Express Checkout
With PayPal Express Checkout, the customer pays with PayPal straight from your product page or shopping cart.
Requirements
- Your PayPal account is connected in Plaza under PayPal
- One-off payments only
Show the buttons
<div id="paypal-container"></div>
<script>
$(function () {
BuckarooSdk.PayPal.initiate({
containerSelector: '#paypal-container',
buckarooWebsiteKey: 'YOUR_STORE_KEY',
paypalMerchantId: 'YOUR_PAYPAL_MERCHANT_ID',
currency: 'EUR',
amount: 10.00,
createPaymentHandler: createPayment,
onSuccessCallback: function () {
window.location.href = '/checkout/thank-you';
},
onErrorCallback: function (reason) {
// show an error message
},
onCancelCallback: function () {
// the customer closed the PayPal window
},
});
});
// Called after the customer approves the payment in PayPal
function createPayment(data) {
// Send the PayPal order ID to your server, which creates the PayPal Pay request at Buckaroo
return fetch('/checkout/paypal', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ paypalOrderId: data.orderID }),
}).then(function (response) {
if (!response.ok) {
throw new Error('Payment could not be created');
}
});
}
</script>Options
| Option | Required | Type | Description |
|---|---|---|---|
containerSelector | Yes | String | Where the PayPal buttons are shown |
buckarooWebsiteKey | Yes | String | Your Buckaroo store key |
paypalMerchantId | Yes | String | Your PayPal merchant ID |
currency | Yes | String | The currency of the payment |
amount | Yes | Number | The amount of the payment |
createPaymentHandler | Yes | Function | Called with the PayPal approval data after the customer approves the payment. Create the PayPal Pay request on your server with the PayPal order ID, and return a Promise |
onSuccessCallback | Yes | Function | Called when createPaymentHandler succeeds. Use it to send the customer to your confirmation page |
onErrorCallback | No | Function | Called with the reason when PayPal reports an error or createPaymentHandler fails |
onCancelCallback | No | Function | Called when the customer cancels in PayPal |
onShippingChangeHandler | No | Function | Called with data and actions when the customer changes the shipping address in PayPal. Use it to update the shipping costs or reject an address |
onInitCallback | No | Function | Called when the PayPal buttons are shown |
onClickCallback | No | Function | Called when the customer clicks a PayPal button |
invoiceId | No | String | Your invoice number for the PayPal order |
intent | No | String | Authorize to reserve the amount and capture it later. Leave it out for a direct payment |
The
buckarooWebsiteKeyoption takes your store key.
The store key used to be called the website key, and the option kept its name.
Update the shipping costs
onShippingChangeHandler receives the same data and actions as the onShippingChange callback of the PayPal JavaScript SDK. This example rejects addresses outside the Netherlands and adds the shipping costs to the order:
var orderAmount = '10.00';
var shippingAmount = '4.95';
function onShippingChange(data, actions) {
if (data.shipping_address.country_code !== 'NL') {
return actions.reject();
}
return actions.order.patch([
{
op: 'replace',
path: "/purchase_units/@reference_id=='default'/amount",
value: {
currency_code: 'EUR',
value: (parseFloat(orderAmount) + parseFloat(shippingAmount)).toFixed(2),
breakdown: {
item_total: { currency_code: 'EUR', value: orderAmount },
shipping: { currency_code: 'EUR', value: shippingAmount },
},
},
},
]);
}Updated 9 days ago