承接 klump/laravel-klump 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

klump/laravel-klump

Composer 安装命令:

composer require klump/laravel-klump

包简介

Klump Buy Now Pay Later integration for Laravel

README 文档

README

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

Requirements

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

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

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

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:

<!-- Add this in your layout file or view -->
<script src="https://js.useklump.com/klump.js" defer></script>

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

<livewire:klump-checkout 
    :order="$order" 
    :items="$items" 
    :customer="$customer" 
/>

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

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

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

Custom Checkout Component

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

<?php

namespace App\Http\Livewire;

use Klump\LaravelKlump\Http\Livewire\KlumpCheckout;

class CustomKlumpCheckout extends KlumpCheckout
{
    public function checkout()
    {
        // Custom logic before checkout
        
        parent::checkout();
        
        // Custom logic after checkout
    }
}

Then register your custom component in your AppServiceProvider:

Livewire::component('custom-klump-checkout', CustomKlumpCheckout::class);

Webhook Handling

To handle Klump webhooks, you can create a webhook controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Klump\LaravelKlump\Services\KlumpService;

class KlumpWebhookController extends Controller
{
    protected $klumpService;
    
    public function __construct(KlumpService $klumpService)
    {
        $this->klumpService = $klumpService;
    }
    
    public function handle(Request $request)
    {
        // Verify webhook signature
        if (!$this->klumpService->verifyWebhook($request)) {
            return response()->json(['error' => 'Invalid signature'], 400);
        }
        
        $payload = $request->all();
        $event = $payload['event'];
        
        // Handle different webhook events
        switch ($event) {
            case 'payment.successful':
                // Handle successful payment
                break;
            case 'payment.failed':
                // Handle failed payment
                break;
            // Add more event handlers as needed
        }
        
        return response()->json(['status' => 'success']);
    }
}

Then register the webhook route in your routes/web.php or routes/api.php:

Route::post('webhooks/klump', [KlumpWebhookController::class, 'handle']);

Testing

composer test

Security

If you discover any security related issues, please email richienabuk@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

klump/laravel-klump 适用场景与选型建议

klump/laravel-klump 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 klump/laravel-klump 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 klump/laravel-klump 我们能提供哪些服务?
定制开发 / 二次开发

基于 klump/laravel-klump 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-19