定制 amedev/smart-payment 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

amedev/smart-payment

最新稳定版本:1.0.3

Composer 安装命令:

composer require amedev/smart-payment

包简介

A smart and extensible Laravel payment system

README 文档

README

SmartPayment is a flexible and extensible Laravel package for managing payment workflows. It follows clean architecture principles and allows dynamic resolution of gateways and models.

📦 Installation

Install the package via Composer:

composer require amedev/smart-payment

Then publish the package components:

php artisan vendor:publish --tag=smart-payment-config         # Configuration file
php artisan vendor:publish --tag=smart-payment-migrations     # Database migrations
php artisan vendor:publish --tag=smart-payment-models         # Default models
php artisan vendor:publish --tag=smart-payment-translations   # Translations (e.g. Farsi)

Run migrations:

php artisan migrate

⚙️ Configuration

The configuration file will be available at config/smart-payment.php:

return [
    'default' => 'zarinpal', // Default payment gateway

    'gateways' => [
        'zarinpal' => \SmartPayment\Gateways\ZarinpalGateway::class,
        // You can register your own gateway classes like:
        // 'idpay' => \App\Gateways\CustomIDPayGateway::class,
    ],

    'models' => [
        'order' => \App\Models\Order::class,           // Your custom Order model
        'transaction' => \App\Models\Transaction::class, // Your custom Transaction model
    ],
];

🚀 Making a Payment

To initiate a payment request, make a POST call to /api/payment/pay:

POST /api/payment/pay
Content-Type: application/json

Example JSON body:

{
  "amount": 10000,
  "gateway": "zarinpal",
  "callback_url": "https://your-site.com/payment/callback",
  "meta": {
    "description": "Order #123",
    "email": "user@example.com",
    "mobile": "09123456789"
  }
}

This will create a transaction and redirect the user to the payment gateway.

🔄 Payment Callback

After payment, the user is redirected to the callback URL:

GET /payment/callback

The package will verify the payment status and complete the transaction accordingly.

🛠 Artisan Utilities

To automatically fix namespaces for your custom models (especially if you override default ones):

php artisan smart-payment:fix-model-namespace

🌐 Translations

You can customize user-facing messages using the published translation file:

resources/lang/vendor/smart-payment/fa/messages.php

📌 Notes

  • The package is UI-agnostic: ideal for REST APIs or frontend frameworks like Vue or React.
  • You can extend it with custom gateways by implementing your own Gateway class and registering it.
  • The meta field allows storing custom order-related data like user contact or description.

统计信息

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

GitHub 信息

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

其他信息

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