lzbrest / payment-sdk
There is no license information available for the latest version (0.0.3) of this package.
0.0.3
2026-01-27 07:50 UTC
Requires
- php: ^7.4|^8.0
- alipaysdk/easysdk: ^2.0
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^8.0|^9.0|^10.0
- stripe/stripe-php: ^7.0
- wechatpay/wechatpay: ^1.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.0
This package is not auto-updated.
Last update: 2026-04-08 11:46:54 UTC
README
安装
composer require lzbrest/payment-sdk
如果包版本还在开发阶段:
composer require lzbrest/payment-sdk:@dev
配置
发布配置文件:
php artisan vendor:publish --provider="Lzbrest\PaymentSdk\PaymentServiceProvider" --tag=config
配置文件路径:config/payment.php
默认支持驱动:
- alipay
- stripe
- paypal
可通过环境变量指定默认驱动与各驱动的接口地址:
PAYMENT_DRIVER=alipay ALIPAY_ENDPOINT=http://localhost:8080/api/payment WECHAT_ENDPOINT=http://localhost:8080/api/payment STRIPE_ENDPOINT=http://localhost:8080/api/payment PAYPAL_ENDPOINT=http://localhost:8080/api/payment
使用方式
Facade
use Payment; $result = Payment::pay([ 'order_id' => 1001, 'amount' => 199, ]);
指定驱动:
$result = Payment::pay([ 'order_id' => 1001, 'amount' => 199, ], 'stripe');
说明:如果不传 $driver,会使用 PAYMENT_DRIVER 配置的默认驱动;未配置默认驱动会抛出异常。
返回结构
pay() 返回数组:
status:HTTP 状态码body:响应原始内容json:解析后的 JSON(若非 JSON 则为 null)
测试
vendor/bin/phpunit