承接 madarit/laravel-kashier 相关项目开发

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

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

madarit/laravel-kashier

Composer 安装命令:

composer require madarit/laravel-kashier

包简介

Laravel package for integrating Kashier payment gateway

README 文档

README

A Laravel package for integrating Kashier payment gateway into your Laravel application with ease.

Features

  • ✅ Easy installation via Composer
  • ✅ Auto-discovery for Laravel 5.5+
  • ✅ Support for both test and live modes
  • ✅ iFrame and Hosted Payment Page (HPP) integration
  • ✅ Automatic signature validation
  • ✅ Customizable views
  • ✅ Facade support for easy access

Requirements

  • PHP 8.0 or higher
  • Laravel 9.0, 10.0, or 11.0

Installation

1. Install via Composer

composer require madarit/laravel-kashier

The package will automatically register itself via Laravel's package auto-discovery.

2. Publish Configuration

Publish the configuration file to customize settings:

php artisan vendor:publish --tag=kashier-config

This will create config/kashier.php in your application.

3. Publish Views (Optional)

If you want to customize the payment views:

php artisan vendor:publish --tag=kashier-views

Views will be published to resources/views/vendor/kashier/.

4. Configure Environment Variables

Add the following to your .env file:

KASHIER_MODE=test
KASHIER_TEST_API_KEY=your-test-api-key
KASHIER_TEST_MID=your-test-mid
KASHIER_LIVE_API_KEY=
KASHIER_LIVE_MID=

Replace the test credentials with your actual Kashier credentials from your merchant dashboard.

Usage

Using the Facade

use Madarit\LaravelKashier\Facades\Kashier;

// Generate order hash
$hash = Kashier::generateOrderHash($orderId, $amount, $currency);

// Get HPP URL
$hppUrl = Kashier::getHppUrl($orderId, $amount, $currency, $callbackUrl);

// Validate callback signature
$isValid = Kashier::validateSignature($request->all());

// Get configuration
$config = Kashier::getConfig();
$mode = Kashier::getMode();
$mid = Kashier::getMid();

Using Dependency Injection

use Madarit\LaravelKashier\KashierService;

class YourController extends Controller
{
    private $kashier;

    public function __construct(KashierService $kashier)
    {
        $this->kashier = $kashier;
    }

    public function processPayment()
    {
        $hash = $this->kashier->generateOrderHash('123', '100', 'EGP');
        // ...
    }
}

Default Routes

The package automatically registers these routes:

  • GET /kashier/checkout - Display checkout page
  • GET /kashier/iframe/callback - iFrame payment callback
  • GET /kashier/hpp/callback - Hosted Payment Page callback

Accessing the Demo

After installation, visit:

http://your-app.test/kashier/checkout

Test Cards

  • Success: 5111 1111 1111 1118 - 06/28 - 100
  • Success 3D Secure: 5123 4500 0000 0008 - 06/28 - 100
  • Failure: 5111 1111 1111 1118 - 05/28 - 102

Customization

Custom Views

After publishing views, you can customize them in resources/views/vendor/kashier/:

  • payment/checkout.blade.php - Checkout page
  • payment/success.blade.php - Success page
  • payment/error.blade.php - Error page

Custom Controller

You can create your own controller and use the KashierService:

use Madarit\LaravelKashier\KashierService;
use Illuminate\Http\Request;

class CustomPaymentController extends Controller
{
    public function initiatePayment(KashierService $kashier)
    {
        $orderId = uniqid('order_');
        $amount = '100.00';
        $currency = 'EGP';
        
        $hppUrl = $kashier->getHppUrl(
            $orderId, 
            $amount, 
            $currency, 
            route('payment.callback')
        );
        
        return redirect($hppUrl);
    }
    
    public function handleCallback(Request $request, KashierService $kashier)
    {
        if ($kashier->validateSignature($request->all())) {
            if ($request->get('paymentStatus') === 'SUCCESS') {
                // Handle successful payment
                return view('payment-success');
            }
        }
        
        return view('payment-failed');
    }
}

Package Structure

laravel-kashier/
├── src/
│   ├── Http/
│   │   └── Controllers/
│   │       └── PaymentController.php
│   ├── Facades/
│   │   └── Kashier.php
│   ├── KashierService.php
│   └── KashierServiceProvider.php
├── config/
│   └── kashier.php
├── resources/
│   └── views/
│       └── payment/
│           ├── checkout.blade.php
│           ├── success.blade.php
│           └── error.blade.php
├── routes/
│   └── web.php
├── composer.json
└── README.md

API Reference

KashierService Methods

generateOrderHash($orderId, $amount, $currency, $customerReference = null)

Generate hash for order verification.

validateSignature($queryParams)

Validate callback signature for security.

getHppUrl($orderId, $amount, $currency, $callbackUrl, $allowedMethods = 'card,wallet,bank_installments')

Generate Hosted Payment Page URL.

getConfig()

Get current configuration (test/live).

getMode()

Get current mode (test/live).

getMid()

Get merchant ID.

getBaseUrl()

Get Kashier base URL.

Payment Flow

iFrame Payment

  1. User visits /payment/checkout
  2. Clicks the Kashier payment button
  3. Payment popup opens on the same page
  4. After payment, redirects to /payment/iframe/callback
  5. Signature is validated
  6. User sees success or error page

Hosted Payment Page (HPP)

  1. User visits /payment/checkout
  2. Clicks "Pay with Hosted Payment Page" link
  3. Redirected to Kashier's hosted page
  4. After payment, redirected back to /payment/hpp/callback
  5. Signature is validated
  6. User sees success or error page

Security

  • All callbacks validate the signature using HMAC SHA256
  • Never expose your API keys in frontend code
  • Always validate signatures before processing payments
  • Log failed signature validations for security monitoring

Going Live

  1. Obtain live credentials from Kashier merchant dashboard
  2. Update .env file with live credentials
  3. Change KASHIER_MODE to live
  4. Test thoroughly before processing real payments

Support

For issues or questions:

About the Developer

This package is developed and maintained by Madar IT - a software development company specializing in creating robust and scalable solutions for businesses.

Madar IT

Madar IT provides professional software development services with expertise in:

  • Laravel & PHP Development
  • Payment Gateway Integration
  • API Development & Integration
  • Enterprise Application Development
  • Custom Software Solutions

We are committed to delivering high-quality, secure, and well-documented packages that make developers' lives easier.

Connect With Us

  • GitHub: github.com/madarit
  • Website: Contact us for custom development and integration services

For package-related issues, please open an issue on the GitHub repository. For custom development or integration services, feel free to reach out directly.

License

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

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

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

它主要适用于以下技术方向: 「payment」 「gateway」 「laravel」 「Egypt」 「kashier」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-24