buckaroo/laravel

Laravel Wrapper package for Buckaroo Payments Gateway

1.1.0 2024-04-04 05:20 UTC

This package is auto-updated.

Last update: 2024-05-13 14:28:30 UTC


README

68747470733a2f2f7777772e6275636b61726f6f2e6e6c2f6d656469612f333837372f6c61726176656c2d6c6f676f2d6769746875622e706e67

Laravel Buckaroo Payment Integration

68747470733a2f2f7777772e6275636b61726f6f2e6e6c2f6d656469612f333837382f6c61726176656c2d6578616d706c65332e706e67

Index

Introduction

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.

Installation

To install the Laravel Buckaroo Wrapper, you can use Composer by running the following command:

  • 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.

$ composer require buckaroo/laravel:^1.0

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

Usage

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.

Laravel 11.0

Add the service provider in your bootstrap/providers.php file:

  return [
      ...,
      Buckaroo\Laravel\BuckarooServiceProvider::class,
  ];

Before Laravel < 11.0

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.

  • 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')
]);

Find our full documentation online on dev.buckaroo.nl.

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

to make sure everything runs smoothly.

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

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

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

Additional information

License

Laravel Buckaroo Wrapper is open-sourced software licensed under the MIT license.