PHPackages                             klump/laravel-klump - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. klump/laravel-klump

ActiveLibrary[Payment Processing](/categories/payments)

klump/laravel-klump
===================

Klump Buy Now Pay Later integration for Laravel

1.0.0(1y ago)012MITPHPPHP ^8.0

Since Mar 18Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/Klump-Inc/laravel-klump)[ Packagist](https://packagist.org/packages/klump/laravel-klump)[ RSS](/packages/klump-laravel-klump/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

Klump Laravel Payment Package
=============================

[](#klump-laravel-payment-package)

A Laravel package for integrating Klump's Buy Now Pay Later (BNPL) payment solution into your Laravel applications.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Laravel 10.0 or higher
- Livewire 3.0 or higher

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require klump/laravel-klump
```

After installing the package, publish the configuration file:

```
php artisan vendor:publish --provider="Klump\LaravelKlump\KlumpServiceProvider"
```

Configuration
-------------

[](#configuration)

After publishing the configuration, you can find the config file at `config/klump.php`. You need to set your Klump API credentials in your `.env` file:

```
KLUMP_PUBLIC_KEY=your_public_key
KLUMP_SECRET_KEY=your_secret_key
KLUMP_ENVIRONMENT=sandbox # or production

```

Basic Usage
-----------

[](#basic-usage)

### Setting Up the Checkout Component

[](#setting-up-the-checkout-component)

The package provides a Livewire component for handling Klump checkout. To use it, you need to include the Klump JavaScript SDK in your layout or view:

```

```

Then, you can use the Livewire component in your blade files:

```

```

Where:

- `$order` is an array containing order information (id, amount, currency, etc.)
- `$items` is an array of items in the order
- `$customer` is an array with customer details

### Example Controller

[](#example-controller)

```
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CheckoutController extends Controller
{
    public function checkout()
    {
        $order = [
            'id' => 'ORD-' . uniqid(),
            'amount' => 50000, // Amount in kobo/cents
            'currency' => 'NGN',
            'redirect_url' => route('payment.success'),
        ];

        $items = [
            [
                'name' => 'Product Name',
                'unit_price' => 50000, // Price in kobo/cents
                'quantity' => 1,
                'description' => 'Product description',
            ],
        ];

        $customer = [
            'name' => 'John Doe',
            'email' => 'john@example.com',
            'phone' => '08012345678',
        ];

        return view('checkout', compact('order', 'items', 'customer'));
    }

    public function success(Request $request)
    {
        // Handle successful payment
        return view('payment.success');
    }
}
```

### Handling Checkout Events

[](#handling-checkout-events)

The Klump checkout component dispatches several events that you can listen for:

- `onSuccess`: Called when payment is successful
- `onError`: Called when payment fails
- `onClose`: Called when the checkout modal is closed

These events are already configured in the Livewire component, but you can customize them by extending the component.

Advanced Usage
--------------

[](#advanced-usage)

### Custom Checkout Component

[](#custom-checkout-component)

If you need to customize the checkout process, you can extend the `KlumpCheckout` component:

```
