yansongda/laravel-pay
yansongda/laravel-pay 是 Laravel/Lumen 的聚合支付扩展,基于 yansongda/pay,支持支付宝、微信、抖音支付、江苏银行(e融支付)等。提供 Facade 调用与统一配置,快速创建订单、发起网页/公众号/小程序等支付。
Pros:
Pay facade provides a clean, fluent interface (Pay::alipay()->web($order)), reducing boilerplate and improving readability. This is particularly useful in a Laravel ecosystem where facades are idiomatic.paid, failed events) for async workflows (e.g., inventory updates, notifications).Cons:
config/laravel-pay.php) may grow unwieldy as more gateways or custom logic are added. A per-gateway config structure could improve maintainability.Laravel/Lumen Compatibility:
PHP 8.0+: Leverages modern PHP features (e.g., named arguments, typed properties), reducing compatibility risks with legacy systems.
Database Agnostic: No ORM or schema assumptions, making it adaptable to any Laravel database setup.
Key Dependencies:
Gateway-Specific Quirks:
yansongda/pay repo for updates.~3.7.0) to avoid major version bumps.Idempotency: Payment systems require idempotency to handle duplicate requests. The package supports out_trade_no for order deduplication, but custom logic may be needed for edge cases (e.g., retries).
Error Handling:
Testing Complexity:
Laravel Ecosystem:
Pay facade integrates naturally with Laravel’s idiomatic usage (e.g., Pay::alipay()->web()).PaymentProcessed events).Lumen:
Third-Party Integrations:
Http\Middleware\VerifyCsrfToken or custom middleware can validate these.Log::error($e->getMessage())) for payment failures.composer require yansongda/laravel-pay:~3.7.0
php artisan vendor:publish --provider="Yansongda\LaravelPay\PayServiceProvider" --tag=laravel-pay
.env (e.g., ALIPAY_APP_ID, WECHAT_MCH_ID).routes/web.php for async notifications).PaymentTest class).~3.7.0 to ~4.0.0 may require review of breaking changes (check release notes).Yansongda\LaravelPay\Gateways\AbstractGateway).stripe() method to the facade for multi-gateway support.How can I help you explore Laravel packages today?