efati/payment-gateway 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

efati/payment-gateway

Composer 安装命令:

composer require efati/payment-gateway

包简介

A reusable, multi-gateway Laravel payment package.

README 文档

README

A reusable, multi-gateway Laravel payment package supporting Iranian banking system.

Features

  • Multiple Gateways: Support for Zarinpal, Mellat, and more.
  • Dynamic Access: Access specific gateways easily via Facade (e.g., Payment::zarinpal()).
  • Customizable Models: Publish and customize Bank, Gateway, and Transaction models.
  • Database Support: Includes migrations and seeders for banks and gateways.
  • DTO Support: Uses Data Transfer Objects for consistent request/response handling.

Requirements

  • PHP ^8.2
  • Laravel ^11.0 | ^12.0

Installation

Install the package via composer:

composer require efati/payment-gateway

Configuration

Run the installation command to publish the config, migrations, seeders, models, and core logic:

php artisan payment:install

This command will:

  1. Publish configuration to config/payment.php
  2. Publish migrations to database/migrations
  3. Publish seeders to database/seeders
  4. Publish models to app/Models
  5. Scaffold Core Logic: Copy Contracts, Gateways, DTOs, and Managers to app/Payment/

Run migrations:

php artisan migrate

Seed the database with banks and gateways:

php artisan db:seed --class=PaymentGateway\Database\Seeders\BankSeeder
php artisan db:seed --class=PaymentGateway\Database\Seeders\GatewaySeeder

Usage

Basic Usage

The core logic is now located in app/Payment. You can customize any part of it.

Use the Payment facade to initialize a payment:

use App\Payment\Managers\PaymentManager; // Or use Facade
use PaymentGateway\Facades\Payment;
use App\Payment\DTOs\PaymentRequestDTO;

$dto = new PaymentRequestDTO(
    amount: 10000,
    orderId: 'ORD-123',
    callbackUrl: route('payment.callback'),
    description: 'Order payment',
    mobile: '09123456789'
);

$result = Payment::initialize($dto);

Dynamic Gateway Selection

// Use Zarinpal
Payment::zarinpal()->initialize($dto);

Customization

Since the code is in app/Payment, you can directly edit:

  • app/Payment/Gateways/Zarinpal.php
  • app/Payment/Managers/PaymentManager.php
  • app/Payment/DTOs/PaymentRequestDTO.php

The package automatically detects if these files exist in app/Payment and uses them instead of the package defaults.

Verification

On your callback route:

use PaymentGateway\Facades\Payment;
use PaymentGateway\DTOs\PaymentVerifyDTO;

$dto = new PaymentVerifyDTO(
    amount: 10000,
    authority: request('Authority'), // or whatever the gateway sends
    gateway: 'zarinpal'
);

try {
    $receipt = Payment::verify($dto);
    // $receipt['ref_id'], $receipt['tracking_code']

    return "Payment Successful! Ref ID: " . $receipt['ref_id'];
} catch (\PaymentGateway\Exceptions\PaymentException $e) {
    return "Payment Failed: " . $e->getMessage();
}

Customizing Models

If you need to extend or modify the models (e.g., to add relationships), you can publish them to your app/Models directory:

php artisan vendor:publish --tag=efati-payment-models

This will copy Bank, PaymentGateway, and PaymentTransaction models to app/Models. The package will automatically use your published models if you update the config/payment.php file:

// config/payment.php
'models' => [
    'bank' => \App\Models\Bank::class,
    'gateway' => \App\Models\PaymentGateway::class,
    'transaction' => \App\Models\PaymentTransaction::class,
],

License

The MIT License (MIT).

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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