codeglen/laravel-binancepay
最新稳定版本:v1.0.0
Composer 安装命令:
composer require codeglen/laravel-binancepay
包简介
A Laravel package for integrating the Binance Pay API.
README 文档
README
codeglen/laravel-binancepay is a Laravel package for Binance Pay order creation, order query, and webhook signature verification.
Compatibility
- Laravel 10
- Laravel 11
- Laravel 12
- Laravel 13
Installation
composer require codeglen/laravel-binancepay:dev-main
Publish config:
php artisan vendor:publish --tag=binancepay-config
Configuration
Add environment values:
BINANCE_PAY_BASE_URL=https://bpay.binanceapi.com BINANCE_PAY_CERTIFICATE_SN=your_binance_certificate_sn BINANCE_PAY_SECRET_KEY=your_binance_secret_key BINANCE_PAY_WEBHOOK_ENABLED=true BINANCE_PAY_WEBHOOK_PATH=binancepay/webhook
Usage
Create order:
use Codeglen\BinancePay\Facades\BinancePay; $response = BinancePay::createOrder([ 'merchantTradeNo' => 'ORDER-1001', 'orderAmount' => 25.5, 'currency' => 'USDT', 'goods' => [ 'goodsType' => '01', 'goodsCategory' => 'D000', 'referenceGoodsId' => 'SKU-1001', 'goodsName' => 'Starter Plan', ], ]);
Query order:
$response = BinancePay::queryOrder('ORDER-1001');
DTO-based order creation:
use Codeglen\BinancePay\DTO\OrderData; use Codeglen\BinancePay\Facades\BinancePay; $order = new OrderData( merchantTradeNo: 'ORDER-1002', currency: 'USDT', goodsName: 'Pro Plan', goodsCategory: 'D000', referenceGoodsId: 'SKU-1002', totalFee: 1000, // smallest currency unit expected by your integration extra: ['returnUrl' => 'https://example.com/paid'] ); $response = BinancePay::createOrder($order);
Webhook Verification
When enabled, the package registers:
POST /binancepay/webhook(or your configuredBINANCE_PAY_WEBHOOK_PATH)
The controller validates Binance headers:
BinancePay-TimestampBinancePay-NonceBinancePay-Signature
If signature verification succeeds and status is PAID, it dispatches:
Codeglen\BinancePay\Events\PaymentPaid
Listen for the event in your app to complete payment fulfillment.
Testing
composer test
Author
Abul Kashem (akasham67@gmail.com)
License
MIT
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-09