datlechin / sepay-php
v1.0.0
2024-10-02 04:20 UTC
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.9.2
Requires (Dev)
- pestphp/pest: ^1.20|^2.0|^3.2
README
SePay PHP 是一个帮助您轻松将 SePay 支付服务集成到您应用程序中的 PHP 库。这个库提供了管理银行账户、跟踪交易和处理 webhook 的方法。
安装
您可以通过 Composer 安装此包
composer require datlechin/sepay-php
使用方法
初始化 Client
前往 SePay 网站以获取 API Key。
use Datlechin\SePay\SePay; $client = SePay::client('your_api_key_here');
管理银行账户
// Lấy danh sách tài khoản ngân hàng $bankAccounts = $client->bankAccounts()->list(); // Lấy thông tin một tài khoản cụ thể $account = $client->bankAccounts()->get($accountId); // Đếm số lượng tài khoản $count = $client->bankAccounts()->count();
管理交易
// Lấy danh sách giao dịch $transactions = $client->transactions()->list(); // Lấy thông tin một giao dịch cụ thể $transaction = $client->transactions()->get($transactionId); // Đếm số lượng giao dịch $count = $client->transactions()->count();
处理 Webhook
use Datlechin\SePay\SePay; use Datlechin\SePay\Webhook\Payload; use Datlechin\SePay\Webhook\Webhook; $webhook = SePay::webhook(); $webhook->setAuthorization(Webhook::AUTH_API_KEY, 'your_api_key_here'); $webhook->handle(function (Payload $payload) { // Xử lý webhook như lưu thông tin giao dịch hay cập nhật trạng thái đơn hàng... return true; // Trả về true để xác nhận webhook hợp lệ hoặc false nếu không hợp lệ });
测试
composer test
作者
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 以获取更多信息。