PHP SDK
About
Buckaroo is the the Payment Service Provider for all your online payments with more than 15,000 companies relying on Buckaroo's platform to securely process their payments, subscriptions and unpaid invoices. Buckaroo developed their own PHP SDK. The SDK is a modern, open-source PHP library that makes it easy to integrate your PHP application with Buckaroo's services.
Start accepting payments today with Buckaroo.
Requirements
To use the Buckaroo API client, the following things are required:
GitHub repository
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 in order 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.
# 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
]);
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,
]);
ApplePay
There are two methods for integrating ApplePay into your website. The first method involves incorporating our JavaScript library, while the second method utilizes 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.
# 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 incorporate 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.
# Create a Bancontact payment
$buckaroo->method('bancontactmrcash')->pay([
'invoice' => uniqid(),
'amountDebit' => 10.10,
'saveToken' => true,
]);
Encrypted version:
# 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(),
]);
Bilink
# 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' => 'test@buckaroo.nl',
],
'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 examples?
More examples can be found on our GitHub page in the "examples" folder.
Contribute
We really appreciate it when developers contribute to improve 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