承接 ifcon/laravel-payment-gateway 相关项目开发

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

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

ifcon/laravel-payment-gateway

Composer 安装命令:

composer require ifcon/laravel-payment-gateway

包简介

Laravel payment gateway drivers for SenangPay, ToyyibPay, CHIP, DOKU, KiplePay, and PayPal

README 文档

README

Laravel payment gateway package supporting SenangPay, ToyyibPay, CHIP, DOKU, KiplePay, and PayPal.

Requirements

  • PHP ^8.0
  • Laravel 9, 10, 11, 12, or 13

Installation

composer require ifcon/laravel-payment-gateway

The service provider is auto-discovered. Publish the config:

php artisan vendor:publish --tag=payment-gateway-config

Configuration

Set PAYMENT_DRIVER in your .env to select the active gateway:

PAYMENT_DRIVER=senangpay

SenangPay

PAYMENT_DRIVER=senangpay
SENANGPAY_MERCHANT_ID=your-merchant-id
SENANGPAY_SECRET_KEY=your-secret-key
SENANGPAY_SANDBOX=true
SENANGPAY_HASH_TYPE=sha256

Supported SENANGPAY_HASH_TYPE values: md5, sha256 (or any algorithm accepted by hash_hmac).

ToyyibPay

PAYMENT_DRIVER=toyyibpay
TOYYIBPAY_USER_SECRET_KEY=your-user-secret-key
TOYYIBPAY_CATEGORY_CODE=your-category-code
TOYYIBPAY_RETURN_URL=https://yourapp.com/payment/return/toyyibpay
TOYYIBPAY_CALLBACK_URL=https://yourapp.com/payment/callback/toyyibpay
TOYYIBPAY_SANDBOX=true

CHIP

PAYMENT_DRIVER=chip
CHIP_BRAND_ID=your-brand-id
CHIP_API_KEY=your-api-key
CHIP_ENDPOINT=https://gate.chip-in.asia
CHIP_SUCCESS_REDIRECT=https://yourapp.com/payment/return/chip
CHIP_SUCCESS_CALLBACK=https://yourapp.com/payment/callback/chip
CHIP_FAILURE_REDIRECT=https://yourapp.com/payment/failed

DOKU

PAYMENT_DRIVER=doku
DOKU_SANDBOX=false
DOKU_CLIENT_ID=your-client-id
DOKU_API_KEY=your-api-key
DOKU_EXPIRED_HOURS=24
DOKU_BACK_TO_MERCHANT_URL=https://yourapp.com/payment/return/doku
DOKU_BACK_TO_MERCHANT_CANCEL_URL=https://yourapp.com/payment/cancel/doku
DOKU_BACK_TO_MERCHANT_RESULT_URL=https://yourapp.com/payment/result/doku

KiplePay

PAYMENT_DRIVER=kiplepay
KIPLEPAY_SANDBOX=true
KIPLEPAY_MERCHANT_ID=your-merchant-id
KIPLEPAY_SECRET_KEY=your-secret-key
KIPLEPAY_RETURN_URL=https://yourapp.com/payment/return/kiplepay
KIPLEPAY_CALLBACK_URL=https://yourapp.com/payment/callback/kiplepay

PayPal

PAYMENT_DRIVER=paypal
PAYPAL_CLIENT_ID=your-client-id
PAYPAL_SECRET=your-secret
PAYPAL_MODE=sandbox
PAYPAL_RETURN_URL=https://yourapp.com/payment/return/paypal
PAYPAL_CANCEL_URL=https://yourapp.com/payment/cancel/paypal

Basic Usage

Initiating a payment

use Ifcon\PaymentGateway\PaymentGatewayService;

$gateway = new PaymentGatewayService(config('payment_gateway.driver'));

$result = $gateway->driver
    ->setSendPaymentDetails(
        description: 'Order #1234',
        amount: 99.90,
        orderId: 'ORD-1234',
        to: 'Ahmad bin Ali',
        email: 'ahmad@example.com',
        phone: '0123456789'
    )
    ->processPayment();

// Redirect the user
return redirect($result['redirect_url']);

processPayment() returns:

KeyTypeDescription
redirect_urlstring\|nullURL to redirect the user to the gateway
billcodestring\|nullGateway reference (ToyyibPay bill code, CHIP purchase ID, etc.)
payment_formstring\|nullRaw HTML form (KiplePay only — render and auto-submit)

Handling the return / callback

public function handleReturn(Request $request)
{
    $gateway = new PaymentGatewayService(config('payment_gateway.driver'));

    $result = $gateway->driver->payment_return($request);

    if ($result['status'] === 1) {
        // Payment successful
        // $result['txn_ref'] contains the gateway transaction reference
    } else {
        // Payment failed — $result['message'] explains why
    }
}

Checking payment status by order ID

$result = $gateway->driver->payment_check($orderId);

if ($result['status'] === 1) {
    $transactionRef = $result['txn_ref'];
}

payment_check() / payment_return() always return:

KeyTypeDescription
statusint1 = success, 0 = failed
txn_refstringGateway transaction reference (on success)
messagestringHuman-readable result message

Dependency Injection

The service is bound in the container. You can inject it directly:

use Ifcon\PaymentGateway\PaymentGatewayService;

public function __construct(private PaymentGatewayService $gateway) {}

This resolves the driver from payment_gateway.driver config automatically.

Custom Drivers

Register a custom driver before instantiating the service:

use Ifcon\PaymentGateway\PaymentGatewayService;
use App\Payments\MyCustomDriver;

PaymentGatewayService::extend('mycustom', MyCustomDriver::class);

$gateway = new PaymentGatewayService('mycustom');

The custom driver must implement Ifcon\PaymentGateway\Contracts\DriverContract:

use Ifcon\PaymentGateway\Contracts\DriverContract;
use Illuminate\Http\Request;

class MyCustomDriver implements DriverContract
{
    public function setSendPaymentDetails(
        $description, $amount, $orderId, $to, $email, $phone,
        $billName = null, $billCode = null
    ) {
        // store payment details, return $this
    }

    public function processPayment(): array
    {
        // return ['redirect_url' => '...', 'billcode' => '...']
    }

    public function payment_return(Request $request): array
    {
        // return ['status' => 1, 'txn_ref' => '...', 'message' => '...']
    }

    public function payment_check($order_id): array
    {
        // return ['status' => 1, 'txn_ref' => '...']
    }
}

Driver Notes

ToyyibPay — pre-created bills

If you created a bill externally and already have a bill code, skip bill creation:

$gateway->driver
    ->setSendPaymentDetails(...)
    ->setBillCode('ABC123')
    ->processPayment();

SenangPay — hash verification

Verify the return signature before trusting the response:

if (! $gateway->driver->checkIfReturnHashCorrect($request)) {
    abort(400, 'Invalid signature');
}

KiplePay — HTML form response

KiplePay returns a self-submitting HTML form instead of a redirect URL:

$result = $gateway->driver->setSendPaymentDetails(...)->processPayment();

return response($result['payment_form']); // render directly

DOKU / SenangPay — debug mode

Pass true to payment_check to dump the raw gateway response during development:

$gateway->driver->payment_check($orderId, debug: true);

ifcon/laravel-payment-gateway 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-11