PHP SDK
Welcome to the Buckaroo PHP SDK Documentation! We’re here to guide you through using our PHP SDK with ease and confidence. Buckaroo developed its own PHP SDK. The SDK is an open-source PHP library that makes integrating your PHP application with Buckaroo’s services easy.
Requirements
To use the Buckaroo API client, the following are required:
- A Buckaroo account (Dutch or English)
- PHP 7.4 or higher
- Up-to-date OpenSSL (or other SSL/TLS toolkit)
Click here to view the PHP SDK on the Buckaroo GitHub repository.
Composer Installation
By far the easiest way to install the Buckaroo API client is to require it with Composer.
$ composer require buckaroo/sdk:^1.0
{
"require": {
"buckaroo/sdk": "^1.0"
}
}
Examples
Create and config the Buckaroo object.
require __DIR__ . '/vendor/autoload.php';
# Get your website & secret key in your plaza.
$buckaroo = new \Buckaroo\BuckarooClient('WEBSITE_KEY', 'SECRET_KEY');
iDEAL
# Create an iDEAL payment
$buckaroo->payment('ideal') // Input the desire payment method.
->pay([
'returnURL' => 'https://example.com/return', //Returns to this url aftere payment.
'issuer' => 'ABNANL2A' // Selected bank,
'amountDebit' => 10, // The amount we want to charge
'invoice' => 'UNIQUE-INVOICE-NO', // Each payment must contain a unique invoice number
]);
Credit Card
There are two ways to initialize the credit card payment: a standard pay flow and an encrypted pay flow. The encrypted pay flow enhances security by requiring credit card information to be encrypted on the client side before being transmitted to our servers.
Standard flow
# Create a standard flow credit card payment
$buckaroo->payment('creditcard') // Input the desire payment method.
->pay([
'name' => 'visa' // Request to pay with Visa
'amountDebit' => 10, // The amount we want to charge
'invoice' => 'UNIQUE-INVOICE-NO', // Each payment must contain a unique invoice number
]);
Encrypted flow
The encrypted pay flow requires the credit card information to be encrypted on the client side using our JavaScript library before being sent in the API request. This method provides an additional layer of security by ensuring that sensitive information is encrypted at the point of entry.
# Create a encrypted flow credit card payment
$buckaroo->payment('creditcard') // Input the desire payment method.
->payEncrypted([
'name' => 'visa' // Request to pay with Visa
'amountDebit' => 10, // The amount we want to charge
'invoice' => 'UNIQUE-INVOICE-NO', // Each payment must contain a unique invoice number
'encryptedCardData' => 'xxx', //This encrypted string is base on the input of the credit card information using the Javascript library
]);
Alipay
# Create a Alipay payment
$buckaroo->method('alipay')->pay([
'amountDebit' => 10,
'invoice' => uniqid(),
'useMobileView' => true,
]);
Apple Pay
There are two methods for integrating ApplePay into your website: incorporating our JavaScript library or using a redirect approach. Implementing the redirect version is simpler, as it directs the customer to our hosted payment page that already has the ApplePay JavaScript implementation in place.
JavaScrtipt method
# Create a ApplePay payment
$buckaroo->method('applepay')->pay([
'amountDebit' => 10,
'invoice' => uniqid(),
'paymentData' => uniqid(),
'customerCardName' => 'Buck Aroo',
]);
Redirect version
# Create a ApplePay payment using redirect
$buckaroo->method('applepay')->payRedirect([
'amountDebit' => 10,
'invoice' => uniqid(),
'servicesSelectableByClient' => 'applepay',
'continueOnIncomplete' => '1',
]);
Bancontact
Similar to credit card payment integration, there are two approaches to incorporating Bancontact on your website. You can either direct customers to our hosted payment site, where they will be taken to a separate page to enter their Bancontact details, or you can integrate our JavaScript library to encrypt the data directly on your site.
Non-encrypted
# Create a Bancontact payment
$buckaroo->method('bancontactmrcash')->pay([
'invoice' => uniqid(),
'amountDebit' => 10.10,
'saveToken' => true,
]);
Encrypted
# Create a Bancontact encrypted payment
$buckaroo->method('bancontactmrcash')->payEncrypted([
'invoice' => uniqid(),
'amountDebit' => 10.10,
'description' => 'Bancontact PayEncrypted Test 123',
'encryptedCardData' => 'xxx',
]);
Belfius
# Create a Belfius payment
$buckaroo->method('belfius')->pay([
'amountDebit' => 10.10,
'invoice' => uniqid(),
]);
Billink
# Create a Bilink payment
$buckaroo->method('billink')->pay([
'amountDebit' => 50.30,
'order' => uniqid(),
'invoice' => uniqid(),
'trackAndTrace' => 'TR0F123456789',
'vATNumber' => '2',
'billing' => [
'recipient' => [
'category' => 'B2B',
'careOf' => 'John Smith',
'title' => 'Female',
'initials' => 'JD',
'firstName' => 'John',
'lastName' => 'Do',
'birthDate' => '01-01-1990',
'chamberOfCommerce' => 'TEST',
],
'address' => [
'street' => 'Hoofdstraat',
'houseNumber' => '13',
'houseNumberAdditional' => 'a',
'zipcode' => '1234AB',
'city' => 'Heerenveen',
'country' => 'NL',
],
'phone' => [
'mobile' => '0698765433',
'landline' => '0109876543',
],
'email' => '[email protected]',
],
'shipping' => [
'recipient' => [
'category' => 'B2C',
'careOf' => 'John Smith',
'title' => 'Male',
'initials' => 'JD',
'firstName' => 'John',
'lastName' => 'Do',
'birthDate' => '1990-01-01',
],
'address' => [
'street' => 'Kalverstraat',
'houseNumber' => '13',
'houseNumberAdditional' => 'b',
'zipcode' => '4321EB',
'city' => 'Amsterdam',
'country' => 'NL',
],
],
'articles' => [
[
'identifier' => 'Articlenumber1',
'description' => 'Blue Toy Car',
'vatPercentage' => '21',
'quantity' => '2',
'price' => '20.10',
'priceExcl' => 5,
],
[
'identifier' => 'Articlenumber2',
'description' => 'Red Toy Car',
'vatPercentage' => '21',
'quantity' => '1',
'price' => 10.10,
'priceExcl' => 5,
],
],
]);
Need more?
- More examples can be found on our GitHub page in the "examples" folder.
Contribute
We appreciate it when developers contribute to improving the Buckaroo plugins.
If you want to contribute as well, then please follow our Contribution Guidelines.
Versioning
- MAJOR: Breaking changes that require additional testing/caution
- MINOR: Changes that should not have a big impact
- PATCHES: Bug and hotfixes only
Updated 2 months ago