Laravel Wrapper

Laravel Wrapper logo

The Buckaroo Laravel Wrapper is an open source package that adds Buckaroo payments to a Laravel application. It is built on the PHP SDK and adds what a Laravel application expects: a service provider, a facade, a configuration file, a transactions table, ready-made routes for the return page and push messages, and events you can listen to.

Running a store on an e-commerce platform? Use one of our ready-made plugins and apps instead. This package is for custom Laravel applications.


What the wrapper does for you

PHP SDKLaravel Wrapper
Start payments, refunds and capturesYesYes
Configuration through .envNoYes
Stores every transaction in your databaseNoYes
Push route with signature validationYou build itIncluded
Updates the stored transaction from the push messageYou build itIncluded
Laravel events for payments and refundsNoYes

Requirements

RequirementDetails
Buckaroo accountCreate an account if you do not have one yet
PHP8.0 or higher
Laravel9 or higher
ComposerTo install the package. The PHP SDK is installed with it

Installation

Install the package with Composer:

composer require buckaroo/laravel

Publish the configuration file, the migration and the routes file, then create the transactions table:

php artisan buckaroo:publish
php artisan migrate

Laravel discovers the service provider automatically.

The source code is on GitHub.


Quick start

Add your keys to .env:

BPE_WEBSITE_KEY=your_store_key
BPE_SECRET_KEY=your_secret_key
BPE_MODE=test

Then start a payment and send the customer to the payment page:

use Buckaroo\Laravel\Api\PayService;
use Buckaroo\Laravel\Handlers\PaymentMethodFactory;

[$response, $transaction] = PayService::make(
    PaymentMethodFactory::make('ideal')->setPayload([
        'invoice'     => 'INV-1001', // must be unique per payment
        'order'       => 'ORD-1001',
        'amountDebit' => 10.00,
        'currency'    => 'EUR',
        'description' => 'Order #1001',
    ])
)->pay();

if ($response->hasRedirect()) {
    return redirect()->away($response->getRedirectUrl());
}

That starts an iDEAL | Wero payment in test mode and stores it in the buckaroo_transactions table. Before the result can reach your application, exclude the push route from CSRF verification. Continue with these pages in order:

  1. Configuration: credentials, CSRF, routes and the transaction model
  2. Payments: start a payment, read the response and handle errors
  3. Push messages and events: act on the payment result
  4. Order management: refunds, captures and stored transactions
  5. Test and go live: what to test and how to switch to production

Versioning

The package follows semantic versioning:

PartMeaning
MAJORBreaking changes that require additional testing and caution
MINORNew functionality with limited impact
PATCHBug fixes and hotfixes only

Every change is recorded on the releases page.


Contribute

The package is open source under the MIT license, and contributions are welcome through a pull request on GitHub.



Did this page help you?