Laravel Wrapper

Buckaroo is a Payment Service Provider used by many companies to securely handle payments, subscriptions, and invoices. The Buckaroo SDK is a modern, open-source library that makes it easier to integrate Buckaroo's services into PHP apps. The SDK also supports webhooks.

GitHub Repository


Requirements

  • A Buckaroo account (Dutch or English)
  • PHP >= 7.4
  • Up-to-date OpenSSL (or other SSL/TLS toolkit)

Composer installation

By far the easiest way to install the Laravel Buckaroo client is to require it with Composer.
To install the Laravel Buckaroo Wrapper, you can use Composer by running the following command:

$ composer require buckaroo/laravel-buckaroo:^1.0

{
    "require": {
        "buckaroo/laravel-laravel": "^1.0"
    }
}

Usage

Create and config the Buckaroo object. You can find your credentials in plaza WEBSITE_KEY and SECRET_KEY.

To use the Laravel Buckaroo Wrapper in your application, you need to add the following parameters to your .env file:

BPE_WEBSITE_KEY=
BPE_SECRET_KEY=
BPE_MODE=

You should replace the empty values with the appropriate keys provided by Buckaroo.
Add the service provider in your config/app.php file:

Buckaroo\Laravel\BuckarooServiceProvider::class,

Add the class Aliases in your config/app.php file:

'Buckaroo' => Buckaroo\Laravel\Facades\Buckaroo::class

Then run the following command to publish the Buckaroo config file:

php artisan vendor:publish --provider="Buckaroo\Laravel\BuckarooServiceProvider"

Buckaroo service provider loads its database migrations, so remember to run the necessary migrations to update your database after installing the package.

php artisan migrate

The $buckaroo object is the instance of the Buckaroo PHP SDK. The method method is called with the argument "creditcard", which indicates that the payment method used is a credit card. The pay method is called with an associative array as its argument, which contains the details of the payment.

  • name: the name of the credit card payment method (e.g. "visa").
  • amountDebit: the amount of the payment.
  • invoice: the invoice number associated with the payment.
  • pushURL: the URL to which Buckaroo will send a push notification when the payment is processed.

This is set to the result of the route method with the argument "buckaroo.push".
This code initiates a payment using the credit card payment method with the specified details.

Buckaroo::api()->method('creditcard')->pay([
    'name'          => 'visa',
    'amountDebit'   => 10.25,
    'invoice'       => 'inv-123',
    'pushURL'      => route('buckaroo.push')
]);

Validation

Laravel validation is used to ensure the data passed to the payment method is valid and secure. This validation checks the parameters passed to the payment method and confirms that they are correct and complete. This helps to prevent errors and guarantees that payments are processed accurately.

use App\BuckarooLaravelWrapper\src\Http\Requests\Payments\CreditCard\CreditCardPayRequest;

    public function preparePayment(CreditCardPayRequest $request)
    {
        $response = \Buckaroo::api()->method('creditcard')->pay($request->all());

        return response($response->toArray());
    }

Behind the scenes, this will register a POST route to a controller provided by this package. Because the app that sends webhooks to you has no way of getting a CSRF token, you must add that route to the except array of the VerifyCsrfToken middleware:

protected $except = [
    'buckaroo/*',
];

Conclusion

By following the steps outlined in this documentation, you can easily integrate Laravel validation with the Buckaroo PHP SDK in your application. This will allow you to securely process payments, subscriptions, and unpaid invoices with the Buckaroo platform. Remember to add the BPE_WEBSITE_KEY, BPE_SECRET_KEY, and BPE_MODE to your .env file and run:

php artisan vendor:publish --provider="Buckaroo\Laravel\BuckarooServiceProvider"
php artisan migrate

Versioning

178474134-f4c3976d-653c-4ca1-bcd1-48bf6d489196


  • MAJOR: Breaking changes that require additional testing/caution
  • MINOR: Changes that should not have a big impact
  • PATCHES: Bug and hotfixes only