The documentation explains how to integrate Laravel validation with the Buckaroo PHP SDK in your application. 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.
To install the Laravel Buckaroo Wrapper, you can use Composer by running the following command:
By far the easiest way to install the Laravel Buckaroo client is to require it with Composer.
$ composer require buckaroo/laravel:^1.0
{
"require": {
"buckaroo/laravel": "^1.0"
}
}
Create and config the Buckaroo object. You can find your credentials in plaza WEBSITE_KEY and SECRET_KEY
In order 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 bootstrap/providers.php file:
return [
...,
Buckaroo\Laravel\BuckarooServiceProvider::class,
];
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 own 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.
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')
]);
Find our full documentation online on dev.buckaroo.nl.
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/*',
];
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
to make sure everything runs smoothly.
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.
Laravel Buckaroo Wrapper is open-sourced software licensed under the MIT license.